Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Header changes required for 0.40#670

Merged
buptkang merged 1 commit into
microsoft:masterfrom
wildlifela:upgrade
Jan 24, 2017
Merged

Header changes required for 0.40#670
buptkang merged 1 commit into
microsoft:masterfrom
wildlifela:upgrade

Conversation

@christopherdro
Copy link
Copy Markdown
Contributor

@christopherdro christopherdro commented Jan 12, 2017

These changes were required for me to properly build the project on the latest version of react native.
Related #665 #638

@msftclas
Copy link
Copy Markdown

Hi @christopherdro, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla.microsoft.com.

TTYL, MSBOT;

@axemclion
Copy link
Copy Markdown

@christopherdro Thanks for the PR. Would this be a duplicate of #665 ?

@christopherdro
Copy link
Copy Markdown
Contributor Author

@axemclion Are the changes in #665 suppose to achieve the same thing?

I had to cherry pick the 2 open PR's plus these changes to get our app to build properly.
Although I haven't tested it. Will likely push to stage tomorrow and can confirm back here afterwards.

Here is how our forked version currently looks.
https://github.com/wildlifela/react-native-code-push/tree/rn-40

@msftgits
Copy link
Copy Markdown

Hi, I am closing and re-opening this PR to bump the CLA bot. Sorry for the inconvenience!

@dingbat
Copy link
Copy Markdown
Contributor

dingbat commented Jan 18, 2017

