React-native-code-push: How to remove code push from React Native App

Created on 8 Dec 2017  路  2Comments  路  Source: microsoft/react-native-code-push

Expected Behavior

After removing code push from package.json. There is a lot of trace in ios and android package which are not going away.How can I remove code push completely?.

Actual Behavior

What actually happens?

some time npm install cause issue such as
"npm WARN enoent ENOENT: no such file or directory, open '/Users/albin.git/Desktop/itsman_app/node_modules/react-native-code-push/package.json'"

even after removing it from package.json
also running package separately on Xcode or android studio causes code-push error

question

Most helpful comment

Hi @Albinzr and thanks for submitting the issue. Please follow these steps:

  • Run npm uni --save react-native-code-push from the app directory
  • Remove code-push references from JS code
  • Remove code-push SDK from your app:


Android instructions

  • Update build.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')*/
  • Update android/app/build.gradle
...
dependencies {
    ...
    //compile project(':react-native-code-push')
}
...
//apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
  • Update MainApplication.java
//import com.microsoft.codepush.react.CodePush;

public class MainApplication extends Application implements ReactApplication {

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        ...

/*
        @Override
        protected String getJSBundleFile() {
            return CodePush.getJSBundleFile();
        }
*/
        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                new MainReactPackage(),
//                new CodePush("deployment-key-here", MainApplication.this, BuildConfig.DEBUG)
            );
        }
    };
}

or update MyReactActivity.java (select the way that is working for you)

...
//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()
                // ...
                //.addPackage(new CodePush("deployment-key-here", getApplicationContext(), BuildConfig.DEBUG))

                //.setJSBundleFile(CodePush.getJSBundleFile())
                // ...

                .build();
        mReactRootView.startReactApplication(mReactInstanceManager, "MyReactNativeApp", null);

        setContentView(mReactRootView);
    }

    ...
}
  • Remove any entries in res/values/string.xml related with CodePush (if it exists)


iOS instructions

If you installed Codepush via cocoapods

  • Remove CodePush from Podfile, then pod install again.
  • Remove entries beginning with CodePush from Info.plist

If you installed Codepush manually

  • Remove CodePush.xcodeproj from Libraries directory
  • Remove any of next dependencies if it unnecessary for your app: SSZipArchive, JWT, Base64
  • Select the project node in Xcode and select the "Build Phases" tab of your project configuration. Remove libCodePush.a and libz.tbd (or remove the -lz flag from the Other Linker Flags field in the Linking section of the Build Settings) from Link binary with libraries list.

Common steps

  • Update AppDelegate.m
// #import <CodePush/CodePush.h>
...

//#ifdef DEBUG
    jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.bundle?platform=ios&dev=true"];
//#else
//    jsCodeLocation = [CodePush bundleURL];
//#endif

  • Update Info.plist (remove <key>codepush.azurewebsites.net</key>)



<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
   <key>codepush.azurewebsites.net</key> 
  </dict>
</dict>

<!-- ...other configs... -->


  • Remove any codepush references on native side
  • Clean and rebuild project.

Please let us know if it helps or any updates.

All 2 comments

Hi @Albinzr and thanks for submitting the issue. Please follow these steps:

  • Run npm uni --save react-native-code-push from the app directory
  • Remove code-push references from JS code
  • Remove code-push SDK from your app:


Android instructions

  • Update build.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')*/
  • Update android/app/build.gradle
...
dependencies {
    ...
    //compile project(':react-native-code-push')
}
...
//apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
  • Update MainApplication.java
//import com.microsoft.codepush.react.CodePush;

public class MainApplication extends Application implements ReactApplication {

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        ...

/*
        @Override
        protected String getJSBundleFile() {
            return CodePush.getJSBundleFile();
        }
*/
        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                new MainReactPackage(),
//                new CodePush("deployment-key-here", MainApplication.this, BuildConfig.DEBUG)
            );
        }
    };
}

or update MyReactActivity.java (select the way that is working for you)

...
//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()
                // ...
                //.addPackage(new CodePush("deployment-key-here", getApplicationContext(), BuildConfig.DEBUG))

                //.setJSBundleFile(CodePush.getJSBundleFile())
                // ...

                .build();
        mReactRootView.startReactApplication(mReactInstanceManager, "MyReactNativeApp", null);

        setContentView(mReactRootView);
    }

    ...
}
  • Remove any entries in res/values/string.xml related with CodePush (if it exists)


iOS instructions

If you installed Codepush via cocoapods

  • Remove CodePush from Podfile, then pod install again.
  • Remove entries beginning with CodePush from Info.plist

If you installed Codepush manually

  • Remove CodePush.xcodeproj from Libraries directory
  • Remove any of next dependencies if it unnecessary for your app: SSZipArchive, JWT, Base64
  • Select the project node in Xcode and select the "Build Phases" tab of your project configuration. Remove libCodePush.a and libz.tbd (or remove the -lz flag from the Other Linker Flags field in the Linking section of the Build Settings) from Link binary with libraries list.

Common steps

  • Update AppDelegate.m
// #import <CodePush/CodePush.h>
...

//#ifdef DEBUG
    jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.bundle?platform=ios&dev=true"];
//#else
//    jsCodeLocation = [CodePush bundleURL];
//#endif

  • Update Info.plist (remove <key>codepush.azurewebsites.net</key>)



<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
   <key>codepush.azurewebsites.net</key> 
  </dict>
</dict>

<!-- ...other configs... -->


  • Remove any codepush references on native side
  • Clean and rebuild project.

Please let us know if it helps or any updates.

Thanks @ruslan-bikkinin, Adding this to Documentation will be great.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sergey-akhalkov picture sergey-akhalkov  路  4Comments

vira-khdr picture vira-khdr  路  3Comments

fanzhiri picture fanzhiri  路  3Comments

ACCTFORGH picture ACCTFORGH  路  3Comments

DeDuckProject picture DeDuckProject  路  3Comments