微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ld:当 lib 存在于 .../BuildProductsPath/Debug-iphoneos/Amplitude 时,找不到 -lAmplitude 的库

如何解决ld:当 lib 存在于 .../BuildProductsPath/Debug-iphoneos/Amplitude 时,找不到 -lAmplitude 的库

在命令行中使用 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.alibPods-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。

  1. -l"振幅"
  2. -l"amplitude-react-native"

linker flags

解决方法

更改此设置 -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;

我还必须:

  1. 更新对 iOS 11 的最低支持
  2. 将链接器标志设置为 ONLY ${inhereted}
  3. Build Active Architecture Only 设置为 YES

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。