Any updates on this? This PR alone fixed errors for me on RN 0.40.0 (without needing the other things in the rn-40 branch of @christopherdro's fork.)

@bitcoinvsalts
Copy link
Copy Markdown

+1

Comment thread ios/CodePush/CodePush.h
@@ -1,5 +1,5 @@
#if __has_include("RCTEventEmitter.h")
#import "RCTEventEmitter.h"
#import <React/RCTEventEmitter.h>
Copy link
Copy Markdown
Contributor

@sergey-akhalkov sergey-akhalkov Jan 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make CodePush able to work both with react-native@0.40.0 and react-native@0.39.2 we probably should use:

#if __has_include("RCTEventEmitter.h")
#import "RCTEventEmitter.h"
#elif __has_include(<React/RCTEventEmitter.h>)
#import <React/RCTEventEmitter.h>
#else
#import "React/RCTEventEmitter.h"   // Required when used as a Pod in a Swift project
#endif

Comment thread ios/CodePush/CodePush.m
#import <React/RCTConvert.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTRootView.h>
#import <React/RCTUtils.h>
Copy link
Copy Markdown
Contributor

@sergey-akhalkov sergey-akhalkov Jan 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here:

#if __has_include("RCTAssert.h")
#import "RCTAssert.h"
#else
#import <React/RCTAssert.h>
#endif

#if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
#import <React/RCTBridgeModule.h>
#endif

#if __has_include("RCTConvert.h")
#import "RCTConvert.h"
#else
#import <React/RCTConvert.h>
#endif

#if __has_include("RCTEventDispatcher.h")
#import "RCTEventDispatcher.h"
#else
#import <React/RCTEventDispatcher.h>
#endif

#if __has_include("RCTRootView.h")
#import "RCTRootView.h"
#else
#import <React/RCTRootView.h>
#endif

#if __has_include("RCTUtils.h")
#import "RCTUtils.h"
#else
#import <React/RCTUtils.h>
#endif

@@ -1,5 +1,5 @@
#import "CodePush.h"
#import "RCTConvert.h"
#import <React/RCTConvert.h>
Copy link
Copy Markdown
Contributor

@sergey-akhalkov sergey-akhalkov Jan 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#import "CodePush.h"
#if __has_include("RCTConvert.h")
#import "RCTConvert.h"
#else
#import <React/RCTConvert.h>
#endif

@@ -1,5 +1,5 @@
#import "CodePush.h"
#import "RCTConvert.h"
#import <React/RCTConvert.h>
Copy link
Copy Markdown
Contributor

@sergey-akhalkov sergey-akhalkov Jan 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#import "CodePush.h"
#if __has_include("RCTConvert.h")
#import "RCTConvert.h"
#else
#import <React/RCTConvert.h>
#endif

@sergey-akhalkov
Copy link
Copy Markdown
Contributor

sergey-akhalkov commented Jan 19, 2017

@dingbat - hi. I've tried to build initial React Native project (execute react-native init myapp command) using this PR and got build failed - CodePush.h file not found, it means that #665 and #638 PRs is steel required for react-native@0.40.0.

By the way I think it may be a good idea to apply this PR in next release of CodePush due to breaking changes in https://github.com/facebook/react-native/releases/tag/v0.40.0 . But this PR has no back compatibility with React Native having version v0.39.2. To make CodePush able to work both with react-native@0.40.0 and react-native@0.39.2 header files should use __has_include(...) statements. (I've added comments in files changes of this PR).

@christopherdro, could you please rebase your commit to provide back compatibility? Please let me know if you see any issues or have any questions.

@AndrewJack
Copy link
Copy Markdown
Contributor

@sergey-akhalkov Why don't you bump the major version for 0.40 and later, and continue to support 0.29 and older on the 1.x version in a separate 1.x branch?

Just like how bugsnag have done it - https://github.com/bugsnag/bugsnag-react-native/releases

@richardhuaaa
Copy link
Copy Markdown
Contributor

@AndrewJack - I think the main reason is that we'd like to avoid the overhead of maintaining multiple active branches simultaneously and porting features/fixes between them etc. Although I'd be interested to hear any alternative arguments.

@ivpusic
Copy link
Copy Markdown

ivpusic commented Jan 19, 2017

are you planning to integrate these changes soon? This is the only thing blocking me from migrating to RN 0.40.

@richardhuaaa
Copy link
Copy Markdown
Contributor

@buptkang and I are actively looking at it, we expect to have it released tomorrow or on Monday.

@richardhuaaa
Copy link
Copy Markdown
Contributor

Hi all, we ran into some minor unanticipated issues and have a supplemental PR up with some tweaks to ensure that we are backwards compatible and that some other header issues are taken care of. It will be merged tonight, and we will make a release tomorrow morning!

@buptkang
Copy link
Copy Markdown
Contributor

@christopherdro @dingbat @jsappme @AndrewJack @ivpusic @nihgwu @martijndeh:
Apologies for the delay - we've merged all of the required fixes and verified everything. react-native-code-push@1.17.0-beta has been published to npm with support for react-native@0.40.0. Thanks for your patience, and release notes are coming soon!

@ivpusic
Copy link
Copy Markdown

ivpusic commented Jan 24, 2017

awesome! thanks a lot for your time and effort!

@wkw
Copy link
Copy Markdown

wkw commented Feb 7, 2017

In case this helps anyone else upgrading iOS, I was getting build failures for a lot of duplicate interface definitions after upgrading to rncp 1.17.0-beta. They all came from this line in my AppDelegate.m: #import "CodePush.h". I guess that got left when I r-n unlinked then after re-linking, my appdelegate looked like:

#import "AppDelegate.h"
#import <CodePush/CodePush.h>
#import "CodePush.h"

Removing #import "CodePush.h" made the build... well, build!

I have yet to ever test code pushing, so I can't say whether there are any other issues.

@ghost
Copy link
Copy Markdown

ghost commented Feb 8, 2017

If it's a breaking change may I suggest bumping the major in accordance with SemVer unless you've got something more practical going on.

@axemclion
Copy link
Copy Markdown

We have been using (this line](https://github.com/Microsoft/react-native-code-push/blob/e42485243d9466fb6c00937bd9f67cee0d96de53/ios/CodePush/RCTConvert%2BCodePushInstallMode.m#L3 for backward compat, so I think we dont have to bump up the major version.

#if __has_include(<React/RCTConvert.h>)
#import <React/RCTConvert.h>
#else
#import "RCTConvert.h"
#endif

@simonmitchell
Copy link
Copy Markdown

All of the above __has_includes need to be the other way around apart from @axemclion's example, because technically #import "RCTConvert.h" is still available to the compiler, it just causes compiler warnings due to a duplicate import!

#if __has_include(<React/RCTRedBox.h>)
#import <React/RCTRedBox.h>
#elif __has_include("RCTRedBox.h")
#import "RCTRedBox.h"
#elif __has_include("React/RCTRedBox.h")
#import "React/RCTRedBox.h"   // Required when used as a Pod in a Swift project
#endif

@axemclion
Copy link
Copy Markdown

cc @BretJohnson - what do you think of the comment above ?

@simonmitchell
Copy link
Copy Markdown

I added this style of import into a pull-request I was merging into another library: react-native-navigation, I only ran the project with RN 0.40.0, so this way around may cause issues with RN < 0.40.0, but the examples above mine certainly didn't work with RN 0.40.0 :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.