react-native-code-push icon indicating copy to clipboard operation
react-native-code-push copied to clipboard

Not working with staging environment

Open salujaharkirat opened this issue 9 years ago • 30 comments

Description

Hi, we have a react native application and we recently planned to add codepush to our application.

I went through the documentation and followed the exact steps mentioned there. I create a staging profile and added staging key there but I am witnessing something strange here. Its working fine on my local device with Debug as well as Release build(staging profile).

I can see following in my xcode logs when I try to run it locally with release option:-

[CodePush] Loading JS bundle from file:///var/containers/Bundle/Application/C20B7F8E-CC2F-418C-A011-A583183FB407/wlv1.app/main.jsbundle
2017-06-20 19:17:11.093 [info][tid:com.facebook.react.JavaScript] [CodePush] Checking for update.
2017-06-20 19:17:11.093323 wlv1[4744:1122933] [CodePush] Checking for update.
2017-06-20 19:17:11.384 [info][tid:com.facebook.react.JavaScript] [CodePush] Reporting binary update (1.1.0)
2017-06-20 19:17:11.384649 wlv1[4744:1122933] [CodePush] Reporting binary update (1.1.0)
2017-06-20 19:17:13.553 [info][tid:com.facebook.react.JavaScript] [CodePush] App is up to date.

Now when i create a beta build using archive and export to app store(using same staging profile), the codepush part does not work at all. In firebase I can see that an app_update event is getting fired but I am not really sure whats going on there because I cannot see result of API call anywhere. I am pretty sure my staging key is correct because same is working on device locally.

Reproduction

Following is my JS code:-

class WealthyApp extends React.Component {

  componentDidMount () {
    // Adding event to get current net status
    NetInfo.isConnected.addEventListener("change", this.handleConnectionChange);
  }

  componentWillUnmount () {
    // Removing event to get current net status
    NetInfo.isConnected.removeEventListener("change", this.handleConnectionChange);
  }

  handleConnectionChange = (isConnected) => {
    // Dispatching action to update current net status
    this.props.dispatch({"type":"RECEIVE_IS_NET_CONNECTED",isConnected});
  };



  render () {
    if (this.props.pinStatus === null) {
      return null;
    }
    return (
      <View style={styles.container}>
        <WealthyNavigator
          pinStatus={this.props.pinStatus}
        />
      </View>
    );
  }
}


WealthyApp.propTypes = {
  "dispatch": React.PropTypes.func.isRequired,
  "pinStatus": React.PropTypes.bool
};

const styles = StyleSheet.create({
  "container": {
    "flex": 1
  }
});

function login (store) {
  const {wlStore} = store;
  const {login} = wlStore;
  const {pinStatus} = login;

  return {
    pinStatus
  };
}

module.exports = codePush(connect(login)(WealthyApp));

Following is my code present in AppDelegate.m:-

#import <CodePush/CodePush.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ 
#ifdef DEBUG
    jsCodeLocation = [NSURL URLWithString:@"http://192.168.225.137:8081/index.ios.bundle"];
  #else
    jsCodeLocation = [CodePush bundleURL];
  #endif
}

Can someone please help me?

Additional Information

  • react-native-code-push version: 1.17.3-beta
  • react-native version: 0.40
  • iOS/Android/Windows version: ios
  • Does this reproduce on a debug build or release build? release

salujaharkirat avatar Jun 20 '17 14:06 salujaharkirat

Yeah no luck changing the project settings on appcenter.ms if I setup a staging scheme.

Not really your problem though, thanks for your help.

brookemitchell avatar Dec 14 '17 20:12 brookemitchell

@sergey-akhalkov thanks a ton for sharing.. i am finally back to integrating this to my project again :D .. I tried the exact configuration you mentioned but when i upload the binary to itunes after building with staging scheme it throws error on itunes saying that the build is invalid (Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path.) . It works fine release scheme though. Have u faced this issue?

salujaharkirat avatar Dec 25 '17 12:12 salujaharkirat

Hi @jinxac, thanks for reaching us again!

Have u faced this issue?

I believe not, so I don't sure how exactly I can help you here, did you tried the working sample above? Does it work for you?

sergey-akhalkov avatar Dec 25 '17 14:12 sergey-akhalkov

@sergey-akhalkov looks like the pod libraries are getting copied into Staging folder instead of release which leads to https://github.com/facebook/react-native/issues/11813#issuecomment-331368709

