diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index f57df8c4d..aab7c89ab 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -16,7 +16,7 @@ What actually happens? ### Reproducible Demo -* Download https://github.com/microsoft/react-native-code-push/archive/master.zip and unzip. From `Examples` folder run `node create-app.js appName react-native@0.71.19 react-native-code-push@9.0.0` command to generate plain CodePushified React Native app. Please see description on top of `create-app.js` file content if needed +* Download https://github.com/microsoft/react-native-code-push/archive/master.zip and unzip. From `Examples` folder run `node create-app.js appName react-native@0.71.19 react-native-code-push@9.0.1` command to generate plain CodePushified React Native app. Please see description on top of `create-app.js` file content if needed * If you can't reproduce the bug on it, provide us as much info as possible about your project ### Environment diff --git a/.gitignore b/.gitignore index bfd988d8c..a956393b0 100644 --- a/.gitignore +++ b/.gitignore @@ -191,6 +191,6 @@ Ankh.NoLoad Examples/testapp_rn # Android debug build files (conflict ignoring #Visual Studio files) -!android/app/src/debug/ +!android/src/debug/ -**/*.tgz \ No newline at end of file +**/*.tgz diff --git a/CodePush.podspec b/CodePush.podspec index c78a4979f..feccb6d06 100644 --- a/CodePush.podspec +++ b/CodePush.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.author = package['author'] s.license = package['license'] s.homepage = package['homepage'] - s.source = { :git => 'https://github.com/microsoft/react-native-code-push.git', :tag => "v#{s.version}"} + s.source = { :git => 'https://github.com/CodePushNext/react-native-code-push.git', :tag => "v#{s.version}"} s.ios.deployment_target = '15.5' s.tvos.deployment_target = '15.5' s.preserve_paths = '*.js' diff --git a/Examples/CodePushDemoApp/App.js b/Examples/CodePushDemoApp/App.js index 2b5cf20ac..32e38df81 100644 --- a/Examples/CodePushDemoApp/App.js +++ b/Examples/CodePushDemoApp/App.js @@ -9,7 +9,7 @@ import { View, } from 'react-native'; -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; class App extends Component<{}> { constructor() { diff --git a/Examples/CodePushDemoApp/android/settings.gradle b/Examples/CodePushDemoApp/android/settings.gradle index de0c8f403..c0d9e26e0 100644 --- a/Examples/CodePushDemoApp/android/settings.gradle +++ b/Examples/CodePushDemoApp/android/settings.gradle @@ -1,4 +1,3 @@ rootProject.name = 'CodePushDemoApp' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) -include ':app', ':react-native-code-push' -project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app') +include ':app' \ No newline at end of file diff --git a/Examples/CodePushDemoApp/package.json b/Examples/CodePushDemoApp/package.json index 6315a07f9..192aa8cd5 100644 --- a/Examples/CodePushDemoApp/package.json +++ b/Examples/CodePushDemoApp/package.json @@ -12,7 +12,7 @@ "dependencies": { "react": "17.0.2", "react-native": "0.68.5", - "react-native-code-push": "8.1.0" + "@chlee1001/react-native-code-push": "8.1.0" }, "resolutions": { "strip-ansi": "^6.0.1", diff --git a/Examples/CodePushDemoAppCpp/App.js b/Examples/CodePushDemoAppCpp/App.js index 20bfad332..b48b77948 100644 --- a/Examples/CodePushDemoAppCpp/App.js +++ b/Examples/CodePushDemoAppCpp/App.js @@ -11,7 +11,7 @@ import { View, } from 'react-native'; -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; class App extends Component<{}> { constructor() { @@ -86,7 +86,7 @@ class App extends Component<{}> { this.codePushDownloadDidProgress.bind(this) ); } - + restartApp() { CodePush.restartApp(); } diff --git a/Examples/CodePushDemoAppCpp/package.json b/Examples/CodePushDemoAppCpp/package.json index b0af3379e..57ed68a62 100644 --- a/Examples/CodePushDemoAppCpp/package.json +++ b/Examples/CodePushDemoAppCpp/package.json @@ -11,7 +11,7 @@ "dependencies": { "react": "^17.0.2", "react-native": "^0.68.5", - "react-native-code-push": "^8.1.0", + "@chlee1001/react-native-code-push": "^8.1.0", "react-native-windows": "^1.0.0" }, "resolutions": { diff --git a/Examples/CodePushDemoAppNewArch/android/app/build.gradle b/Examples/CodePushDemoAppNewArch/android/app/build.gradle index 5f867685f..96a439e7f 100644 --- a/Examples/CodePushDemoAppNewArch/android/app/build.gradle +++ b/Examples/CodePushDemoAppNewArch/android/app/build.gradle @@ -117,3 +117,5 @@ dependencies { implementation jscFlavor } } + +apply from: "../../node_modules/@chlee1001/react-native-code-push/android/codepush.gradle" diff --git a/Examples/CodePushDemoAppNewArch/android/app/src/main/java/com/codepushdemoappnewarch/MainApplication.kt b/Examples/CodePushDemoAppNewArch/android/app/src/main/java/com/codepushdemoappnewarch/MainApplication.kt index a0b8d53aa..2e442cf51 100644 --- a/Examples/CodePushDemoAppNewArch/android/app/src/main/java/com/codepushdemoappnewarch/MainApplication.kt +++ b/Examples/CodePushDemoAppNewArch/android/app/src/main/java/com/codepushdemoappnewarch/MainApplication.kt @@ -17,35 +17,27 @@ import com.microsoft.codepush.react.CodePush @OptIn(UnstableReactNativeAPI::class) class MainApplication : Application(), ReactApplication { + val defaultPackageList by lazy { + PackageList(this).packages.apply { + // Packages that cannot be autolinked yet can be added manually here, for example: + // add(MyReactNativePackage()) + } + } + override val reactNativeHost: ReactNativeHost = object : DefaultReactNativeHost(this) { - override fun getPackages(): List = - PackageList(this).packages.apply { - // Packages that cannot be autolinked yet can be added manually here, for example: - // add(MyReactNativePackage()) - } + override fun getPackages(): List = defaultPackageList override fun getJSMainModuleName(): String = "index" override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG + override fun getJSBundleFile(): String = CodePush.getJSBundleFile() override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED } - override val reactHost: ReactHost - get() = getDefaultReactHost( - applicationContext, - PackageList(this).packages.apply { - // Packages that cannot be autolinked yet can be added manually here, for example: - // add(MyReactNativePackage()) - }, - jsMainModulePath = "index", - jsBundleAssetPath = "index.android.bundle", - jsBundleFilePath = CodePush.getJSBundleFile(), - isHermesEnabled = BuildConfig.IS_HERMES_ENABLED, - useDevSupport = BuildConfig.DEBUG, - ) + override val reactHost: ReactHost get() = getDefaultReactHost(this, reactNativeHost) override fun onCreate() { super.onCreate() diff --git a/Examples/CodePushDemoAppNewArch/android/settings.gradle b/Examples/CodePushDemoAppNewArch/android/settings.gradle index ada591976..9ea964767 100644 --- a/Examples/CodePushDemoAppNewArch/android/settings.gradle +++ b/Examples/CodePushDemoAppNewArch/android/settings.gradle @@ -2,6 +2,5 @@ pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") } plugins { id("com.facebook.react.settings") } extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() } rootProject.name = 'CodePushDemoAppNewArch' -include ':app', ':react-native-code-push' -project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app') +include ':app' includeBuild('../node_modules/@react-native/gradle-plugin') diff --git a/Examples/CodePushDemoAppNewArch/ios/CodePushDemoAppNewArch.xcodeproj/project.pbxproj b/Examples/CodePushDemoAppNewArch/ios/CodePushDemoAppNewArch.xcodeproj/project.pbxproj index 1c925ac1d..0162dacff 100644 --- a/Examples/CodePushDemoAppNewArch/ios/CodePushDemoAppNewArch.xcodeproj/project.pbxproj +++ b/Examples/CodePushDemoAppNewArch/ios/CodePushDemoAppNewArch.xcodeproj/project.pbxproj @@ -471,6 +471,7 @@ CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 1; ENABLE_BITCODE = NO; + ENABLE_USER_SCRIPT_SANDBOXING = NO; INFOPLIST_FILE = CodePushDemoAppNewArch/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.1; LD_RUNPATH_SEARCH_PATHS = ( @@ -498,6 +499,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 1; + ENABLE_USER_SCRIPT_SANDBOXING = NO; INFOPLIST_FILE = CodePushDemoAppNewArch/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.1; LD_RUNPATH_SEARCH_PATHS = ( @@ -586,10 +588,7 @@ "-DFOLLY_CFG_NO_COROUTINES=1", "-DFOLLY_HAVE_CLOCK_GETTIME=1", ); - OTHER_LDFLAGS = ( - "$(inherited)", - " ", - ); + OTHER_LDFLAGS = "$(inherited) "; REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG"; @@ -658,10 +657,7 @@ "-DFOLLY_CFG_NO_COROUTINES=1", "-DFOLLY_HAVE_CLOCK_GETTIME=1", ); - OTHER_LDFLAGS = ( - "$(inherited)", - " ", - ); + OTHER_LDFLAGS = "$(inherited) "; REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; USE_HERMES = true; diff --git a/Examples/CodePushDemoAppNewArch/ios/CodePushDemoAppNewArch.xcodeproj/xcshareddata/xcschemes/CodePushDemoAppNewArch.xcscheme b/Examples/CodePushDemoAppNewArch/ios/CodePushDemoAppNewArch.xcodeproj/xcshareddata/xcschemes/CodePushDemoAppNewArch.xcscheme index deed4c430..5160a502d 100644 --- a/Examples/CodePushDemoAppNewArch/ios/CodePushDemoAppNewArch.xcodeproj/xcshareddata/xcschemes/CodePushDemoAppNewArch.xcscheme +++ b/Examples/CodePushDemoAppNewArch/ios/CodePushDemoAppNewArch.xcodeproj/xcshareddata/xcschemes/CodePushDemoAppNewArch.xcscheme @@ -41,7 +41,7 @@ #import @@ -24,7 +25,7 @@ - (NSURL *)bundleURL #if DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else - return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; + return [CodePush bundleURL]; #endif } diff --git a/Examples/CodePushDemoAppNewArch/ios/Podfile.lock b/Examples/CodePushDemoAppNewArch/ios/Podfile.lock index 3a2127215..9971a5188 100644 --- a/Examples/CodePushDemoAppNewArch/ios/Podfile.lock +++ b/Examples/CodePushDemoAppNewArch/ios/Podfile.lock @@ -1,5 +1,11 @@ PODS: + - Base64 (1.1.2) - boost (1.84.0) + - CodePush (8.1.0): + - Base64 (~> 1.1) + - JWT (~> 3.0.0-beta.12) + - React-Core + - SSZipArchive (~> 2.2.2) - DoubleConversion (1.1.6) - FBLazyVector (0.76.0) - fmt (9.1.0) @@ -7,6 +13,8 @@ PODS: - hermes-engine (0.76.0): - hermes-engine/Pre-built (= 0.76.0) - hermes-engine/Pre-built (0.76.0) + - JWT (3.0.0-beta.14): + - Base64 (~> 1.1.2) - RCT-Folly (2024.01.01.00): - boost - DoubleConversion @@ -1510,10 +1518,12 @@ PODS: - React-perflogger (= 0.76.0) - React-utils (= 0.76.0) - SocketRocket (0.7.1) + - SSZipArchive (2.2.3) - Yoga (0.0.0) DEPENDENCIES: - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) + - CodePush (from `../node_modules/react-native-code-push`) - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) - fmt (from `../node_modules/react-native/third-party-podspecs/fmt.podspec`) @@ -1581,11 +1591,16 @@ DEPENDENCIES: SPEC REPOS: trunk: + - Base64 + - JWT - SocketRocket + - SSZipArchive EXTERNAL SOURCES: boost: :podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec" + CodePush: + :path: "../node_modules/react-native-code-push" DoubleConversion: :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" FBLazyVector: @@ -1713,12 +1728,15 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/yoga" SPEC CHECKSUMS: + Base64: cecfb41a004124895a7bcee567a89bae5a89d49b boost: 1dca942403ed9342f98334bf4c3621f011aa7946 + CodePush: 255d7607f428dcbec39085f81a206b170e01d012 DoubleConversion: f16ae600a246532c4020132d54af21d0ddb2a385 FBLazyVector: aa59bef5c46e93168bffcf3dc37ee1e176de799a fmt: 10c6e61f4be25dc963c36bd73fc7b1705fe975be glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a hermes-engine: 9de51d2f67336348a6cd5b686330e436d1dbd522 + JWT: ef71dfb03e1f842081e64dc42eef0e164f35d251 RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648 RCTDeprecation: 4c2c4a088b6f0ccfcbd53c9d5614b0238ad57909 RCTRequired: 2d8a683a7848bc0baf5883f0792c1ac43f6267b5 @@ -1729,16 +1747,16 @@ SPEC CHECKSUMS: React-CoreModules: ac0a55891bcb72a9f8c6631128e7cbbf9ce06b65 React-cxxreact: fec14d0078f627985b2cce98f90458e969a848ae React-debug: c185808d0674717d0d408d7ce45a7343f0072199 - React-defaultsnativemodule: 4340736904471e594da5568971f401440a96277e - React-domnativemodule: 084716bdc086debd25c4311058567ae2699f506a + React-defaultsnativemodule: 5dc781a1e3274cbb6d6d3e91f5bf9914a258115d + React-domnativemodule: f81f69be048840a0efcf0add685ad0cf5583fb5f React-Fabric: 8de8a37b62f81d264302462cf33c69b97faf9979 React-FabricComponents: 777f5e4fdc39355fa0275412a3b8f2430a7bef1d React-FabricImage: 9202f25c36040de738cd486ea6b8480f2d62b05f React-featureflags: 51f1373ac42cefac4936c62be46dbe2a1f9f1f7d - React-featureflagsnativemodule: 0d84b94449c0768cca16ab1622d46354fd452946 + React-featureflagsnativemodule: 59083d49f82a50aecba32e1cddb791ca362df198 React-graphics: 4508c3473dd97c76d627938bfa0c304abc37e3b0 React-hermes: 9d2b208eb88bfd4eb156064a831bec2f01e8165d - React-idlecallbacksnativemodule: 0c87d8ed6f305d7484a2668b9ef35643261899f8 + React-idlecallbacksnativemodule: fc31bde9dc276e78d4289b4fd209b5fbe762600b React-ImageManager: f046a503ff853fc5aec31db274c03cea239e5de4 React-jserrorhandler: a03ee04881559e8a0cdcd0cb7dbbc4d1c78edc9d React-jsi: b7efc160dd211f6a3999cdc4a2c9fc2bbcda05db @@ -1747,16 +1765,16 @@ SPEC CHECKSUMS: React-jsitracing: 043658000ac681e8aa5f3ee61690e0686da01bfe React-logger: d1a89c7d9b3c847eb63eb85724c54b06cae2c939 React-Mapbuffer: b0b4ace5b62b269f3838df26ba2d8b4f39f90783 - React-microtasksnativemodule: 1f580b56eca388dbc696a083ba6125e869194415 + React-microtasksnativemodule: 0b7db04c18f6bb01ef5b1f9007c3229abecc35dd React-nativeconfig: 72c10ff34863148ef90df9c9c8eacba99d2faaaa React-NativeModulesApple: 5ec49182fa000b2215ee1bed03e2867f8323ccf5 React-perflogger: 073c7a8a436b3fe724f1df34e9d1f3db1d25fe74 React-performancetimeline: 52f8e3b73b98dad5d5ba360035ad0be294087bd8 React-RCTActionSheet: 96cf4d93fccb7a96ba1867e173c586e7ad9cd5cc React-RCTAnimation: bcd2356245abffd232ea8d4d5b64ae0bf93c7ef0 - React-RCTAppDelegate: 8abd8ea3f8b868ce9cfc63e1b566b3de75b742d0 + React-RCTAppDelegate: 20242d0ddf9348f8de10e5750d8c0844e222b0e3 React-RCTBlob: 7fadfb83ce2bb5580b73368384fe242aaa6ddbc6 - React-RCTFabric: d389235d2a28dc767baf7a94f35997f7bb56194c + React-RCTFabric: 504fe0307b1e72d093aa84e1c5ccb26d1bca66e3 React-RCTImage: fdf95e50ad94842fd9c508ed36d9bfd6e1ffa8ef React-RCTLinking: 76a398421d9a26422e5733439e2a9d13f19e5a99 React-RCTNetwork: 2bf6ca74a1a14648f6985cfbfc4f8813fa66e6a4 @@ -1776,6 +1794,7 @@ SPEC CHECKSUMS: ReactCodegen: dbfef1fef26f42c900bb1884fa149d49d501d64d ReactCommon: 429ca28cd813c31359c73ffac6dc24f93347d522 SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748 + SSZipArchive: 62d4947b08730e4cda640473b0066d209ff033c9 Yoga: f8ec45ce98bba1bc93dd28f2ee37215180e6d2b6 PODFILE CHECKSUM: de9556319c6d177cc038861b6e8a4c1189ce67bd diff --git a/Examples/CodePushDemoAppNewArch/package-lock.json b/Examples/CodePushDemoAppNewArch/package-lock.json index d3e72a3e0..f1b121420 100644 --- a/Examples/CodePushDemoAppNewArch/package-lock.json +++ b/Examples/CodePushDemoAppNewArch/package-lock.json @@ -8,9 +8,9 @@ "name": "CodePushDemoAppNewArch", "version": "0.0.1", "dependencies": { + "@chlee1001/react-native-code-push": "file:../..", "react": "18.3.1", - "react-native": "0.76.0", - "react-native-code-push": "file:../.." + "react-native": "0.76.0" }, "devDependencies": { "@babel/core": "^7.25.2", @@ -37,10 +37,11 @@ } }, "../..": { - "version": "9.0.0", + "name": "@chlee1001/react-native-code-push", + "version": "10.0.0-alpha.3", "license": "MIT", "dependencies": { - "code-push": "^4.2.2", + "code-push": "4.2.3", "glob": "^7.1.7", "hoist-non-react-statics": "^3.3.2", "inquirer": "^8.1.5", @@ -2086,6 +2087,10 @@ "dev": true, "license": "MIT" }, + "node_modules/@chlee1001/react-native-code-push": { + "resolved": "../..", + "link": true + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz", @@ -10740,10 +10745,6 @@ } } }, - "node_modules/react-native-code-push": { - "resolved": "../..", - "link": true - }, "node_modules/react-native/node_modules/ansi-styles": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", diff --git a/Examples/CodePushDemoAppNewArch/package.json b/Examples/CodePushDemoAppNewArch/package.json index f04371616..2da24a9ca 100644 --- a/Examples/CodePushDemoAppNewArch/package.json +++ b/Examples/CodePushDemoAppNewArch/package.json @@ -12,7 +12,7 @@ "dependencies": { "react": "18.3.1", "react-native": "0.76.0", - "react-native-code-push": "file:../.." + "@chlee1001/react-native-code-push": "file:../.." }, "devDependencies": { "@babel/core": "^7.25.2", diff --git a/Examples/create-app.js b/Examples/create-app.js index 0b527cee2..662487048 100644 --- a/Examples/create-app.js +++ b/Examples/create-app.js @@ -12,9 +12,9 @@ Requirements: sudo gem install cocoapods -n /usr/local/bin Usage: node create-app.js - 1. node create-app.js + 1. node create-app.js 2. node create-app.js myapp - 3. node create-app.js myapp react-native@0.62 react-native-code-push@6.1.0 + 3. node create-app.js myapp react-native@0.62 react-native-code-push@6.1.0 4. node create-app.js myapp react-native@latest Microsoft/react-native-code-push Parameters: @@ -245,11 +245,11 @@ function isReactNativeVersionLowerThan(version) { // Configuring android applications for react-native version higher than 0.60 function androidSetup() { - const buildGradlePath = path.join('android', 'app', 'build.gradle'); + const buildGradlePath = path.join('android', 'build.gradle'); const settingsGradlePath = path.join('android', 'settings.gradle'); const mainApplicationType = reactNativeVersionIsLowerThanV073 ? 'java' : 'kt'; - const mainApplicationPath = path.join('android', 'app', 'src', 'main', 'java', 'com', appName, `MainApplication.${mainApplicationType}`); - const stringsResourcesPath = path.join('android', 'app', 'src', 'main', 'res', 'values', 'strings.xml'); + const mainApplicationPath = path.join('android', 'src', 'main', 'java', 'com', appName, `MainApplication.${mainApplicationType}`); + const stringsResourcesPath = path.join('android', 'src', 'main', 'res', 'values', 'strings.xml'); let stringsResourcesContent = fs.readFileSync(stringsResourcesPath, "utf8"); const insertAfterString = ""; diff --git a/README.md b/README.md index 51f5f43fc..67bc5de51 100644 --- a/README.md +++ b/README.md @@ -62,36 +62,16 @@ In order to ensure that your end users always have a functioning version of your - iOS (7+) - Android (4.1+) on TLS 1.2 compatible devices -- Windows (UWP) +- Windows (UWP) - Not Tested. We recommend to use [microsoft/code-push-react-native](https://github.com/microsoft/react-native-code-push) We try our best to maintain backwards compatibility of our plugin with previous versions of React Native, but due to the nature of the platform, and the existence of breaking changes between releases, it is possible that you need to use a specific version of the CodePush plugin in order to support the exact version of React Native you are using. The following table outlines which CodePush plugin versions officially support the respective React Native versions: -| React Native version(s) | Supporting CodePush version(s) | -|-------------------------|-------------------------------------------------------| -| <0.14 | **Unsupported** | -| v0.14 | v1.3 *(introduced Android support)* | -| v0.15-v0.18 | v1.4-v1.6 *(introduced iOS asset support)* | -| v0.19-v0.28 | v1.7-v1.17 *(introduced Android asset support)* | -| v0.29-v0.30 | v1.13-v1.17 *(RN refactored native hosting code)* | -| v0.31-v0.33 | v1.14.6-v1.17 *(RN refactored native hosting code)* | -| v0.34-v0.35 | v1.15-v1.17 *(RN refactored native hosting code)* | -| v0.36-v0.39 | v1.16-v1.17 *(RN refactored resume handler)* | -| v0.40-v0.42 | v1.17 *(RN refactored iOS header files)* | -| v0.43-v0.44 | v2.0+ *(RN refactored uimanager dependencies)* | -| v0.45 | v3.0+ *(RN refactored instance manager code)* | -| v0.46 | v4.0+ *(RN refactored js bundle loader code)* | -| v0.46-v0.53 | v5.1+ *(RN removed unused registration of JS modules)*| -| v0.54-v0.55 | v5.3+ *(Android Gradle Plugin 3.x integration)* | -| v0.56-v0.58 | v5.4+ *(RN upgraded versions for Android tools)* | -| v0.59 | v5.6+ *(RN refactored js bundle loader code)* | -| v0.60-v0.61 | v6.0+ *(RN migrated to Autolinking)* | -| v0.62-v0.64 | v6.2+ *(RN removed LiveReload)* | -| v0.65-v0.70 | v7.0+ *(RN updated iPhone-target-version)* | -| v0.71 | v8.0+ *(RN moved to react-native-gradle-plugin)* | - -*NOTE: `react-native-code-push` versions lower than **[v5.7.0](https://github.com/microsoft/react-native-code-push/releases/tag/v5.7.0)** will stop working in the near future. You can find more information in our [documentation](https://github.com/microsoft/code-push/blob/master/migration-notice.md).* - -We work hard to respond to new RN releases, but they do occasionally break us. We will update this chart with each RN release, so that users can check to see what our "official" support is. +| React Native version(s) | Supporting CodePush version(s) | +|-------------------------|------------------------------------------------------------------------------------------------------| +| https://yourcodepush.server.com ``` -### API for React Native lower than 0.60 - The Java API is made available by importing the `com.microsoft.codepush.react.CodePush` class into your `MainActivity.java` file, and consists of a single public class named `CodePush`. +### Java API Reference (Android) + #### CodePush Constructs the CodePush client runtime and represents the `ReactPackage` instance that you add to you app's list of packages. diff --git a/docs/multi-deployment-testing-android.md b/docs/multi-deployment-testing-android.md index 5de29661f..8d61bd97e 100644 --- a/docs/multi-deployment-testing-android.md +++ b/docs/multi-deployment-testing-android.md @@ -10,7 +10,7 @@ The [Android Gradle plugin](https://google.github.io/android-gradle-dsl/current/ To set this up, perform the following steps: -**For React Native >= v0.60** +**For React Native >= v0.76** 1. Open the project's app level `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects) @@ -51,98 +51,5 @@ To set this up, perform the following steps: *NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).* -**For React Native v0.29 - v0.59** - -1. Open up your `MainApplication.java` file and make the following changes: - - ```java - @Override - protected List getPackages() { - return Arrays.asList( - ... - new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG), // Add/change this line. - ... - ); - } - ``` - -2. Open your app's `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects) - -3. Find the `android { buildTypes {} }` section and define `buildConfigField` entries for both your `debug` and `release` build types, which reference your `Staging` and `Production` deployment keys respectively. If you prefer, you can define the key literals in your `gradle.properties` file, and then reference them here. Either way will work, and it's just a matter of personal preference. - - ```groovy - android { - ... - buildTypes { - debug { - ... - // Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key. - buildConfigField "String", "CODEPUSH_KEY", '""' - ... - } - - releaseStaging { - ... - buildConfigField "String", "CODEPUSH_KEY", '""' - // Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues - // Add the following line if not already there - matchingFallbacks = ['release'] - ... - } - - release { - ... - buildConfigField "String", "CODEPUSH_KEY", '""' - ... - } - } - ... - } - ``` - - *NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).* - -4. Pass the deployment key to the `CodePush` constructor via the build config you defined, as opposed to a string literal. - -**For React Native v0.19 - v0.28** - -Open up your `MainActivity.java` file and make the following changes: - - ```java - @Override - protected List getPackages() { - return Arrays.asList( - ... - new CodePush(BuildConfig.CODEPUSH_KEY, this, BuildConfig.DEBUG), // Add/change this line. - ... - ); - } - ``` - -*Note: If you gave your build setting a different name in your Gradle file, simply make sure to reflect that in your Java code.* - -And that's it! Now when you run or build your app, your debug builds will automatically be configured to sync with your `Staging` deployment, and your release builds will be configured to sync with your `Production` deployment. - -*NOTE: By default, the `react-native run-android` command builds and deploys the debug version of your app, so if you want to test out a release/production build, simply run `react-native run-android --variant release. Refer to the [React Native docs](http://facebook.github.io/react-native/docs/signed-apk-android.html#conten) for details about how to configure and create release builds for your Android apps.* - -If you want to be able to install both debug and release builds simultaneously on the same device (highly recommended!), then you need to ensure that your debug build has a unique identity and icon from your release build. Otherwise, neither the OS nor you will be able to differentiate between the two. You can achieve this by performing the following steps: - -1. In your `build.gradle` file, specify the [`applicationIdSuffix`](http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html#com.android.build.gradle.internal.dsl.BuildType:applicationIdSuffix) field for your debug build type, which gives your debug build a unique identity for the OS (like `com.foo` vs. `com.foo.debug`). - -```groovy -buildTypes { - debug { - applicationIdSuffix ".debug" - } -} -``` - -2. Create the `app/src/debug/res` directory structure in your app, which allows overriding resources (like strings, icons, layouts) for your debug builds - -3. Create a `values` directory underneath the debug res directory created in #2, and copy the existing `strings.xml` file from the `app/src/main/res/values` directory - -4. Open up the new debug `strings.xml` file and change the `` element's value to something else (like `foo-debug`). This ensures that your debug build now has a distinct display name, so that you can differentiate it from your release build. - -5. Optionally, create "mirrored" directories in the `app/src/debug/res` directory for all of your app's icons that you want to change for your debug build. This part isn't technically critical, but it can make it easier to quickly spot your debug builds on a device if its icon is noticeable different. And that's it! View [here](http://tools.android.com/tech-docs/new-build-system/resource-merging) for more details on how resource merging works in Android. diff --git a/docs/setup-android.md b/docs/setup-android.md index ee8b61a90..e32259dbe 100644 --- a/docs/setup-android.md +++ b/docs/setup-android.md @@ -1,33 +1,14 @@ ## Android Setup -* [Plugin Installation and Configuration for React Native 0.60 version and above](#plugin-installation-and-configuration-for-react-native-060-version-and-above-android) -* [Plugin Installation for React Native lower than 0.60 (Android)](#plugin-installation-for-react-native-lower-than-060-android) - * [Plugin Installation (Android - RNPM)](#plugin-installation-android---rnpm) - * [Plugin Installation (Android - Manual)](#plugin-installation-android---manual) -* [Plugin Configuration for React Native lower than 0.60 (Android)](#plugin-configuration-for-react-native-lower-than-060-android) - * [For React Native v0.29 - v0.59](#for-react-native-v029---v059) - * [For newly created React Native application](#for-newly-created-react-native-application) - * [For existing native application](#for-existing-native-application) - * [For React Native v0.19 - v0.28](#for-react-native-v019---v028) - * [Background React Instances](#background-react-instances) - * [For React Native >= v0.29 (Background React Instances)](#for-react-native--v029-background-react-instances) - * [For React Native v0.19 - v0.28 (Background React Instances)](#for-react-native-v019---v028-background-react-instances) - * [WIX React Native Navigation applications (ver 1.x)](#wix-react-native-navigation-applications) +* [Plugin Installation and Configuration for React Native 0.76 version and above](#plugin-installation-and-configuration-for-react-native-060-version-and-above-android) * [Code Signing setup](#code-signing-setup) In order to integrate CodePush into your Android project, please perform the following steps: -### Plugin Installation and Configuration for React Native 0.60 version and above (Android) +### Plugin Installation and Configuration for React Native 0.76 version and above (Android) -1. In your `android/settings.gradle` file, make the following additions at the end of the file: - ```gradle - ... - include ':app', ':chlee1001_react-native-code-push' - project(':chlee1001_react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/@chlee1001/react-native-code-push/android/app') - ``` - -2. In your `android/app/build.gradle` file, add the `codepush.gradle` file as an additional build task definition to the end of the file: +1. In your `android/app/build.gradle` file, add the `codepush.gradle` file as an additional build task definition to the end of the file: ```gradle ... @@ -35,9 +16,11 @@ In order to integrate CodePush into your Android project, please perform the fol ... ``` -3. Update the `MainApplication` file to use CodePush via the following changes: +2. Update the `MainApplication` file to use CodePush via the following changes: - For React Native 0.73 and above: update the `MainApplication.kt` + For React Native 0.76 and above: update the `MainApplication.kt` + + **Important! : PackageList must be instantiated only one in application lifetime.** ```kotlin ... @@ -45,6 +28,14 @@ In order to integrate CodePush into your Android project, please perform the fol import com.microsoft.codepush.react.CodePush class MainApplication : Application(), ReactApplication { + + // PackageList must be instantiated only one in application lifetime. + val defaultPackageList by lazy { + PackageList(this).packages.apply { + // Packages that cannot be autolinked yet can be added manually here, for example: + // add(MyReactNativePackage()) + } + } override val reactNativeHost: ReactNativeHost = object : DefaultReactNativeHost(this) { @@ -60,30 +51,8 @@ In order to integrate CodePush into your Android project, please perform the fol } ``` - For React Native 0.72 and below: update the `MainApplication.java` - ```java - ... - // 1. Import the plugin class. - import com.microsoft.codepush.react.CodePush; - - public class MainApplication extends Application implements ReactApplication { - - private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { - ... - - // 2. Override the getJSBundleFile method in order to let - // the CodePush runtime determine where to get the JS - // bundle location from on each app start - @Override - protected String getJSBundleFile() { - return CodePush.getJSBundleFile(); - } - }; - } - ``` - -4. Add the Deployment key to `strings.xml`: +3. Add the Deployment key to `strings.xml`: To let the CodePush runtime know which deployment it should query for updates, open your app's `strings.xml` file and add a new string named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `appcenter codepush deployment list -a / -k` in the CodePush CLI (the `-k` flag is necessary since keys aren't displayed by default) and copying the value of the `Key` column which corresponds to the deployment you want to use (see below). Note that using the deployment's name (like Staging) will not work. The "friendly name" is intended only for authenticated management usage from the CLI, and not for public consumption within your app. @@ -102,350 +71,10 @@ In order to integrate CodePush into your Android project, please perform the fol *Note: If you need to dynamically use a different deployment, you can also override your deployment key in JS code using [Code-Push options](./api-js.md#CodePushOptions)* -### Plugin Installation for React Native lower than 0.60 (Android) - -In order to accommodate as many developer preferences as possible, the CodePush plugin supports Android installation via two mechanisms: - -1. [**RNPM**](#plugin-installation-android---rnpm) - [React Native Package Manager (RNPM)](https://github.com/rnpm/rnpm) is an awesome tool that provides the simplest installation experience possible for React Native plugins. If you're already using it, or you want to use it, then we recommend this approach. - -2. [**"Manual"**](#plugin-installation-android---manual) - If you don't want to depend on any additional tools or are fine with a few extra installation steps (it's a one-time thing), then go with this approach. - -*Note: Due to a code change from the React Native repository, if your installed React Native version ranges from 0.29 to 0.32, we recommend following the manual steps to set up correctly. * - -#### Plugin Installation (Android - RNPM) - -1. As of v0.27 of React Native, `rnpm link` has already been merged into the React Native CLI. Simply run: - ``` - react-native link react-native-code-push - ``` - - If your app uses a version of React Native that is lower than v0.27, run the following: - ``` - rnpm link react-native-code-push - ``` - - *Note: If you don't already have RNPM installed, you can do so by simply running `npm i -g rnpm` and then executing the above command.* - -2. If you're using RNPM >=1.6.0, you will be prompted for the deployment key you'd like to use. If you don't already have it, you can retrieve this value by running `appcenter codepush deployment list -a / -k`, or you can choose to ignore it (by simply hitting ``) and add it in later. To get started, we would recommend just using your `Staging` deployment key, so that you can test out the CodePush end-to-end. - -And that's it for installation using RNPM! Continue below to the [Plugin Configuration](#plugin-configuration-for-react-native-lower-than-060-android) section to complete the setup. - -#### Plugin Installation (Android - Manual) - -1. In your `android/settings.gradle` file, make the following additions: - - ```gradle - include ':app', ':react-native-code-push' - project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app') - ``` - -2. In your `android/app/build.gradle` file, add the `:react-native-code-push` project as a compile-time dependency: - - ```gradle - ... - dependencies { - ... - compile project(':react-native-code-push') - } - ``` - -3. In your `android/app/build.gradle` file, add the `codepush.gradle` file as an additional build task definition underneath `react.gradle`: - - ```gradle - ... - apply from: "../../node_modules/react-native/react.gradle" - apply from: "../../node_modules/react-native-code-push/android/codepush.gradle" - ... - ``` - -### Plugin Configuration for React Native lower than 0.60 (Android) - -*NOTE: If you used RNPM or `react-native link` to automatically link the plugin, these steps have already been done for you so you may skip this section.* - -After installing the plugin and syncing your Android Studio project with Gradle, you need to configure your app to consult CodePush for the location of your JS bundle, since it will "take control" of managing the current and all future versions. To do this: - -#### For React Native v0.29 - v0.59 - -##### For newly created React Native application - -If you are integrating Code Push into React Native application please do the following steps: - -Update the `MainApplication.java` file to use CodePush via the following changes: - -```java -... -// 1. Import the plugin class. -import com.microsoft.codepush.react.CodePush; - -public class MainApplication extends Application implements ReactApplication { - - private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { - ... - // 2. Override the getJSBundleFile method in order to let - // the CodePush runtime determine where to get the JS - // bundle location from on each app start - @Override - protected String getJSBundleFile() { - return CodePush.getJSBundleFile(); - } - - @Override - protected List getPackages() { - // 3. Instantiate an instance of the CodePush runtime and add it to the list of - // existing packages, specifying the right deployment key. If you don't already - // have it, you can run "appcenter codepush deployment list -a / -k" to retrieve your key. - return Arrays.asList( - new MainReactPackage(), - new CodePush("deployment-key-here", MainApplication.this, BuildConfig.DEBUG) - ); - } - }; -} -``` - -*NOTE: For React Native v0.49+ please be sure that `getJSMainModuleName` function in the `MainApplication.java` file determines correct URL to fetch JS bundle (used when dev support is enabled, see [this](https://github.com/facebook/react-native/blob/c7f37074ac89f7e568ca26a6bad3bdb02812c39f/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java#L124) for more details) e.g.* -``` -@Override -protected String getJSMainModuleName() { - return "index"; -} -``` - -##### For existing native application - -If you are integrating React Native into existing native application please do the following steps: - -Update `MyReactActivity.java` (it could be named differently in your app) file to use CodePush via the following changes: - -```java -... -// 1. Import the plugin class. -import com.microsoft.codepush.react.CodePush; - -public class MyReactActivity extends Activity { - private ReactRootView mReactRootView; - private ReactInstanceManager mReactInstanceManager; - - @Override - protected void onCreate(Bundle savedInstanceState) { - ... - mReactInstanceManager = ReactInstanceManager.builder() - // ... - // Add CodePush package - .addPackage(new CodePush("deployment-key-here", getApplicationContext(), BuildConfig.DEBUG)) - // Get the JS Bundle File via Code Push - .setJSBundleFile(CodePush.getJSBundleFile()) - // ... - - .build(); - mReactRootView.startReactApplication(mReactInstanceManager, "MyReactNativeApp", null); - - setContentView(mReactRootView); - } - - ... -} -``` - -#### For React Native v0.19 - v0.28 - -Update the `MainActivity.java` file to use CodePush via the following changes: - -```java -... -// 1. Import the plugin class (if you used RNPM to install the plugin, this -// should already be done for you automatically so you can skip this step). -import com.microsoft.codepush.react.CodePush; - -public class MainActivity extends ReactActivity { - // 2. Override the getJSBundleFile method in order to let - // the CodePush runtime determine where to get the JS - // bundle location from on each app start - @Override - protected String getJSBundleFile() { - return CodePush.getJSBundleFile(); - } - - @Override - protected List getPackages() { - // 3. Instantiate an instance of the CodePush runtime and add it to the list of - // existing packages, specifying the right deployment key. If you don't already - // have it, you can run "appcenter codepush deployment list -a / -k" to retrieve your key. - return Arrays.asList( - new MainReactPackage(), - new CodePush("deployment-key-here", this, BuildConfig.DEBUG) - ); - } - - ... -} -``` - -#### Background React Instances - -*This section is only necessary if you're explicitly launching a React Native instance without an `Activity` (for example, from within a native push notification receiver). For these situations, CodePush must be told how to find your React Native instance.* - -In order to update/restart your React Native instance, CodePush must be configured with a `ReactInstanceHolder` before attempting to restart an instance in the background. This is done in your `Application` implementation. - -##### For React Native >= v0.29 (Background React Instances) - -Update the `MainApplication.java` file to use CodePush via the following changes: - -```java -... -// 1. Declare your ReactNativeHost to extend ReactInstanceHolder. ReactInstanceHolder is a subset of ReactNativeHost, so no additional implementation is needed. -import com.microsoft.codepush.react.ReactInstanceHolder; - -public class MyReactNativeHost extends ReactNativeHost implements ReactInstanceHolder { - // ... usual overrides -} - -// 2. Provide your ReactNativeHost to CodePush. - -public class MainApplication extends Application implements ReactApplication { - - private final MyReactNativeHost mReactNativeHost = new MyReactNativeHost(this); - - @Override - public void onCreate() { - CodePush.setReactInstanceHolder(mReactNativeHost); - super.onCreate(); - } -} -``` - -##### For React Native v0.19 - v0.28 (Background React Instances) - -Before v0.29, React Native did not provide a `ReactNativeHost` abstraction. If you're launching a background instance, you'll likely have built your own, which should now implement `ReactInstanceHolder`. Once that's done: - -```java -// 1. Provide your ReactInstanceHolder to CodePush. - -public class MainApplication extends Application { - - @Override - public void onCreate() { - // ... initialize your instance holder - CodePush.setReactInstanceHolder(myInstanceHolder); - super.onCreate(); - } -} -``` In order to effectively make use of the `Staging` and `Production` deployments that were created along with your CodePush app, refer to the [multi-deployment testing](../README.md#multi-deployment-testing) docs below before actually moving your app's usage of CodePush into production. -#### WIX React Native Navigation applications - -If you are using [WIX React Native Navigation **version 1.x**](https://github.com/wix/react-native-navigation) based application, please do the following steps to integrate CodePush: - -1. No need to change `MainActivity.java` file, so if you are integrating CodePush to newly created RNN application it might be looking like this: -```java -import com.facebook.react.ReactActivity; -import com.reactnativenavigation.controllers.SplashActivity; - -public class MainActivity extends SplashActivity { - -} -``` - -2. Update the `MainApplication.java` file to use CodePush via the following changes: - -```java -// ... -import com.facebook.react.ReactInstanceManager; - -// Add CodePush imports -import com.microsoft.codepush.react.ReactInstanceHolder; -import com.microsoft.codepush.react.CodePush; - -public class MainApplication extends NavigationApplication implements ReactInstanceHolder { - - @Override - public boolean isDebug() { - // Make sure you are using BuildConfig from your own application - return BuildConfig.DEBUG; - } - - protected List getPackages() { - // Add additional packages you require here - return Arrays.asList( - new CodePush("deployment-key-here", getApplicationContext(), BuildConfig.DEBUG) - ); - } - - @Override - public List createAdditionalReactPackages() { - return getPackages(); - } - - @Override - public String getJSBundleFile() { - // Override default getJSBundleFile method with the one CodePush is providing - return CodePush.getJSBundleFile(); - } - - @Override - public String getJSMainModuleName() { - return "index"; - } - - @Override - public ReactInstanceManager getReactInstanceManager() { - // CodePush must be told how to find React Native instance - return getReactNativeHost().getReactInstanceManager(); - } -} -``` -If you are using [WIX React Native Navigation **version 2.x**](https://github.com/wix/react-native-navigation/tree/v2) based application, please do the following steps to integrate CodePush: - -1. As per React Native Navigation's documentation, `MainActivity.java` should extend `NavigationActivity`, no changes required to incorporate CodePush: - -```java -import com.reactnativenavigation.NavigationActivity; - -public class MainActivity extends NavigationActivity { - -} -``` - -2. Update the `MainApplication.java` file to use CodePush via the following changes: - -```java -// ... -import com.facebook.react.ReactInstanceManager; - -// Add CodePush imports -import com.microsoft.codepush.react.CodePush; - -public class MainApplication extends NavigationApplication { - - @Override - public boolean isDebug() { - return BuildConfig.DEBUG; - } - - @Override - protected ReactGateway createReactGateway() { - ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) { - @javax.annotation.Nullable - @Override - protected String getJSBundleFile() { - return CodePush.getJSBundleFile(); - } - - }; - return new ReactGateway(this, isDebug(), host); - } - - @Override - public List createAdditionalReactPackages() { - return Arrays.asList( - new CodePush("deployment-key-here", getApplicationContext(), isDebug()) - //,MainReactPackage , etc... - } -} -``` ### Code Signing setup @@ -468,23 +97,7 @@ zwIDAQAB ``` -#### For React Native <= v0.60 you should configure the `CodePush` instance to use this parameter using one of the following approaches - -##### Using constructor - -```java -new CodePush( - "deployment-key", - getApplicationContext(), - BuildConfig.DEBUG, - R.string.CodePushPublicKey) -``` - -##### Using builder - - ```java -new CodePushBuilder("deployment-key-here",getApplicationContext()) - .setIsDebugMode(BuildConfig.DEBUG) - .setPublicKeyResourceDescriptor(R.string.CodePushPublicKey) - .build() -``` +### Expo Integration +1. A pure expo react-native is not supported yet. We are planning to look into this after a while. See https://github.com/CodePushNext/react-native-code-push/issues/5 +2. A bare react-native app with expo sdk is supported, but you have to initialize rn app without `ReactNativeHostWrapper` of expo. It seems `ReactNativeHostWrapper` overrides `getJsBundleFile` internally, which prevents `CodePush` from being configured correctly. + https://github.com/expo/expo/issues/25865 diff --git a/docs/setup-ios.md b/docs/setup-ios.md index 7a02369bc..226659457 100644 --- a/docs/setup-ios.md +++ b/docs/setup-ios.md @@ -2,7 +2,7 @@ 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: ​ -### Plugin Installation and Configuration for React Native 0.60 version and above (iOS) +### Plugin Installation and Configuration for React Native 0.76 version and above (iOS) 1. Run `cd ios && pod install && cd ..` to install all the necessary CocoaPods dependencies. ​ @@ -52,177 +52,6 @@ Once you've acquired the CodePush plugin, you need to integrate it into the Xcod *Note: If you need to dynamically use a different deployment, you can also override your deployment key in JS code using [Code-Push options](./api-js.md#CodePushOptions)* -### Plugin Installation for React Native lower than 0.60 (iOS) - -In order to accommodate as many developer preferences as possible, the CodePush plugin supports iOS installation via three mechanisms: - -1. [**RNPM**](#plugin-installation-ios---rnpm) - [React Native Package Manager (RNPM)](https://github.com/rnpm/rnpm) is an awesome tool that provides the simplest installation experience possible for React Native plugins. If you're already using it, or you want to use it, then we recommend this approach. - -2. [**CocoaPods**](#plugin-installation-ios---cocoapods) - If you're building a native iOS app that is embedding React Native into it, or you simply prefer using [CocoaPods](https://cocoapods.org), then we recommend using the Podspec file that we ship as part of our plugin. - -3. [**"Manual"**](#plugin-installation-ios---manual) - If you don't want to depend on any additional tools or are fine with a few extra installation steps (it's a one-time thing), then go with this approach. - -#### Plugin Installation (iOS - RNPM) - -1. As of v0.27 of React Native, `rnpm link` has already been merged into the React Native CLI. Simply run: - ``` - react-native link react-native-code-push - ``` - - If your app uses a version of React Native that is lower than v0.27, run the following: - ``` - rnpm link react-native-code-push - ``` - - *Note: If you don't already have RNPM installed, you can do so by simply running `npm i -g rnpm` and then executing the above command. If you already have RNPM installed, make sure you have v1.9.0+ in order to benefit from this one step install.* - -2. You will be prompted for the deployment key you'd like to use. If you don't already have it, you can retrieve this value by running `appcenter codepush deployment list -a / -k`, or you can choose to ignore it (by simply hitting ``) and add it in later. To get started, we would recommend just using your `Staging` deployment key, so that you can test out the CodePush end-to-end. - -And that's it! Isn't RNPM awesome? :) - -#### Plugin Installation (iOS - CocoaPods) - -1. Add the ReactNative and CodePush plugin dependencies to your `Podfile`, pointing at the path where NPM installed it - - ``` - # React Native requirements - pod 'React', :path => '../node_modules/react-native', :subspecs => [ - 'Core', - 'CxxBridge', # Include this for RN >= 0.47 - 'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43 - 'RCTText', - 'RCTNetwork', - 'RCTWebSocket', # Needed for debugging - 'RCTAnimation', # Needed for FlatList and animations running on native UI thread - # Add any other subspecs you want to use in your project - ] - # Explicitly include Yoga if you are using RN >= 0.42.0 - pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga' - pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' - pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' - pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec' - - # CodePush plugin dependency - pod 'CodePush', :path => '../node_modules/react-native-code-push' - ``` - - *NOTE: The above path needs to be relative to your app's `Podfile`, so adjust it as necessary.* - - *NOTE: `JWT` library should be >= version 3.0.x* - -2. Run `pod install` - -*NOTE: The CodePush `.podspec` depends on the `React` pod, and so in order to ensure that it can correctly use the version of React Native that your app is built with, please make sure to define the `React` dependency in your app's `Podfile` as explained [here](https://facebook.github.io/react-native/docs/integration-with-existing-apps.html#podfile).* - -#### Plugin Installation (iOS - Manual) - -1. Open your app's Xcode project - -2. Find the `CodePush.xcodeproj` file within the `node_modules/react-native-code-push/ios` directory (or `node_modules/react-native-code-push` for <=`1.7.3-beta` installations) and drag it into the `Libraries` node in Xcode - - ![Add CodePush to project](https://cloud.githubusercontent.com/assets/8598682/13368613/c5c21422-dca0-11e5-8594-c0ec5bde9d81.png) - -3. Select the project node in Xcode and select the "Build Phases" tab of your project configuration. - -4. Drag `libCodePush.a` from `Libraries/CodePush.xcodeproj/Products` into the "Link Binary With Libraries" section of your project's "Build Phases" configuration. - - ![Link CodePush during build](https://cloud.githubusercontent.com/assets/516559/10322221/a75ea066-6c31-11e5-9d88-ff6f6a4d6968.png) - -5. Click the plus sign underneath the "Link Binary With Libraries" list and select the `libz.tbd` library underneath the `iOS 9.1` node. - - ![Libz reference](https://cloud.githubusercontent.com/assets/116461/11605042/6f786e64-9aaa-11e5-8ca7-14b852f808b1.png) - - *Note: Alternatively, if you prefer, you can add the `-lz` flag to the `Other Linker Flags` field in the `Linking` section of the `Build Settings`.* - - -### Plugin Configuration for React Native lower than 0.60 (iOS) - -*NOTE: If you used RNPM or `react-native link` to automatically link the plugin, these steps have already been done for you so you may skip this section.* - -Once your Xcode project has been setup to build/link the CodePush plugin, you need to configure your app to consult CodePush for the location of your JS bundle, since it is responsible for synchronizing it with updates that are released to the CodePush server. To do this, perform the following steps: - -1. Open up the `AppDelegate.m` file, and add an import statement for the CodePush headers: - - ```objective-c - #import - ``` - -For React Native 0.59 - 0.59.10: - -2. Find the following line of code, which sets the source URL for bridge for production releases: - - ```objective-c - return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; - ``` - -3. Replace it with this line: - - ```objective-c - return [CodePush bundleURL]; - ``` - -For React Native 0.58 and below: - -2. Find the following line of code, which loads your JS Bundle from the app binary for production releases: - - ```objective-c - jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; - ``` - -3. Replace it with this line: - - ```objective-c - jsCodeLocation = [CodePush bundleURL]; - ``` - -This change configures your app to always load the most recent version of your app's JS bundle. On the first launch, this will correspond to the file that was compiled with the app. However, after an update has been pushed via CodePush, this will return the location of the most recently installed update. - -*NOTE: The `bundleURL` method assumes your app's JS bundle is named `main.jsbundle`. If you have configured your app to use a different file name, simply call the `bundleURLForResource:` method (which assumes you're using the `.jsbundle` extension) or `bundleURLForResource:withExtension:` method instead, in order to overwrite that default behavior* - -Typically, you're only going to want to use CodePush to resolve your JS bundle location within release builds, and therefore, we recommend using the `DEBUG` pre-processor macro to dynamically switch between using the packager server and CodePush, depending on whether you are debugging or not. This will make it much simpler to ensure you get the right behavior you want in production, while still being able to use the Chrome Dev Tools, live reload, etc. at debug-time. - -For React Native 0.59 - 0.59.10: - -```objective-c -- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge -{ - #if DEBUG - return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; - #else - return [CodePush bundleURL]; - #endif -} -``` - -For React Native 0.49 - 0.58: - -```objective-c -NSURL *jsCodeLocation; - -#ifdef DEBUG - jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; -#else - jsCodeLocation = [CodePush bundleURL]; -#endif -``` - -For React Native 0.48 and below: - -```objective-c -NSURL *jsCodeLocation; - -#ifdef DEBUG - jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"]; -#else - jsCodeLocation = [CodePush bundleURL]; -#endif -``` - -To let the CodePush runtime know which deployment it should query for updates against, open your app's `Info.plist` file and add a new entry named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `appcenter codepush deployment list -a / -k` in the AppCenter CLI (the `-k` flag is necessary since keys aren't displayed by default) and copying the value of the `Key` column which corresponds to the deployment you want to use (see below). Note that using the deployment's name (like Staging) will not work. That "friendly name" is intended only for authenticated management usage from the CLI, and not for public consumption within your app. - -![Deployment list](https://cloud.githubusercontent.com/assets/116461/11601733/13011d5e-9a8a-11e5-9ce2-b100498ffb34.png) - -In order to effectively make use of the `Staging` and `Production` deployments that were created along with your CodePush app, refer to the [multi-deployment testing](../README.md#multi-deployment-testing) docs below before actually moving your app's usage of CodePush into production. ### HTTP exception domains configuration (iOS) diff --git a/package-lock.json b/package-lock.json index 0335d03b7..08a4276af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "react-native-code-push", - "version": "10.0.3", + "version": "10.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "react-native-code-push", - "version": "10.0.3", + "version": "10.0.0", "license": "MIT", "dependencies": { - "code-push": "^4.2.2", + "code-push": "4.2.3", "glob": "^7.1.7", "hoist-non-react-statics": "^3.3.2", "inquirer": "^8.1.5", @@ -1233,9 +1233,9 @@ } }, "node_modules/code-push": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/code-push/-/code-push-4.2.2.tgz", - "integrity": "sha512-45pvyF6bhJ5h8tllcE9CkmZaCxT+QvA8hxUpUdUevLAOCWv+Tlw/B8XXC1Q7ai3qyZwkiVbEuq3E8lyGmjMsrQ==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/code-push/-/code-push-4.2.3.tgz", + "integrity": "sha512-FPwcU9/5lgMJH7MfBgkr4nCta513DGx2v4mg2yW860+8sCQTbhHHnduoAjSlZgyZJj3FIxzW2ccD41pVtTJDow==", "dependencies": { "appcenter-file-upload-client": "0.1.0", "proxy-agent": "^6.3.0", diff --git a/package.json b/package.json index 288e151f5..9fb400943 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "code", "push" ], - "author": "Microsoft Corporation", + "author": "chlee1001", "license": "MIT", "scripts": { "clean": "shx rm -rf bin", @@ -20,6 +20,9 @@ "test": "npm run build:tests && npm run test:setup && npm run test:fast", "test:android": "npm run build:tests && npm run test:setup:android && npm run test:fast:android", "test:ios": "npm run build:tests && npm run test:setup:ios && npm run test:fast:ios", + "test:oldArch": "export TEST_OLD_ARCH=true && npm run build:tests && npm run test:setup && npm run test:fast", + "test:oldArch:android": "export TEST_OLD_ARCH=true && npm run build:tests && npm run test:setup:android && npm run test:fast:android", + "test:oldArch:ios": "export TEST_OLD_ARCH=true && npm run build:tests && npm run test:setup:ios && npm run test:fast:ios", "test:setup": "mocha --recursive bin/test --android --ios --setup", "test:setup:android": "mocha --recursive bin/test --android --setup", "test:setup:ios": "mocha --recursive bin/test --ios --setup", @@ -35,7 +38,7 @@ "url": "https://github.com/chlee1001/react-native-code-push" }, "dependencies": { - "code-push": "^4.2.2", + "code-push": "4.2.3", "glob": "^7.1.7", "hoist-non-react-statics": "^3.3.2", "inquirer": "^8.1.5", @@ -73,8 +76,8 @@ ] }, "commands": { - "postlink": "node node_modules/react-native-code-push/scripts/postlink/run", - "postunlink": "node node_modules/react-native-code-push/scripts/postunlink/run" + "postlink": "node node_modules/@chlee1001/react-native-code-push/scripts/postlink/run", + "postunlink": "node node_modules/@chlee1001/react-native-code-push/scripts/postunlink/run" } } } diff --git a/react-native.config.js b/react-native.config.js index 29f627a4d..589c72ea9 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -3,7 +3,8 @@ module.exports = { platforms: { android: { packageInstance: - "new CodePush(getResources().getString(R.string.CodePushDeploymentKey), getApplicationContext(), BuildConfig.DEBUG)" + "new CodePush(getResources().getString(R.string.CodePushDeploymentKey), getApplicationContext(), BuildConfig.DEBUG)", + sourceDir: './android', } } } diff --git a/scripts/tools/linkToolsAndroid.js b/scripts/tools/linkToolsAndroid.js index 0ffe08fff..59671ca90 100644 --- a/scripts/tools/linkToolsAndroid.js +++ b/scripts/tools/linkToolsAndroid.js @@ -13,7 +13,7 @@ exports.getJSBundleFileOverride = ` `; exports.reactNativeHostInstantiation = "new ReactNativeHost(this) {"; exports.mainActivityClassDeclaration = "public class MainActivity extends ReactActivity {"; -exports.codePushGradleLink = `\napply from: "../../node_modules/react-native-code-push/android/codepush.gradle"`; +exports.codePushGradleLink = `\napply from: "../../node_modules/@chlee1001/react-native-code-push/android/codepush.gradle"`; exports.deploymentKeyName = "CodePushDeploymentKey"; exports.getMainApplicationLocation = function () { @@ -29,7 +29,7 @@ exports.getStringsResourcesPath = function () { } exports.getBuildGradlePath = function () { - return path.join("android", "app", "build.gradle"); + return path.join("android", "build.gradle"); } exports.isJsBundleOverridden = function (codeContents) { diff --git a/test/template/android/app/src/main/java/com/testcodepush/MainApplication.kt b/test/template/android/app/src/main/java/com/testcodepush/MainApplication.kt index 46487aeeb..58d8d9277 100644 --- a/test/template/android/app/src/main/java/com/testcodepush/MainApplication.kt +++ b/test/template/android/app/src/main/java/com/testcodepush/MainApplication.kt @@ -17,15 +17,19 @@ import com.microsoft.codepush.react.CodePush @OptIn(UnstableReactNativeAPI::class) class MainApplication : Application(), ReactApplication { + val defaultPackageList by lazy { + PackageList(this).packages.apply { + // Packages that cannot be autolinked yet can be added manually here, for example: + // add(MyReactNativePackage()) + } + } + override val reactNativeHost: ReactNativeHost = object : DefaultReactNativeHost(this) { - override fun getPackages(): List = - PackageList(this).packages.apply { - // Packages that cannot be autolinked yet can be added manually here, for example: - // add(MyReactNativePackage()) - } + override fun getPackages(): List = defaultPackageList override fun getJSMainModuleName(): String = "index" + override fun getJSBundleFile(): String = CodePush.getJSBundleFile() override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG @@ -33,19 +37,7 @@ class MainApplication : Application(), ReactApplication { override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED } - override val reactHost: ReactHost - get() = getDefaultReactHost( - applicationContext, - PackageList(this).packages.apply { - // Packages that cannot be autolinked yet can be added manually here, for example: - // add(MyReactNativePackage()) - }, - jsMainModulePath = "index", - jsBundleAssetPath = "index.android.bundle", - jsBundleFilePath = CodePush.getJSBundleFile(), - isHermesEnabled = BuildConfig.IS_HERMES_ENABLED, - useDevSupport = BuildConfig.DEBUG, - ) + override val reactHost: ReactHost get() = getDefaultReactHost(this, reactNativeHost) override fun onCreate() { super.onCreate() diff --git a/test/template/codePushWrapper.js b/test/template/codePushWrapper.js index 7c84177dd..ed38e8d55 100644 --- a/test/template/codePushWrapper.js +++ b/test/template/codePushWrapper.js @@ -1,4 +1,4 @@ -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; // This module wraps CodePush API calls to add test message callbacks to every function for simpler test code. @@ -70,4 +70,4 @@ module.exports = { } ); } -} \ No newline at end of file +} diff --git a/test/template/index.js b/test/template/index.js index 5306d2753..dcc6278d7 100644 --- a/test/template/index.js +++ b/test/template/index.js @@ -13,7 +13,7 @@ import { View } from 'react-native'; -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; var testScenario = require("./CODE_PUSH_INDEX_JS_PATH"); @@ -165,4 +165,4 @@ const styles = StyleSheet.create({ }, }); -AppRegistry.registerComponent('CODE_PUSH_TEST_APP_NAME', () => CODE_PUSH_TEST_APP_NAME); \ No newline at end of file +AppRegistry.registerComponent('CODE_PUSH_TEST_APP_NAME', () => CODE_PUSH_TEST_APP_NAME); diff --git a/test/template/ios/Podfile b/test/template/ios/Podfile new file mode 100644 index 000000000..ff9655497 --- /dev/null +++ b/test/template/ios/Podfile @@ -0,0 +1,40 @@ +# Resolve react_native_pods.rb with node to allow for hoisting +require Pod::Executable.execute_command('node', ['-p', + 'require.resolve( + "react-native/scripts/react_native_pods.rb", + {paths: [process.argv[1]]}, + )', __dir__]).strip + +platform :ios, '15.5' +prepare_react_native_project! + +linkage = ENV['USE_FRAMEWORKS'] +if linkage != nil + Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green + use_frameworks! :linkage => linkage.to_sym +end + +target 'TestCodePush' do + config = use_native_modules! + + use_react_native!( + :path => config[:reactNativePath], + # An absolute path to your application root. + :app_path => "#{Pod::Config.instance.installation_root}/.." + ) + + target 'TestCodePushTests' do + inherit! :complete + # Pods for testing + end + + post_install do |installer| + # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202 + react_native_post_install( + installer, + config[:reactNativePath], + :mac_catalyst_enabled => false, + # :ccache_enabled => true + ) + end +end \ No newline at end of file diff --git a/test/template/ios/TestCodePush/AppDelegate.mm b/test/template/ios/TestCodePush/AppDelegate.mm index dce0b50fe..a4244c12c 100644 --- a/test/template/ios/TestCodePush/AppDelegate.mm +++ b/test/template/ios/TestCodePush/AppDelegate.mm @@ -1,20 +1,12 @@ #import "AppDelegate.h" - #import #import -#import -#import @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; - RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge - moduleName:@"CODE_PUSH_TEST_APP_NAME" - initialProperties:nil]; - self.moduleName = @"TestCodePush"; // You can add your custom initial props in the dictionary below. // They will be passed down to the ViewController used by React Native. @@ -25,17 +17,16 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { - return [CodePush bundleURL]; + return [self bundleURL]; } -/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off. -/// -/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html -/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture). -/// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`. -- (BOOL)concurrentRootEnabled +- (NSURL *)bundleURL { - return true; +#if DEBUG + return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; +#else + return [CodePush bundleURL]; +#endif } @end diff --git a/test/template/scenarios/scenarioDisallowRestartImmediate.js b/test/template/scenarios/scenarioDisallowRestartImmediate.js index 1df3e2984..dcfa40bf2 100644 --- a/test/template/scenarios/scenarioDisallowRestartImmediate.js +++ b/test/template/scenarios/scenarioDisallowRestartImmediate.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { diff --git a/test/template/scenarios/scenarioDisallowRestartOnResume.js b/test/template/scenarios/scenarioDisallowRestartOnResume.js index 6e8dea378..bd7d67ad1 100644 --- a/test/template/scenarios/scenarioDisallowRestartOnResume.js +++ b/test/template/scenarios/scenarioDisallowRestartOnResume.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { diff --git a/test/template/scenarios/scenarioDisallowRestartOnSuspend.js b/test/template/scenarios/scenarioDisallowRestartOnSuspend.js index 99a6de6df..0183bc87a 100644 --- a/test/template/scenarios/scenarioDisallowRestartOnSuspend.js +++ b/test/template/scenarios/scenarioDisallowRestartOnSuspend.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { diff --git a/test/template/scenarios/scenarioInstall.js b/test/template/scenarios/scenarioInstall.js index b405a36e6..8141c930b 100644 --- a/test/template/scenarios/scenarioInstall.js +++ b/test/template/scenarios/scenarioInstall.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -9,4 +9,4 @@ module.exports = { getScenarioName: function () { return "Install"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioInstallOnRestartWithRevert.js b/test/template/scenarios/scenarioInstallOnRestartWithRevert.js index 7a9bb145d..5aa24098b 100644 --- a/test/template/scenarios/scenarioInstallOnRestartWithRevert.js +++ b/test/template/scenarios/scenarioInstallOnRestartWithRevert.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -9,4 +9,4 @@ module.exports = { getScenarioName: function () { return "Install on Restart with Revert"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioInstallOnResumeWithRevert.js b/test/template/scenarios/scenarioInstallOnResumeWithRevert.js index 781795ba9..a452a853f 100644 --- a/test/template/scenarios/scenarioInstallOnResumeWithRevert.js +++ b/test/template/scenarios/scenarioInstallOnResumeWithRevert.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -9,4 +9,4 @@ module.exports = { getScenarioName: function () { return "Install on Resume with Revert"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioInstallOnSuspendWithRevert.js b/test/template/scenarios/scenarioInstallOnSuspendWithRevert.js index 71dca22a3..3ab54f4f9 100644 --- a/test/template/scenarios/scenarioInstallOnSuspendWithRevert.js +++ b/test/template/scenarios/scenarioInstallOnSuspendWithRevert.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { diff --git a/test/template/scenarios/scenarioInstallRestart2x.js b/test/template/scenarios/scenarioInstallRestart2x.js index edfa50f19..77c68d950 100644 --- a/test/template/scenarios/scenarioInstallRestart2x.js +++ b/test/template/scenarios/scenarioInstallRestart2x.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -14,4 +14,4 @@ module.exports = { getScenarioName: function () { return "Install and Restart 2x"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioInstallWithRevert.js b/test/template/scenarios/scenarioInstallWithRevert.js index e5c8ad639..4338c373c 100644 --- a/test/template/scenarios/scenarioInstallWithRevert.js +++ b/test/template/scenarios/scenarioInstallWithRevert.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -9,4 +9,4 @@ module.exports = { getScenarioName: function () { return "Install with Revert"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioRestart.js b/test/template/scenarios/scenarioRestart.js index db8e55535..b65adc420 100644 --- a/test/template/scenarios/scenarioRestart.js +++ b/test/template/scenarios/scenarioRestart.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -16,4 +16,4 @@ module.exports = { getScenarioName: function () { return "Restart"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioRestart2x.js b/test/template/scenarios/scenarioRestart2x.js index 56e716be7..7bb23501f 100644 --- a/test/template/scenarios/scenarioRestart2x.js +++ b/test/template/scenarios/scenarioRestart2x.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -14,4 +14,4 @@ module.exports = { getScenarioName: function () { return "Restart2x"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioSync.js b/test/template/scenarios/scenarioSync.js index 4e0d94bed..6c5706247 100644 --- a/test/template/scenarios/scenarioSync.js +++ b/test/template/scenarios/scenarioSync.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -9,4 +9,4 @@ module.exports = { getScenarioName: function () { return "Sync"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioSync2x.js b/test/template/scenarios/scenarioSync2x.js index 7135bb469..0245e604f 100644 --- a/test/template/scenarios/scenarioSync2x.js +++ b/test/template/scenarios/scenarioSync2x.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -10,4 +10,4 @@ module.exports = { getScenarioName: function () { return "Sync 2x"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioSyncMandatoryDefault.js b/test/template/scenarios/scenarioSyncMandatoryDefault.js index e881f7991..b166c4459 100644 --- a/test/template/scenarios/scenarioSyncMandatoryDefault.js +++ b/test/template/scenarios/scenarioSyncMandatoryDefault.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -9,4 +9,4 @@ module.exports = { getScenarioName: function () { return "Sync Mandatory Default"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioSyncMandatoryRestart.js b/test/template/scenarios/scenarioSyncMandatoryRestart.js index 999bffd15..f887d087a 100644 --- a/test/template/scenarios/scenarioSyncMandatoryRestart.js +++ b/test/template/scenarios/scenarioSyncMandatoryRestart.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -13,4 +13,4 @@ module.exports = { getScenarioName: function () { return "Sync Mandatory Restart"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioSyncMandatoryResume.js b/test/template/scenarios/scenarioSyncMandatoryResume.js index 3232c474d..6a1102aec 100644 --- a/test/template/scenarios/scenarioSyncMandatoryResume.js +++ b/test/template/scenarios/scenarioSyncMandatoryResume.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -13,4 +13,4 @@ module.exports = { getScenarioName: function () { return "Sync Mandatory Resume"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioSyncMandatorySuspend.js b/test/template/scenarios/scenarioSyncMandatorySuspend.js index bed4925b9..053284092 100644 --- a/test/template/scenarios/scenarioSyncMandatorySuspend.js +++ b/test/template/scenarios/scenarioSyncMandatorySuspend.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { diff --git a/test/template/scenarios/scenarioSyncRestartDelay.js b/test/template/scenarios/scenarioSyncRestartDelay.js index 992145065..df327fb61 100644 --- a/test/template/scenarios/scenarioSyncRestartDelay.js +++ b/test/template/scenarios/scenarioSyncRestartDelay.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -13,4 +13,4 @@ module.exports = { getScenarioName: function () { return "Sync Restart Delay"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioSyncResume.js b/test/template/scenarios/scenarioSyncResume.js index 73303b0f2..4880483cc 100644 --- a/test/template/scenarios/scenarioSyncResume.js +++ b/test/template/scenarios/scenarioSyncResume.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -10,4 +10,4 @@ module.exports = { getScenarioName: function () { return "Sync Resume"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioSyncResumeDelay.js b/test/template/scenarios/scenarioSyncResumeDelay.js index 9fc368ab9..91454d4ee 100644 --- a/test/template/scenarios/scenarioSyncResumeDelay.js +++ b/test/template/scenarios/scenarioSyncResumeDelay.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -13,4 +13,4 @@ module.exports = { getScenarioName: function () { return "Sync Resume Delay"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/scenarioSyncSuspend.js b/test/template/scenarios/scenarioSyncSuspend.js index 3c89a6bc5..ab84225bb 100644 --- a/test/template/scenarios/scenarioSyncSuspend.js +++ b/test/template/scenarios/scenarioSyncSuspend.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { diff --git a/test/template/scenarios/scenarioSyncSuspendDelay.js b/test/template/scenarios/scenarioSyncSuspendDelay.js index fadbfdda9..ee4c2d69b 100644 --- a/test/template/scenarios/scenarioSyncSuspendDelay.js +++ b/test/template/scenarios/scenarioSyncSuspendDelay.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { diff --git a/test/template/scenarios/updateNARConditional.js b/test/template/scenarios/updateNARConditional.js index 591efd0d3..1438ac049 100644 --- a/test/template/scenarios/updateNARConditional.js +++ b/test/template/scenarios/updateNARConditional.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -16,4 +16,4 @@ module.exports = { getScenarioName: function () { return "Conditional Update"; } -}; \ No newline at end of file +}; diff --git a/test/template/scenarios/updateNotifyApplicationReady.js b/test/template/scenarios/updateNotifyApplicationReady.js index 9e2ed7a7a..18daee183 100644 --- a/test/template/scenarios/updateNotifyApplicationReady.js +++ b/test/template/scenarios/updateNotifyApplicationReady.js @@ -1,5 +1,5 @@ var CodePushWrapper = require("../codePushWrapper.js"); -import CodePush from "react-native-code-push"; +import CodePush from "@chlee1001/react-native-code-push"; module.exports = { startTest: function (testApp) { @@ -10,4 +10,4 @@ module.exports = { getScenarioName: function () { return "Good Update"; } -}; \ No newline at end of file +}; diff --git a/test/test.ts b/test/test.ts index df1edc629..525a33553 100644 --- a/test/test.ts +++ b/test/test.ts @@ -70,7 +70,7 @@ class RNAndroid extends Platform.Android implements RNPlatform { * Returns the path to the binary of the given project on this platform. */ getBinaryPath(projectDirectory: string): string { - return path.join(projectDirectory, TestConfig.TestAppName, "android", "app", "build", "outputs", "apk", "release", "app-release.apk"); + return path.join(projectDirectory, TestConfig.TestAppName, "android", "build", "outputs", "apk", "release", "app-release.apk"); } /** @@ -78,31 +78,31 @@ class RNAndroid extends Platform.Android implements RNPlatform { */ installPlatform(projectDirectory: string): Q.Promise { const innerprojectDirectory: string = path.join(projectDirectory, TestConfig.TestAppName); - const gradleContent: string = slash(path.join(innerprojectDirectory, "node_modules", "react-native-code-push", "android", "codepush.gradle")); + const gradleContent: string = slash(path.join(innerprojectDirectory, "node_modules", "@chlee1001/react-native-code-push", "android", "codepush.gradle")); //// Set up gradle to build CodePush with the app - // Add CodePush to android/app/build.gradle - const buildGradle = path.join(innerprojectDirectory, "android", "app", "build.gradle"); + // Add CodePush to android/build.gradle + const buildGradle = path.join(innerprojectDirectory, "android", "build.gradle"); TestUtil.replaceString(buildGradle, - "apply from: file\\(\"../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle\"\\); applyNativeModulesAppBuildGradle\\(project\\)", - "apply from: file(\"../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle\"); applyNativeModulesAppBuildGradle(project)\napply from: \"" + gradleContent + "\""); + "apply plugin: \"com.facebook.react\"", + "apply plugin: \"com.facebook.react\"\napply from: \"" + gradleContent + "\""); - // Add CodePush to android/settings.gradle - const settingsGradle = path.join(innerprojectDirectory, "android", "settings.gradle"); - TestUtil.replaceString(settingsGradle, - "include ':app'", - "include ':app', ':react-native-code-push'\nproject(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')"); + // Disable new architecture + if (TestConfig.testOldArch) { + const gradleProperties = path.join(innerprojectDirectory, "android", "gradle.properties"); + TestUtil.replaceString(gradleProperties, "newArchEnabled=true", "newArchEnabled=false"); + } //// Set the app version to 1.0.0 instead of 1.0 // Set the app version to 1.0.0 in android/app/build.gradle TestUtil.replaceString(buildGradle, "versionName \"1.0\"", "versionName \"1.0.0\""); // Set the app version to 1.0.0 in AndroidManifest.xml - TestUtil.replaceString(path.join(innerprojectDirectory, "android", "app", "src", "main", "AndroidManifest.xml"), "android:versionName=\"1.0\"", "android:versionName=\"1.0.0\""); + TestUtil.replaceString(path.join(innerprojectDirectory, "android", "src", "main", "AndroidManifest.xml"), "android:versionName=\"1.0\"", "android:versionName=\"1.0.0\""); //// Replace the MainApplication.java with the correct server url and deployment key - const string = path.join(innerprojectDirectory, "android", "app", "src", "main", "res", "values", "strings.xml"); - const AndroidManifest = path.join(innerprojectDirectory, "android", "app", "src", "main", "AndroidManifest.xml"); + const string = path.join(innerprojectDirectory, "android", "src", "main", "res", "values", "strings.xml"); + const AndroidManifest = path.join(innerprojectDirectory, "android", "src", "main", "AndroidManifest.xml"); TestUtil.replaceString(string, TestUtil.SERVER_URL_PLACEHOLDER, this.getServerUrl()); TestUtil.replaceString(string, TestUtil.ANDROID_KEY_PLACEHOLDER, this.getDefaultDeploymentKey()); TestUtil.replaceString(AndroidManifest, "android:allowBackup=\"false\"", "android:allowBackup=\"false\"" + "\n\t" + "android:usesCleartextTraffic=\"true\""); @@ -119,8 +119,8 @@ class RNAndroid extends Platform.Android implements RNPlatform { return TestUtil.getProcessOutput("adb install -r " + this.getBinaryPath(projectDirectory), { cwd: androidDirectory }).then(() => { return null; }); } - /** - * Build function of the test application, the command depends on the OS + /** + * Build function of the test application, the command depends on the OS */ buildFunction(androidDirectory: string): Q.Promise { const gradlewCommand = process.platform === "darwin" || process.platform === "linux" ? "./gradlew" : "gradlew"; @@ -177,10 +177,12 @@ class RNIOS extends Platform.IOS implements RNPlatform { const iOSProject: string = path.join(projectDirectory, TestConfig.TestAppName, "ios"); const infoPlistPath: string = path.join(iOSProject, TestConfig.TestAppName, "Info.plist"); const appDelegatePath: string = path.join(iOSProject, TestConfig.TestAppName, "AppDelegate.mm"); + const podfilePath: string = path.join(iOSProject, "Podfile"); // Install the Podfile - return TestUtil.getProcessOutput("pod install", { cwd: iOSProject }) + return TestUtil.copyFile(path.join(TestConfig.templatePath, "ios", "Podfile"), podfilePath, true) + .then(() => TestUtil.getProcessOutput(`RCT_NEW_ARCH_ENABLED=${TestConfig.testOldArch ? 0 : 1} pod install`, { cwd: iOSProject })) // Put the IOS deployment key in the Info.plist .then(TestUtil.replaceString.bind(undefined, infoPlistPath, "\n", @@ -199,7 +201,7 @@ class RNIOS extends Platform.IOS implements RNPlatform { .then(TestUtil.copyFile.bind(undefined, path.join(TestConfig.templatePath, "ios", TestConfig.TestAppName, "AppDelegate.mm"), appDelegatePath, true)) - .then(TestUtil.replaceString.bind(undefined, appDelegatePath, TestUtil.CODE_PUSH_TEST_APP_NAME_PLACEHOLDER, TestConfig.TestAppName)); + .then(TestUtil.replaceString.bind(undefined, appDelegatePath, TestUtil.CODE_PUSH_TEST_APP_NAME_PLACEHOLDER, TestConfig.TestAppName)); } /** @@ -211,7 +213,7 @@ class RNIOS extends Platform.IOS implements RNPlatform { /** * Maps project directories to whether or not they have built an IOS project before. - * + * * The first build of an IOS project does not always succeed, so we always try again when it fails. * * EXAMPLE: @@ -307,13 +309,13 @@ class RNProjectManager extends ProjectManager { } mkdirp.sync(projectDirectory); - return TestUtil.getProcessOutput("npx react-native init " + appName + " --version 0.76.1 --install-pods", { cwd: projectDirectory, timeout: 30 * 60 * 1000 }) - .then((e) => { console.log(`"npx react-native init ${appName}" success. cwd=${projectDirectory}`); return e; }) + return TestUtil.getProcessOutput("npx @react-native-community/cli init " + appName + " --version 0.76.5 --install-pods", { cwd: projectDirectory, timeout: 30 * 60 * 1000 }) + .then((e) => { console.log(`"npx @react-native-community/cli init ${appName}" success. cwd=${projectDirectory}`); return e; }) .then(this.copyTemplate.bind(this, templatePath, projectDirectory)) .then(TestUtil.getProcessOutput.bind(undefined, TestConfig.thisPluginInstallString, { cwd: path.join(projectDirectory, TestConfig.TestAppName) })) .then(() => { return null; }) .catch((error) => { - console.log(`"npx react-native init ${appName} failed". cwd=${projectDirectory}`, error); + console.log(`"npx @react-native-community/cli init ${appName} failed". cwd=${projectDirectory}`, error); throw new Error(error); }); }