Table of contents

[iOS] When scheme is Release, Undefined symbol: _RCTSetLogFunction

Objective C Apr 01, 2020 Viewed 365 Comments 0

Question

Upgrade React Native 0.60 to 0.61. When Scheme is set to Debug, it runs without problems. An error is reported when set to Release.

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

Undefined symbol: _RCTSetLogFunction

Solution

I found 2 ways to solve it.

1. Set Dead Code Stripping to NO

In Xcode, select PROJECT-> Build Settings-> LInking-> Dead Code Stringpping, set it to NO, and recompile.

Set Dead Code Stripping to NO

2. Modify Tests.m code

Refer to https://github.com/facebook/react-native/pull/25751/files. Change the Tests.m file code of the Tests project

Change the Tests.m file code of the Tests project

Updated Apr 01, 2020