Linker error introduced in 0.39-0.40 when building to device on release scheme
See original GitHub issueDescription
On a blank project created by 0.39 or 0.40 using react-native init <project_name>
and then switching the scheme from Debug
to Release
and building to a real iPhone 6s device, I get this linker error message:
Undefined symbols for architecture arm64:
"___gxx_personality_v0", referenced from:
_RCTDefaultLogFunction_block_invoke in libReact.a(RCTLog.o)
_RCTFormatLog in libReact.a(RCTLog.o)
___RCTAddLogFunction_block_invoke in libReact.a(RCTLog.o)
_RCTPerformBlockWithLogFunction in libReact.a(RCTLog.o)
_RCTPerformBlockWithLogPrefix in libReact.a(RCTLog.o)
RCTGetLocalLogFunction() in libReact.a(RCTLog.o)
___RCTPerformBlockWithLogPrefix_block_invoke in libReact.a(RCTLog.o)
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
It looks like it was introduced in this commit: Cleanup display of C++ stack frames in redbox.
Reproduction
- Run
react-native init project && open project/ios/project.xcodeproj
- Hit
cmd <
in Xcode and change the build configuration fromDebug
toRelease
- Set to run on your device (I used an iPhone 6s on iOS 10) and set up the appropriate device signing settings
- You should see a build failure with the above linker error
Solution
I had to turn off Dead Code Stripping in Build Settings
to get this to work. Ideally, I shouldn’t need to do this because it was fine in 0.38.
EDITED: Add -lc++
in Other Linker Flags to test target in release scheme
Additional Information
- React Native version: 0.39, 0.40
- Platform: iOS 10, iPhone 6s
- Operating System: macOS Sierra
Issue Analytics
- State:
- Created 7 years ago
- Reactions:47
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Apple Mach-O Linker Error | Apple Developer Forums
I just have some problem to test one of my apps. As soon as i press the play button to build and run...
Read more >Xcode Unit Tests - Link error when building for device only
When the linker is creating the Linker-Error executable, it discards FHKViewControllerThisSymbolWontLink because nothing in the executable uses it.
Read more >RCT-Folly linker error: ld: -U and -bitcode_bundle cannot be ...
Setting ENABLE_BITCODE=YES in PodFile resolves this error, but creates a new one which is caused by react-native-permissions . Here is the error ......
Read more >Install question - linker error - Microchip Technology
Release build of project `C:\Users\pmuldoon\Documents\ExpressPCB\Projects\InductanceMeter\18F47J53\InductanceMeter.mcp' started.
Read more >Linker error while compiling fully specialized member function ...
Hi, The fix does break Windows build heavily and will be put under /permissive-. It is fairly common that people define the explicit...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This looks like the same issue as https://github.com/facebook/react-native/issues/11861
Interesting that turning off dead code stripping also solves the problem, but the solution now in master is to add
-lc++
to theOther linker flags
(under Build Settings) of themyProjectTests
target.Sadly, this fix is still required for 0.40 😞