Not working with staging environment
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
Hi @jinxac, thanks for reaching us. Could you please take a look at https://github.com/Microsoft/react-native-code-push/issues/840 and verify if you have the same issue and if https://github.com/Microsoft/react-native-code-push/issues/840#issuecomment-302635288 resolves it?
@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.
@jinxac, got it, please let me know if any updates.
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.
@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
@sergey-akhalkov looks like there is something wrong with the staging environment itself. So here is what I tried doing:-
- Interchanged the
stagingandreleasekey. - Build the archive using my
releasescheme (which containsstagingkey 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
Hi @jinxac, could you please share with me the minimal version of the app where the issue is reproduces?
@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 :)
@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?
@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
Hi @jinxac, sorry for the delayed response, do you still experiencing the issue?
@sergey-akhalkov thanks for the reply.. yeah still experiencing the same issue
@sergey-akhalkov any updates?
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.
@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.
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.
2.

Please let me know if it helps or if you have any questions or see any issues.
@sergey-akhalkov Thanks a lot for your response. Let me try this out once.
Hi @jinxac, do you have any updates on this? I'm closing this for now, please feel free to reopen if needed.
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 😢
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.