question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Linker error introduced in 0.39-0.40 when building to device on release scheme

See original GitHub issue

Description

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 from Debug to Release
  • 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:closed
  • Created 7 years ago
  • Reactions:47
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
robhogancommented, Jan 16, 2017

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 the Other linker flags (under Build Settings) of the myProjectTests target.

1reaction
kickthekencommented, Jan 8, 2017

Sadly, this fix is still required for 0.40 😞

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found