Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with staging environment #893

Closed
salujaharkirat opened this issue Jun 20, 2017 · 30 comments
Closed

Not working with staging environment #893

salujaharkirat opened this issue Jun 20, 2017 · 30 comments

Comments

@salujaharkirat
Copy link

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
@sergey-akhalkov
Copy link
Contributor

Hi @jinxac, thanks for reaching us. Could you please take a look at #840 and verify if you have the same issue and if #840 (comment) resolves it?

@salujaharkirat
Copy link
Author

@sergey-akhalkov doesnt look the like the same issue but my BuildConfiguration is still Release under Archives section of schemes. I will try making it Staging and creating a build once.

@sergey-akhalkov
Copy link
Contributor

@jinxac, got it, please let me know if any updates.

@salujaharkirat
Copy link
Author

Hey @sergey-akhalkov i tried changing that Release to Staging but that breaks my pods configuration and I get error ld: framework not found Pods_wlv1 and this is coming specifically in staging, release and debug seem to be working fine.

@salujaharkirat
Copy link
Author

@sergey-akhalkov Can you please me tell me what do you need from my end? Logs/More Info would love to share the necessary info

@salujaharkirat
Copy link
Author

salujaharkirat commented Jun 20, 2017

@sergey-akhalkov looks like there is something wrong with the staging environment itself. So here is what I tried doing:-

  1. Interchanged the staging and release key.
  2. Build the archive using my release scheme (which contains staging key itself) and uploaded to app store as beta build.

In this case I was able to see the changes.

Can you please let me know if I am missing something

@salujaharkirat salujaharkirat changed the title Not working on with beta/release builds Not working on with staging environment Jun 20, 2017
@salujaharkirat salujaharkirat changed the title Not working on with staging environment Not working with staging environment Jun 20, 2017
@sergey-akhalkov
Copy link
Contributor

Hi @jinxac, could you please share with me the minimal version of the app where the issue is reproduces?

@salujaharkirat
Copy link
Author

salujaharkirat commented Jun 21, 2017

@sergey-akhalkov I have shared some piece of code above. Can you please tell me once what other information is required? I will share accordingly :)

@sergey-akhalkov
Copy link
Contributor

@jinxac, do I get it right if your app does not receiving any updates in case it has been archived/build with Staging scheme or you are experiencing some compile issues while trying to follow this steps?

@salujaharkirat
Copy link
Author

salujaharkirat commented Jun 21, 2017

@sergey-akhalkov setup works fine the steps linked you shared above. Yes you are right that it is not receiving updates when built with staging schemes with Pods.

When I change Release to Staging under scheme Archives it starts to throw error ld: Frameworks not found(these frameworks are specific to Pods) during Linking.I tried to dig in a bit further and saw that under BuildProducts folder I have 2 folders Release-ios and Staging-ios. My entire packages and code is under Release-ios as expected but my Pod specific packages go under Staging-ios folders. Now linker tries to link pod packages from Release-ios folder which throws error.

Now, When I change Staging to Release under staging scheme Archieves it works fine and build is created but on testflight(beta) build code push changes are not reflected and under code-push deployment app-name ls -k I see no installs recorded

@sergey-akhalkov
Copy link
Contributor

Hi @jinxac, sorry for the delayed response, do you still experiencing the issue?

@salujaharkirat
Copy link
Author

@sergey-akhalkov thanks for the reply.. yeah still experiencing the same issue

@salujaharkirat
Copy link
Author

@sergey-akhalkov any updates?

@sergey-akhalkov
Copy link
Contributor

sergey-akhalkov commented Jul 21, 2017

Hi @jinxac, sorry for the delayed reply. I've investigated the problem you have and faced with linking issue while archiving. But I've successfully configured my project with Production and Staging schemes - CodePush updates work as expected. Also, I'm using the latest version of react-native and react-native-code-push, so the issue with linking could probably be here.
So I'm going to downgrade RN and CodePush versions and verify if everything works - I'll let you know if any changes.

Please also take a look at my project here: rncp893 copy.zip
If you have a chance - you could also try to downgrade RN and CodePush versions and verify if it works or not.

Thanks for the patience.

@sergey-akhalkov
Copy link
Contributor

@jinxac, I've found out the root cause of linker issue - we need to change podfile like that:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'rncp893' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for rncp893

  pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'BatchedBridge'
  ]
  pod 'CodePush', :path => '../node_modules/react-native-code-push'

  target 'rncp893Tests' do
    inherit! :search_paths
    # Pods for testing
  end

end

target 'rncp893-tvOS' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for rncp893-tvOS

  target 'rncp893-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

Please let me know if it helps.

@sergey-akhalkov
Copy link
Contributor

sergey-akhalkov commented Jul 25, 2017

Hi @jinxac, please take a look at rncp893 copy.zip
I've configured this project to use pods, release and staging schemes. Also archiving works well both for release and staging, CodePush also works correctly.
Please pay attention on podfile and this customization:
1.
screenshot 2017-07-25_09-59-32
2.
screenshot 2017-07-25_10-00-57

Please let me know if it helps or if you have any questions or see any issues.

@salujaharkirat
Copy link
Author

@sergey-akhalkov Thanks a lot for your response. Let me try this out once.

@sergey-akhalkov
Copy link
Contributor

Hi @jinxac, do you have any updates on this? I'm closing this for now, please feel free to reopen if needed.

@brookemitchell
Copy link

Thanks @sergey-akhalkov your solution of editing build locations for project and pods worked for me.

Now I wonder how to make those changes in ci 😢

@sergey-akhalkov
Copy link
Contributor

Hi @brookemitchell, thanks for the feedback. By CI do you mean appcenter.ms?
Please let me know if you need any help or have any questions.

@brookemitchell
Copy link

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.

@salujaharkirat
Copy link
Author

salujaharkirat commented Dec 25, 2017

@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?

@sergey-akhalkov
Copy link
Contributor

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?

@salujaharkirat
Copy link
Author

@sergey-akhalkov looks like the pod libraries are getting copied into Staging folder instead of release which leads to facebook/react-native#11813 (comment)

/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

@sergey-akhalkov
Copy link
Contributor

@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.

@salujaharkirat
Copy link
Author

@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
Copy link
Author

@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.

@rodperottoni
Copy link

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.

@salujaharkirat
Copy link
Author

salujaharkirat commented Jan 18, 2019

@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?

@AlgirdasVZ
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants