cd到taro项目根目录,运行yarn install
npm run dev:rn
cd 到 rn_temp目录运行,生成jsbundle,需要在rn_temp目录下新建bundle文件夹
node ../node_modules/react-native/local-cli/cli.js bundle --entry-file ./rn_temp/index.js --bundle-output ./bundle/main.jsbundle --assets-dest ./bundle --dev false --platform ios
问题记录:
1.config.h' file not found
cd node_modules/react-native/third-party/glog-0.3.4
// 第一步。找到路径,进入glog-0.3.4文件里
../../scripts/ios-configure-glog.sh
// 第2步。
2.
报错为
Unknown argument type '__attribute__' in method -[RCTAppState getCurrentAppState:error:]. Extend RCTConvert to support this type.
这个BUG是Xcode.11引起的, 可以查看这个问题的提交记录,链接为:https://github.com/facebook/react-native/issues/25138
我们只需要找到RCTModuleMethod.mm这个文件,大约在93行左右
修改
static BOOL RCTParseUnused(const char **input)
{
return RCTReadString(input, "__unused") ||
RCTReadString(input, "__attribute__((__unused__))") ||
RCTReadString(input, "__attribute__((unused))");
}
这个函数插入 RCTReadString(input, "__attribute__((__unused__))") || 这行代码重新运行就行了。
3.项目运行无误,Archive出错
Cocoapods下的第三方库libReact.a多个路径
:-1: Multiple commands produce '/Users/***/Library/Developer/Xcode/DerivedData/sentryCpush-cvpqbragxhlzloeebvyoihyauasl/Build/Intermediates.noindex/ArchiveIntermediates/sentryCpush/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libReact.a':
1) Target 'React' has a command with output '/Users/***/Library/Developer/Xcode/DerivedData/sentryCpush-cvpqbragxhlzloeebvyoihyauasl/Build/Intermediates.noindex/ArchiveIntermediates/sentryCpush/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libReact.a'
2) Target 'React' has a command with output '/Users/***/Library/Developer/Xcode/DerivedData/sentryCpush-cvpqbragxhlzloeebvyoihyauasl/Build/Intermediates.noindex/ArchiveIntermediates/sentryCpush/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libReact.a'
解决方法:
在Podfile中添加:
post_installdo|installer|
installer.pods_project.targets.eachdo|target|
# The following is needed to ensure the "archive" step works in XCode.
# It removes React & Yoga from the Pods project, as it is already included in the main project.
# Without this, you'd see errors when you archive like:
# "Multiple commands produce ... libReact.a"
# "Multiple commands produce ... libyoga.a"
targets_to_ignore = %w(React yoga)
iftargets_to_ignore.include? target.name
target.remove_from_project
end
end
end
然后 pod install
参考链接:
https://www.jianshu.com/p/804dac985411
4.react-native run-ios --simulator="iPhone 6",运行时指定启动版本
5.'React/RCTBridgeModule.h' file not found
先clean,然后Scheme 选择React 先编译,编译成功后选择项目再次编译
网友评论