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

[0.45.0] + [0.46.0-rc.2] fails to compile folly: Undefined symbols for architecture x86_64 #14328

Closed
sjmueller opened this issue Jun 5, 2017 · 12 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@sjmueller
Copy link
Contributor

sjmueller commented Jun 5, 2017

Having a problem compiling react native 0.45 & 0.46-rc.2 during the linking phase:

image

image

I've never seen errors in RN related to folly, so not really sure what has changed from 0.44 to 0.45 that would cause this type of compilation error. My best guess could be from this commit 885856c that's trying to fix the Travis build, but it does a bunch of stuff with conditional includes that I don't understand.

Our RN xcode project is in swift, so maybe the difference is why these errors snuck through without detection?

cc @ericvicenti @javache

@sjmueller sjmueller changed the title 0.45.0-rc.2 fails to compile folly: Undefined symbols for architecture x86_64 [0.45.0] + [0.46.0-rc.2] fails to compile folly: Undefined symbols for architecture x86_64 Jun 13, 2017
@sjmueller
Copy link
Contributor Author

sjmueller commented Jun 13, 2017

Any help here? I've tried just about everything:

  • Reconfigure Other Linker Flags with every combination of -all_load -Objc -lc++
  • Include libthird-party.a in our project's Linked Frameworks and Libraries
  • Add to Header Search Paths: $(SRCROOT)/../node_modules/react-native/third-party recursively
  • watchman watch-del-all, rm -rf node_modules, rm -fr $TMPDIR/react-*
  • clear xcode derived data, clean builds, the works

All to no avail.

@ericvicenti @javache @vjeux @lelandrichardson: The thirdparty changes included in 0.45+ have broken swift and objc projects with cocoapods. I realize that fb doesn't use swift, but more and more teams are in this camp and so any advice or potential fixes you can think of would be greatly appreciated.

@javache
Copy link
Member

javache commented Jun 14, 2017

The compilation error you mention should be fixed by 2766103. Can you check if those changes are present in your copy?

@andon
Copy link

andon commented Jun 14, 2017

We are having the same issue after upgrade from rn-0.44.2 to rn-45.1.

@javache I checked react-native in node_modules, and the changes from 2766103 are present, but we still get the errors.

Similar as with @sjmueller, we tried all the steps to clean up the project before getting to this issue.

@sjmueller
Copy link
Contributor Author

@javache I have prepared a barebones swift 3 project with RN 0.46.0-rc.2 which reproduces the errors:

rn46-swift-3rd-party-errors.zip

  • npm i to install dependencies

  • open project in xcode, then ⌘ SHIFT < to uncheck parallelized build + add React as the first target:

    image

  • Run the project in xcode ⌘ R

You should now be able to reproduce the error:

@daesan
Copy link
Contributor

daesan commented Jun 15, 2017

@javache I have upgraded from 0.44.3 to 0.45.1 and I am experiencing the same linker error as @sjmueller. My project is Objective-C based and I am using CocoaPod.

Looking at the linker warnings, there seems to be path misconfiguration? "ios" part is being repeated in the path.

error

@sjmueller
Copy link
Contributor Author

sjmueller commented Jun 15, 2017

Sorry you have the same issue @daesan -- didn't know until now that objc projects with cocoapods are affected too. I originally thought it was just swift.

@sjmueller
Copy link
Contributor Author

FYI our swift project does not use cocoapods at all.

@mhorowitz
Copy link
Contributor

There's two problems here:

  1. the react project file includes folly/File.cpp, which is what pulls in these symbols, and is unnecessary. You can delete it; I'll submit a fix to do the same upstream.

  2. Normally, an unreferenced .o file in a .a file would not cause a problem, but your top-level project file includes -all_load in Other Linker Flags. This causes all .o files to get pulled in, which causes the failure. This flag was needed as a workaround for an old version of Xcode, but not any more. If I remove the flag, your project builds without any linker errors. So this likely a good workaround for now.

@sjmueller
Copy link
Contributor Author

sjmueller commented Jun 15, 2017

Thanks for chiming in @mhorowitz. As mentioned above, I tried every combination of Linker Flags. For the record, I have never been able to get a swift project to work with react native using just -lc++ and -ObjC linker flags. Yes the project will build, however the app will immediately crash at runtime. This is what I just got by removing -all_load in favor of -ObjC in the swift project I shared:

<RCTBridge: 0x6100000ba160>, executor: (null))
2017-06-14 23:45:50.390 [warn][tid:main][RCTBridge.m:114] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?

@sjmueller
Copy link
Contributor Author

Actually, the error above is caused by AppTransportSecurity -- i forgot to add the exception:

	<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSAllowsLocalNetworking</key>
		<true/>
	</dict>

After updating info.plist, I get the error:

2017-06-15 00:03:02.798 [error][tid:com.facebook.react.JavaScript] undefined is not an object (evaluating 'ReactPropTypes.string')
2017-06-15 00:03:02.800 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: undefined is not an object (evaluating 'ReactPropTypes.string')
2017-06-15 00:03:02.814 [error][tid:com.facebook.react.JavaScript] this._lazyCallableModules[name] is not a function. (In 'this._lazyCallableModules[name]()', 'this._lazyCallableModules[name]' is undefined)
2017-06-15 00:03:02.817 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: this._lazyCallableModules[name] is not a function. (In 'this._lazyCallableModules[name]()', 'this._lazyCallableModules[name]' is undefined)

These are not errors I recall seeing before. For reference, the error is the same for -all_load or -ObjC, of course after a clean + rebuild.

@andon
Copy link

andon commented Jun 15, 2017

Removing -all_load from Other Linker Flags makes the project build again. Thanks @mhorowitz

@sjmueller
Copy link
Contributor Author

sjmueller commented Jun 15, 2017

@mhorowitz FYI removing File.cpp from third-party Compile Source indeed fixes the problem 🎉 -- I tried with our full project. There are some other problems now with the packager for 0.46.0-rc.2 that I've detailed in #14530, but not related to this issue.

grabbou pushed a commit that referenced this issue Jul 5, 2017
Summary: This fixes #14328

Reviewed By: javache

Differential Revision: D5254711

fbshipit-source-id: e9b81e537cca9d6648f44ed61acd127015d2e1f8
@facebook facebook locked as resolved and limited conversation to collaborators Jun 15, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants