React-native: Undefined symbols for architecture x86_64 - _RCTSetLogFunction referenced...

Created on 1 Aug 2019  路  18Comments  路  Source: facebook/react-native

Build release failed with message

Ld /Users/user/Library/Developer/Xcode/DerivedData/[projectname]-dbcuopocesxwzyaxjpbtpqciwylm/Build/Intermediates.noindex/[projectname].build/Release-iphonesimulator/[projectname]Tests.build/Objects-normal/x86_64/[projectname]Tests normal x86_64 (in target: [projectname]Tests)
cd /Users/user/Apps/[projectname]/ios
export IPHONEOS_DEPLOYMENT_TARGET=9.0
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk -L/Users/user/Library/Developer/Xcode/DerivedData/[projectname]-dbcuopocesxwzyaxjpbtpqciwylm/Build/Products/Release-iphonesimulator -F/Users/user/Library/Developer/Xcode/DerivedData/[projectname]-dbcuopocesxwzyaxjpbtpqciwylm/Build/Products/Release-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -filelist /Users/user/Library/Developer/Xcode/DerivedData/[projectname]-dbcuopocesxwzyaxjpbtpqciwylm/Build/Intermediates.noindex/[projectname].build/Release-iphonesimulator/[projectname]Tests.build/Objects-normal/x86_64/[projectname]Tests.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -mios-simulator-version-min=9.0 -dead_strip -bundle_loader /Users/user/Library/Developer/Xcode/DerivedData/[projectname]-dbcuopocesxwzyaxjpbtpqciwylm/Build/Products/Release-iphonesimulator/[projectname].app/[projectname] -Xlinker -object_path_lto -Xlinker /Users/user/Library/Developer/Xcode/DerivedData/[projectname]-dbcuopocesxwzyaxjpbtpqciwylm/Build/Intermediates.noindex/[projectname].build/Release-iphonesimulator/[projectname]Tests.build/Objects-normal/x86_64/[projectname]Tests_lto.o -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -ObjC -lc++ -lstdc++ -framework JavaScriptCore -framework XCTest -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/user/Library/Developer/Xcode/DerivedData/[projectname]-dbcuopocesxwzyaxjpbtpqciwylm/Build/Intermediates.noindex/[projectname].build/Release-iphonesimulator/[projectname]Tests.build/[projectname]Tests.xctest-Simulated.xcent -lPods-[projectname]Tests -Xlinker -dependency_info -Xlinker /Users/user/Library/Developer/Xcode/DerivedData/[projectname]-dbcuopocesxwzyaxjpbtpqciwylm/Build/Intermediates.noindex/[projectname].build/Release-iphonesimulator/[projectname]Tests.build/Objects-normal/x86_64/[projectname]Tests_dependency_info.dat -o /Users/user/Library/Developer/Xcode/DerivedData/[projectname]-dbcuopocesxwzyaxjpbtpqciwylm/Build/Intermediates.noindex/[projectname].build/Release-iphonesimulator/[projectname]Tests.build/Objects-normal/x86_64/[projectname]Tests

Undefined symbols for architecture x86_64:
"_RCTSetLogFunction", referenced from:
-[[projectname]Tests testRendersWelcomeScreen] in [projectname]Tests.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

React Native version:
System:
OS: macOS High Sierra 10.13.6
CPU: (8) x64 Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz
Memory: 2.07 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.0 - /usr/local/bin/node
Yarn: 1.3.2 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.0
System Images: android-24 | Google Play Intel x86 Atom
IDEs:
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.4 => 0.60.4
npmGlobalPackages:
react-native-cli: 2.0.1
react-native: 0.57.5

Steps To Reproduce

  1. Generate a project (react-native init test).
  2. Open the workspace on Xcode, change the scheme to release and press cmd + b to build.
Bug Stale

Most helpful comment

@brunojs02 this issue seems to happen if you create a new RN project on > 0.60.

It will be solved once #25751 lands, but in the meanwhile you can apply the following changes to your /ios/{appname}Tests/{appname}Tests.m to make it work.

All 18 comments

Has to do with your code stripping. Turn that off.

How can i do that?

What version of Xcode are you using? Could possibly be fixed by updating to 10.3.

EDIT: can confirm upgrading to 10.3 works.

@wenq1 when I turned off works, what are the consequences of that?

@Echelpoel I can't update Xcode, it is limited to 10.1

@brunojs02 this issue seems to happen if you create a new RN project on > 0.60.

It will be solved once #25751 lands, but in the meanwhile you can apply the following changes to your /ios/{appname}Tests/{appname}Tests.m to make it work.

What the diference between turn off code stripping and following changes?

The change above will be the "official" one once it lands in a new version of RN.
Code stripping reduces the bundle size, so I will keep it on if possible.

I'm facing this issue with 60.5...

The same issue with 60.5. The fix https://github.com/facebook/react-native/issues/25911#issuecomment-517941867 removed 2 of 3 errors (undefined symbols _RCTSetLogFunction and RCTDefaultLogFunction ), but it I am still getting an error for RCTSharedApplication.

@mxs17 turn code stripping off, it's works

@mxs17 How to turn off code stripping? What do you mean? Please explain

@roots-ai In Xcode, Command+1, select your project, go to Build Settings on the right, filter by 'strip' using Search input. I saw the recommendation to switch 'Dead code stripping' in Linking section to 'No' for Release. It did not work for me, so I unsuccessfully experimented with all the parameters on this tab, and moved my code to a newly created project. (Probably, something was broken in a different place.)

@mxs17 Thanks for your reply

Same issue for me, "react-native": "0.60.5",

Same issue for me, "react-native": "0.60.5",

Are you resolved this problem?
I have this for debug build

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

Was this page helpful?
0 / 5 - 0 ratings