问题描述
在命令行中使用 xcodebuild
构建我的应用程序时,我不断收到此错误。
xcodebuild -workspace ios/APP_NAME.xcworkspace -scheme APP_NAME clean archive -sdk iphoneos -configuration Debug -UseModernBuildSystem=NO -archivePath $PWD/APP_NAME CODE_SIGNING_ALLOWED=NO;
该应用程序通过 Xcode UI 构建得很好。这是一个 React Native 应用程序,我尝试了此处列出的一系列方法 - Xcode - ld: library not found for -lPods,但均无效。
- 为 Pod 和应用项目设置相同的部署目标
- 从应用项目的 Frameworks 文件夹中删除
libAmplitude.a
- 将
Build Active Architecture Only
设置为 NO - 将
libAmplitude.a
与libPods-APP_NAME.a
一起嵌入
奇怪的是,它找不到的文件实际上存在于目录中。我看到了两次这种类型的失败(arm64、armv7)。
ld: warning: directory not found for option '-L-L/Users/Parth/Library/Developer/Xcode/DerivedData/APP_NAME-atzumsqdaojeyaaukpzreucvvlja/Build/Intermediates.noindex/ArchiveIntermediates/APP_NAME/BuildProductsPath/Debug-iphoneos/Amplitude'
ld: library not found for -lAmplitude
clang: error: linker command Failed with exit code 1 (use -v to see invocation)
最终构建失败:
The following build commands Failed:
Ld /Users/Parth/Library/Developer/Xcode/DerivedData/APP_NAME-atzumsqdaojeyaaukpzreucvvlja/Build/Intermediates.noindex/ArchiveIntermediates/APP_NAME/IntermediateBuildFilesPath/APP_NAME.build/Debug-iphoneos/APP_NAME.build/Objects-normal/arm64/APP_NAME normal arm64
Ld /Users/Parth/Library/Developer/Xcode/DerivedData/APP_NAME-atzumsqdaojeyaaukpzreucvvlja/Build/Intermediates.noindex/ArchiveIntermediates/APP_NAME/IntermediateBuildFilesPath/APP_NAME.build/Debug-iphoneos/APP_NAME.build/Objects-normal/armv7/APP_NAME normal armv7
(2 failures)
问题提交幅度 - https://github.com/amplitude/Amplitude-ReactNative/issues/87
编辑
这可能是问题的根本原因,将 other linker flags
更改为 ${inherited}
后,我看到 2 处提到了 Amplitude。
- -l"振幅"
- -l"amplitude-react-native"
解决方法
更改此设置 -UseModernBuildSystem=YES
后,我开始工作了。
xcodebuild -workspace ios/APP_NAME.xcworkspace -scheme APP_NAME clean archive -sdk iphoneos -configuration Debug -UseModernBuildSystem=YES -archivePath $PWD/APP_NAME CODE_SIGNING_ALLOWED=NO;
我还必须:
- 更新对 iOS 11 的最低支持
- 将链接器标志设置为 ONLY
${inhereted}
- 将
Build Active Architecture Only
设置为YES
。