如何解决应用程序中测试目标的 Xcode 链接器警告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35754326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Resolve Xcode Linker Warnings For Tests Target in App
提问by JeffB6688
The solution offered in Apple LLVM 6.0 Error: clang failed with exit code -1may work to resolve this problem, but as I stated at the end of my problem statement is that I did not want to remove the Tests target unless that is the only solution. So, is there another solution?
Apple LLVM 6.0 Error: clang failed with exit code -1 中提供的解决方案可能可以解决此问题,但正如我在问题陈述末尾所述,我不想删除测试目标,除非这是唯一的解决方案。那么,还有其他解决方案吗?
When trying to build a new app in Xcode, I am getting a ton of linker warnings. The warnings are related to a target that was automatically created called Tests. The expanded view of some of the warnings look like the following:
尝试在 Xcode 中构建新应用程序时,我收到了大量链接器警告。这些警告与自动创建的名为 Tests 的目标相关。一些警告的扩展视图如下所示:
Ld /Users/me/Library/Developer/Xcode/DerivedData/My_App-ahfusfuifhsybmalxaykbmfrhylc/Build/Products/Debug-iphoneos/My\ AppTests.xctest/My\ AppTests normal arm64
cd "/Users/me/iPhone Apps/myProducts/My App"
. . .
ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/Developer/Library/Frameworks'
and
和
GenerateDSYMFile /Users/me/Library/Developer/Xcode/DerivedData/My_App-ahfusfuifhsybmalxaykbmfrhylc/Build/Products/Debug-iphoneos/My\ AppTests.xctest.dSYM /Users/me/Library/Developer/Xcode/DerivedData/My_App-ahfusfuifhsybmalxaykbmfrhylc/Build/Products/Debug-iphoneos/My\ AppTests.xctest/My\ AppTests
cd "/Users/me/iPhone Apps/myProducts/My App"
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/me/Library/Developer/Xcode/DerivedData/My_App-ahfusfuifhsybmalxaykbmfrhylc/Build/Products/Debug-iphoneos/My\ AppTests.xctest/My\ AppTests -o /Users/me/Library/Developer/Xcode/DerivedData/My_App-ahfusfuifhsybmalxaykbmfrhylc/Build/Products/Debug-iphoneos/My\ AppTests.xctest.dSYM
while processing /Users/me/Library/Developer/Xcode/DerivedData/My_App-ahfusfuifhsybmalxaykbmfrhylc/Build/Intermediates/My App.build/Debug-iphoneos/My AppTests.build/Objects-normal/arm64/My_AppTests.o:
warning: /Users/me/Library/Developer/Xcode/DerivedData/ModuleCache/3K6537SSXYD4O/UIKit-2LM3EQU7VVY4O.pcm: No such file or directory
...
warning: Could not resolve external type c:objc(cs)XCTestCase
...
warning: Could not resolve external type c:objc(cs)_XCTestCaseInterruptionException
What can I do to eliminate these warnings? Since I don't really understand how to use test cases yet, I'd rather not delete the target (but if that is the only option, I will).
我该怎么做才能消除这些警告?由于我还不太了解如何使用测试用例,我宁愿不删除目标(但如果这是唯一的选择,我会这样做)。
回答by lucianoenrico
For these messages:
对于这些消息:
warning: Could not resolve external type c:objc(cs) xXX
The problem happens when you have a Xcode 6 project updated to 7. The short answer is to change the Debug Information Format to "DWARF", on the target, for the Debug configuration only.
当您将 Xcode 6 项目更新为 7 时,问题就会发生。简短的回答是将目标上的调试信息格式更改为“DWARF”,仅用于调试配置。
- Go to Build Settings and search for Debug Information Format
- Change the Debug setting from "DWARF with dSYM File" to "DWARF"
- Leave the Release setting at "DWARF with dSYM File"
- 转到构建设置并搜索调试信息格式
- 将调试设置从“DWARF with dSYM File”更改为“DWARF”
- 将 Release 设置保留在“DWARF with dSYM File”
This is safe because you don't need dSYM files for Debug builds
这是安全的,因为您不需要用于调试构建的 dSYM 文件