我是否必须在 Xcode 11.5 中手动设置框架路径?



我有一个自定义框架,我想在我的Xcode项目中使用它。我可以轻松地将其添加到我的项目中,方法是单击"框架、库和嵌入式内容"中的"+"按钮,然后选择"添加其他..."。

但是,当我尝试构建我的项目时,Xcode 抱怨它找不到框架。这并不奇怪,因为显然 Xcode 不会将框架的路径传递给链接器。框架的路径是/Users/Andreas/TestFramework.如您所见,Xcode 根本没有将此路径传递给ld

Ld /Users/andreas/Library/Developer/Xcode/DerivedData/MyApp-csdbiydhibfjqcdvbmzzinqjghgj/Build/Intermediates.noindex/MyApp.build/Release-iphonesimulator/MyApp.build/Objects-normal/x86_64/Binary/MyApp normal x86_64 (in target 'MyApp' from project 'MyApp')
cd /Users/andreas/Documents/MyApp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-ios8.0-simulator -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk -L/Users/andreas/Library/Developer/Xcode/DerivedData/MyApp-csdbiydhibfjqcdvbmzzinqjghgj/Build/Products/Release-iphonesimulator -F/Users/andreas/Library/Developer/Xcode/DerivedData/MyApp-csdbiydhibfjqcdvbmzzinqjghgj/Build/Products/Release-iphonesimulator -filelist /Users/andreas/Library/Developer/Xcode/DerivedData/MyApp-csdbiydhibfjqcdvbmzzinqjghgj/Build/Intermediates.noindex/MyApp.build/Release-iphonesimulator/MyApp.build/Objects-normal/x86_64/MyApp.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/andreas/Library/Developer/Xcode/DerivedData/MyApp-csdbiydhibfjqcdvbmzzinqjghgj/Build/Intermediates.noindex/MyApp.build/Release-iphonesimulator/MyApp.build/Objects-normal/x86_64/MyApp_lto.o -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/andreas/Library/Developer/Xcode/DerivedData/MyApp-csdbiydhibfjqcdvbmzzinqjghgj/Build/Intermediates.noindex/MyApp.build/Release-iphonesimulator/MyApp.build/MyApp.app-Simulated.xcent -framework TestFramework -Xlinker -dependency_info -Xlinker /Users/andreas/Library/Developer/Xcode/DerivedData/MyApp-csdbiydhibfjqcdvbmzzinqjghgj/Build/Intermediates.noindex/MyApp.build/Release-iphonesimulator/MyApp.build/Objects-normal/x86_64/MyApp_dependency_info.dat -o /Users/andreas/Library/Developer/Xcode/DerivedData/MyApp-csdbiydhibfjqcdvbmzzinqjghgj/Build/Intermediates.noindex/MyApp.build/Release-iphonesimulator/MyApp.build/Objects-normal/x86_64/Binary/MyApp
ld: framework not found TestFramework
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我知道我可以通过在构建选项中的某处添加框架的路径来轻松解决此问题,但是 Xcode 真的需要这个吗?

必须为我使用的每个自定义框架添加路径将非常麻烦。Xcode可以很容易地自动做到这一点。那么真的有必要将框架的路径显式添加到我的 Xcode 项目中,还是我在这里做错了什么?

为了回答我自己的问题,我能够通过将我的应用程序所需的自定义框架复制到我的应用程序的项目目录来解决此问题。然后错误消失了。

可以通过将自定义框架拖放到我的 Xcode 项目的Frameworks部分,然后在随后的 Xcode 对话框中选择Copy items if needed来让 Xcode 自动执行此操作。

最新更新