/Users/harkirat/Library/Developer/Xcode/DerivedData/wlv1-grovuwlrhzpjbvenlreejvbtlwol/Build/Intermediates.noindex/ArchiveIntermediates/wlv1 Staging/BuildProductsPath
tests-MBP:BuildProductsPath harkirat$ ls
Release-iphoneos	Staging-iphoneos
tests-MBP:BuildProductsPath harkirat$
tests-MBP:BuildProductsPath harkirat$ cd Staging-iphoneos/
tests-MBP:Staging-iphoneos harkirat$ ls
GTMOAuth2		Mixpanel		QBImagePickerController
GTMSessionFetcher	Pods_wlv1.framework	RSKImageCropper
GoogleToolboxForMac	Protobuf		nanopb
tests-MBP:Staging-iphoneos harkirat$
tests-MBP:BuildProductsPath harkirat$ cd Release-iphoneos/
tests-MBP:Release-iphoneos harkirat$ ls
49D27CAF-3566-30BB-9FF1-63E20D4D5231.bcsymbolmap	libRCTMaterialKit.a
57C7F55D-A2AE-30F3-A6EA-9F38A1651329.bcsymbolmap	libRCTNetwork.a
5maFL9							libRCTSettings.a
B00A891C-B9FD-3621-85B1-D7ACEEB3888C.bcsymbolmap	libRCTText.a
B881CB00-A637-3C8C-90B1-36E49E358AA1.bcsymbolmap	libRCTVibration.a
GeneratedInfoPlistDotEnv.h				libRCTWebSocket.a
Hhe8NH							libRNDeviceInfo.a
QBImagePicker.framework					libRNFIRMessaging.a
QBImagePicker.framework.dSYM				libRNFS.a
RSKImageCropper.framework				libRNFetchBlob.a
RSKImageCropper.framework.dSYM				libRNIntercom.a
include							libRNMixpanel.a
libBVLinearGradient.a					libReact.a
libBugsnagReactNative.a					libReactNativeConfig.a
libBugsnagStatic.a					libcxxreact.a
libCodePush.a						libdouble-conversion.a
libRCTActionSheet.a					libimageCropPicker.a
libRCTAnimation.a					libjschelpers.a
libRCTCamera.a						libthird-party.a
libRCTFBSDK.a						libyoga.a
libRCTGeolocation.a					wlv1.app
libRCTImage.a						wlv1.swiftmodule
libRCTLinking.a

I am pretty aware that this is not code push issue but any help would really be appreciated :) . Thanks in advance

salujaharkirat avatar Dec 25 '17 20:12 salujaharkirat

@jinxac, we are very "backlogged" and have no ability and time to manage such kind of issues, but please feel free to create a CodePush related issue - we'll take a look at it in order of priority.

sergey-akhalkov avatar Dec 26 '17 07:12 sergey-akhalkov

@sergey-akhalkov i tried using https://github.com/blargity/react-native-schemes-manager for first creating a staging environment and then a taking a beta build with staging configuration. Looks like its working fine now :). Let me give a try now by changing code push keys

salujaharkirat avatar Feb 13 '18 12:02 salujaharkirat

@sergey-akhalkov with react-native-schemes-manager I was easily able to integrate this. If someone needs any help regards integrations and multiple environments on iOS would love to help.

salujaharkirat avatar Feb 17 '18 09:02 salujaharkirat

Hi @jinxac, I'm trying to fix this bug on my app and can't seem to make it work. I'm using CocoaPods and my XCode workspace looks exactly like the demo, but whenever I build my project my files end up scattered across both Staging/Production build folders. I'm now trying to use the schemes-manager module like you said but still am having the same issues. Keen to hear how you got this to work with CocoaPods. Thanks.

rodperottoni avatar Jan 17 '19 03:01 rodperottoni

@rodperottoni i too have cocoapods in my project, but it is working fine. What error are using exactly? Can you share your profiles and package.json once?

salujaharkirat avatar Jan 18 '19 13:01 salujaharkirat

If anybody is still struggling with this issue - there is a simple way to differentiate between Codepush staging and release keys using the same "Release" configuration if you already do your builds with Fastlane.

You basically need to have these lines in your Info.plist:

<key>CodePushDeploymentKey</key>  
<string>$(CODEPUSH_KEY)</string>

and then, assuming you already have different Fastlane lanes for staging and release, add appropriate Codepush key for each lane in form of a gym param:

xcargs: "CODEPUSH_KEY=<your staging/release key>"

The key will be inserted during build process and that's about it! That definitely does not cover all cases, but should be useful for those who are searching for a simplified solution without the need to edit your xcode project file.

AlgirdasVZ avatar Apr 05 '19 10:04 AlgirdasVZ