react-native: iOS 11.3 XCode 9.3 (9E145) don't build
I’ve updated XCode to 9.3 (9E145) and iPhone X to 11.3 and now my project isn’t building. It doesn’t work with iOS 11.2 simulator too. But it works with react-native run-ios
Environment: OS: macOS High Sierra 10.13.4 Node: 9.2.0 Yarn: 1.5.1 npm: 5.8.0 Watchman: 4.9.0 Xcode: Xcode 9.3 Build version 9E145 Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed) react: 16.0.0-beta.5 => 16.0.0-beta.5 react-native: 0.49.5 => 0.49.5
Steps to Reproduce
Update iDevice and Xcode then try to build.
Expected Behavior
Build success
Actual Behavior
Build fails.
/Users/*****/node_modules/react-native/Libraries/Text/RCTTextField.m:131:108: Values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead
RCTLogWarn(@"Native TextInput(%@) is %zd events ahead of JS - try to make your JS faster.", self.text, eventLag);
Enum values with underlying type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead
Sometimes it’s RCTImage, RCTImageCache, etc…
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 42
- Comments: 46 (5 by maintainers)
Commits related to this issue
- Resolve https://github.com/facebook/react-native/issues/18638\#issuecomment-377955130 — committed to Etheryte/react-native by deleted user 6 years ago
RN 0.49.3 Xcode 9.3 have the same issue
UPDATED SOLUTION (choose 1 from below)
NSString stringWithFormat
method which has%zd
formatchange
%zd
to%lld
and add(long long)
into respective format link to sample patch:was https://github.com/facebook/react-native/blob/4a893ee071f76377a678fe9774190397f636598a/Libraries/Image/RCTImageCache.m#L27-L28
after apply patch: https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Image/RCTImageCache.m#L25-L26
Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest release, v0.54?
Thank you for your contributions.
Having the same issue with the same env of @teyou
At the end I downgraded the Xcode to 9.2 to archive the app. I just wondered why Apple doesn’t mention this such breaking change in the release note of Xcode 9.3.
Xcode 9.2
Same problem. I just updated Xcode to 9.3(9E145) and the same errors occur when I try to archive. Different part is building for simulator is fine, but only archive or building for generic iOS device have the problem. I was about to submit a build, but suddenly can’t upload a new build to itunesconnect. =( Any clue?
@peteroid thank you for the solution. It is a high risk to upgrade the RN version. For now, downgrading to Xcode 9.2 is the best solution.
In Xcode just hover the error line and then you will find FIX button press it and re-Archive.
Yes it’s risky to patch RN but it’s a little safer if you create a patch script that’s run in npm/yarn postinstall. That way, if you have to reinstall RN your patches will be automatically applied.
In package.json add:
"postinstall": "bin/patch33x.sh"
The patch script and data are in my gist.
Note that I’m patching RN 0.33 so my patch file may not work on your version. Some of the changes are the same as mentioned above, some are different.
I’m still stuck on RN 0.33 because I still support iOS 7. And I can’t downgrade to Xcode 9.2 because my test device is already on iOS 11.3 (I sent in the phone for a battery replacement and it came back with the upgrade).
Thanks @teyou, @antoinerousseau and @edencakir .
EDIT: I forgot to mention how to create the patch file, which you’ll need to do, since you probably can’t use mine.
With a clean react-native:
Then build with xcode, click on the little red dot, fix the error, and repeat till you’ve fixed all these casting errors. Then:
To make @teyou’s third solution work, I also had to cast
eventLag
tolong
inRCTTextView.m:238
,RCTTextField.m:93
andRCTTextInput.m:90
(i.e. replaceeventLag
by(long)eventLag
)try this:
RCTLogWarn(@"Native TextInput(%@) is %ld events ahead of JS - try to make your JS faster.", self.text, (long)eventLag);
any workaround for older versions? (besides downgrading xcode)
@andrejunges You can use XCode quick fix tool (tap on the red circle).
I use @teyou 's solution 3 and modified about 3 ~ 4 files Built successfully.
@wkwyatt you can find in https://developer.apple.com/downloads/index.action (login with account Apple developer)
Upgrading the react-native: 0.49.3 to react-native: 0.55.2, now it working.
@teyou’s third solution + @antoinerousseau additions worked for me. Thank you guys!
I work on a company product, I am then releasing the app so Ic an downgrade the Xcode to 9.2 and make a work around for it. But what about other developers at different location? They are gonna think I messed up the code as I am the one releasing the code. Also my company has policy to not upgrade the RN version from 0.44.3 to any higher version. This is gonna be hassle.