Skip to main content

iOS Setup

iOS-specific configuration for SwiftPatch.

Requirements
  • iOS 13.4+
  • Swift 5.9+
  • Xcode 15+

Step 1: Install CocoaPods

CocoaPods (iOS dependency manager, similar to npm for native iOS libraries) handles native linking automatically.

cd ios && pod install && cd ..

The SDK auto-links via its podspec (CocoaPods package definition file).

Your Podfile must set the minimum iOS version:

ios/Podfile
platform :ios, '13.4'

Step 2: Add Your App ID

ios/YourApp/Info.plist
<plist version="1.0">
<dict>
<!-- ...other configs... -->

<key>SwiftPatchAppId</key>
<string>YOUR_APP_ID</string>

<!-- Optional: Public key for bundle signature verification -->
<key>SwiftPatchPublicKey</key>
<string>YOUR_PUBLIC_KEY</string>

<!-- Optional: Custom server URL (defaults to SwiftPatch cloud) -->
<key>SwiftPatchServerUrl</key>
<string>https://your-server.com/api/v1</string>

<!-- ...other configs... -->
</dict>
</plist>
tip

Find your App ID in the SwiftPatch Dashboard under Settings.

Native Config Keys

KeyRequiredDescription
SwiftPatchAppIdYesApp ID from the dashboard
SwiftPatchServerUrlNoCustom server URL (self-hosted only)
SwiftPatchPublicKeyNoPublic key for bundle signing

Step 3: Update AppDelegate

Update your AppDelegate to load the SwiftPatch bundle in release builds.

Swift (React Native 0.76+)

ios/YourApp/AppDelegate.swift
import react_native_swiftpatch

@main
class AppDelegate: RCTAppDelegate {
override func bundleURL() -> URL? {
#if DEBUG
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
return SwiftPatchModule.getBundleURL()
#endif
}
}

The #if DEBUG check uses Metro (React Native's JavaScript bundler) in development and SwiftPatch in production.

Objective-C

ios/YourApp/AppDelegate.mm
#import "SwiftPatchModule.h"

@implementation AppDelegate

- (NSURL *)bundleURL {
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [SwiftPatchModule getBundleURL];
#endif
}

@end

You're all set!


Troubleshooting

Pod Install Fails

cd ios
pod deintegrate
pod install
cd ..

Xcode Build Errors

  1. Clean the build folder: Product > Clean Build Folder (Cmd+Shift+K)
  2. Delete derived data (Xcode's build cache): rm -rf ~/Library/Developer/Xcode/DerivedData
  3. Re-run pod install

Bundle Not Loading in Release

Make sure bundleURL returns the SwiftPatch bundle in release builds. The #if DEBUG check should use Metro in development and SwiftPatch in production.

info

For more issues, see the full Troubleshooting guide.