[iOS] Scheme 设置为 Release 时 编译失败 Undefined symbol: _RCTSetLogFunction

React Native 2020-03-30 阅读 81 评论 0

问题描述

React Native 0.60 升级到 0.61,Scheme 为 Debug 时,编译没有出错,当准备发布,改成 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

解决方法

找到有2种方法可以解决。

1. 设置 Dead Code Stripping 为 NO

在 Xcode 中,依次选择 PROJECT -> Build Settings -> LInking -> Dead Code Stringpping,设置为 NO,然后重新编译。

2. 修改 Tests.m 代码

参考 https://github.com/facebook/react-native/pull/25751/files,修改 Tests 项目的 Tests.m 文件代码。

最后更新 2020-03-30
MIP.watch('startSearch', function (newVal, oldVal) { if(newVal) { var keyword = MIP.getData('keyword'); console.log(keyword); // 替换当前历史记录,新增 MIP.viewer.open('/s/' + keyword, {replace: true}); setTimeout(function () { MIP.setData({startSearch: false}) }, 1000); } }); MIP.watch('goHome', function (newVal, oldVal) { MIP.viewer.open('/', {replace: false}); });