Skip to main content

iOS Setup

Once you've acquired the CodePush plugin, you need to integrate it into the Xcode project of your React Native app and configure it correctly. To do this, take the following steps: ​

  1. Run cd ios && pod install && cd .. to install the necessary CocoaPods dependencies. ​
  2. Change bundleUrl on AppDelegate file.
  • Open up the ios/[ProjectName]/AppDelegate.swift file, and add an import statement for the CodePush headers;

  • Find the following line of code, which sets the source URL for bridge for production release and replace it with the following line;

    import React
    import CodePush

    override func bundleURL() -> URL? {
    #if DEBUG
    RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
    #else
    Bundle.main.url(forResource: "main", withExtension: "jsbundle")
    CodePush.bundleURL()
    #endif
    }
  1. Add the CodePushDeploymentKey key (generated in the create app step) in the file ios/[ProjectName]/Info.plist
<key>CodePushDeploymentKey</key>
<string>YOUR_IOS_DEPLOYMENT_KEY</string>
  1. Certifies that your deployment_target is 15.5 or higher in your ios/Podfile file.
platform :ios, '15.5'

Code Signing setup (optional)

Starting with CLI version 2.1.0 you can self sign bundles during release and verify its signature before installation of update. For more info about Code Signing please refer to relevant documentation section.

In order to configure Public Key for bundle verification you need to add record in Info.plist with name CodePushPublicKey and string value of public key content. Example:

<plist version="1.0">
<dict>
<!-- ...other configs... -->

<key>CodePushPublicKey</key>
<string>-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANkWYydPuyOumR/sn2agNBVDnzyRpM16NAUpYPGxNgjSEp0etkDNgzzdzyvyl+OsAGBYF3jCxYOXozum+uV5hQECAwEAAQ==
-----END PUBLIC KEY-----</string>

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