-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
[0.40] Warning: Swift Projects Fail #11572
Comments
As far as I can tell master is effectively broken at the moment, even for simple Obj-C projects created with
Fails due to redefinitions, because 0.40.0-rc.2 (which has e1577df but not 59407f3) fails because headers can't be found - I think that's because third-party libraries pick up RCT headers as user headers, which in turn try to include more RCT headers as library headers, but then they're not found (because the third-party lib doesn't have the proper dependency on React? Not sure). Edit: I've just noticed the discussion on e1577df . Looks like this one's going to be painful. |
@sjmueller I'd be interested to know if #11614 helps you. |
@sjmueller I've just given Swift a try, and I had success with the latest master if I use |
@rh389 I tried latest, but still getting errors. Can you outline how to reproduce your success? Keep in mind I'm trying to start from a fresh swift project, rather than using swift files inside the Obj-C project that's create with react-native-init. |
Did you mean latest master with your #11614 PR applied? |
Sure. And nope, I didn't mean with the PR applied, although if you do have the PR applied it's possible to continue to use a quote style in your bridging header's imports. Below works without my PR:
I haven't gone through step 8 myself, but I've pushed the rest up here: https://github.com/rh389/react-native-swift-template. I haven't needed to touch header search paths here HTH🎄 |
@rh389 just came to say I had success starting from scratch and using the similar steps you outlined above. I'll also mention some extra info for anyone else trying to get get swift 3 running end to end: 6a. In addition, include 7a. Add 8a. Example Swift 3 code as a drop-in to
|
Cheers for fleshing that out, glad you got it working. I think you'll still have problems with any third-party libs that import anything you've already imported, unfortunately, until either they're updated or something like #11614 is merged. |
I just found out that we still have problems, in both 0.40 rc0 and latest master. While the steps above do get you a build that works, unfortunately once someone else clones from source control, the The only solution I know of is to remove all of the core react libs from Linked Frameworks and Libraries except for What a pain! It seems that xcode is getting confused because of not building the react project first, which results in all the other dependent projects failing left and right. |
You'll probably want to make React the first target and disable build parallelisation to ensure that it's built first, See @SandroMachado's comment at #11721 (comment). |
Have any RN core developer made any comments about that they want to focus on swift support? So this doesnt keep happening? Or if there is any updates in the near future that fixes this? We are currently looking at RN to be our platform, but we are very interested in using swift with cocoapods. And this issue here has made us stop at version 0.38 so far. But we would really see that we were at the newest version. |
Summary: To make React Native play nicely with our internal build infrastructure we need to properly namespace all of our header includes. Where previously you could do `#import "RCTBridge.h"`, you must now write this as `#import <React/RCTBridge.h>`. If your xcode project still has a custom header include path, both variants will likely continue to work, but for new projects, we're defaulting the header include path to `$(BUILT_PRODUCTS_DIR)/usr/local/include`, where the React and CSSLayout targets will copy a subset of headers too. To make Xcode copy headers phase work properly, you may need to add React as an explicit dependency to your app's scheme and disable "parallelize build". Reviewed By: mmmulani Differential Revision: D4213120 fbshipit-source-id: 84a32a4b250c27699e6795f43584f13d594a9a82
Speaking as an observer, Swift doesn't appear to have first-class support from the RN team because AFAIK they don't use it internally (and I think it's healthy, at least for now, to regard RN as part of facebook's stack they've chosen to share rather than as something they build primarily for the community's needs). There are plans to add some more tests to prevent big regressions though, and as you can see from this thread, it's very possible to use Swift currently. #12089 should make it smoother - using CocoaPods to build RN as a framework avoids the need for bridging headers. |
Summary: Fixes facebook#11272 Fixes facebook#11572 Fixes facebook#11781 The main changes here are: * This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml * Adds required header search paths for the jschelpers and cxxreact subspecs. * Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project. * It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec * Consistent styling. I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint. rh389 sjmueller Could you please test with your projects? Closes facebook#12089 Differential Revision: D4518605 fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
Summary: Fixes facebook#11272 Fixes facebook#11572 Fixes facebook#11781 The main changes here are: * This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml * Adds required header search paths for the jschelpers and cxxreact subspecs. * Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project. * It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec * Consistent styling. I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint. rh389 sjmueller Could you please test with your projects? Closes facebook#12089 Differential Revision: D4518605 fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
Summary: Fixes facebook#11272 Fixes facebook#11572 Fixes facebook#11781 The main changes here are: * This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml * Adds required header search paths for the jschelpers and cxxreact subspecs. * Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project. * It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec * Consistent styling. I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint. rh389 sjmueller Could you please test with your projects? Closes facebook#12089 Differential Revision: D4518605 fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
Summary: Fixes facebook#11272 Fixes facebook#11572 Fixes facebook#11781 The main changes here are: * This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml * Adds required header search paths for the jschelpers and cxxreact subspecs. * Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project. * It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec * Consistent styling. I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint. rh389 sjmueller Could you please test with your projects? Closes facebook#12089 Differential Revision: D4518605 fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
Summary: Fixes facebook#11272 Fixes facebook#11572 Fixes facebook#11781 The main changes here are: * This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml * Adds required header search paths for the jschelpers and cxxreact subspecs. * Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project. * It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec * Consistent styling. I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint. rh389 sjmueller Could you please test with your projects? Closes facebook#12089 Differential Revision: D4518605 fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
Summary: Fixes facebook#11272 Fixes facebook#11572 Fixes facebook#11781 The main changes here are: * This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml * Adds required header search paths for the jschelpers and cxxreact subspecs. * Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project. * It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec * Consistent styling. I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint. rh389 sjmueller Could you please test with your projects? Closes facebook#12089 Differential Revision: D4518605 fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
Summary: Fixes #11272 Fixes #11572 Fixes #11781 The main changes here are: * This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml * Adds required header search paths for the jschelpers and cxxreact subspecs. * Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project. * It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec * Consistent styling. I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint. rh389 sjmueller Could you please test with your projects? Closes #12089 Differential Revision: D4518605 fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
Summary: Fixes facebook#11272 Fixes facebook#11572 Fixes facebook#11781 The main changes here are: * This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml * Adds required header search paths for the jschelpers and cxxreact subspecs. * Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project. * It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec * Consistent styling. I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint. rh389 sjmueller Could you please test with your projects? Closes facebook#12089 Differential Revision: D4518605 fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
Summary: Fixes facebook#11272 Fixes facebook#11572 Fixes facebook#11781 The main changes here are: * This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml * Adds required header search paths for the jschelpers and cxxreact subspecs. * Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project. * It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec * Consistent styling. I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint. rh389 sjmueller Could you please test with your projects? Closes facebook#12089 Differential Revision: D4518605 fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
With the new changes in e1577df and 59407f3, header references have been changed from quotes to angle brackets. While this may work in an Obj-C project, it causes several compilation errors for swift projects.
Previously to
0.40
, you could create a new swift project and perform the following steps to compile successfully:-all_load
and-lc++
linker flagsHeader Search Paths
Full steps for swift setup details can be seen here.
Now according to the summary in update 59407f3:
The above statement implies that customizing
Header Search Paths
is no longer necessary, but is this true for Swift? In fact it seems there's no longer any straightforward way for Swift projects to find these angle bracket headers when libraries are included directly in the project (not using cocoapods), similar to what has been detailed on stack overflow. In addition toHeader Search Paths
, I've triedUser Header Search Paths
and settingAlways Search User Paths
toYes
. No combination thus far yields successful compilation, instead throwing these errors:Why is this change being made? I've been using swift with RN successfully since the very beginning, and now there is risk of not being able to upgrade without jumping through hoops (i.e. npm post install scripts to rewrite headers). Please don't introduce such a breaking change unless there's a verified way of supporting swift!
The text was updated successfully, but these errors were encountered: