xcode ld:为 iOS 模拟器构建,但与 dylib 链接?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23092201/
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
ld: building for iOS Simulator, but linking against dylib?
提问by Pau Senabre
I'm having a issue compiling my app for Simulator. In the device runs perfectly but once I tried it to compile in simulator I get the following error:
我在为模拟器编译我的应用程序时遇到问题。在设备中运行完美,但是一旦我尝试在模拟器中编译它,我就会收到以下错误:
ld: building for iOS Simulator, but linking against dylib built for MacOSX file '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest' for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I checked before posting this question, but the answers I found in stackoverflow, like to run this,
我在发布这个问题之前检查过,但是我在stackoverflow中找到的答案,喜欢运行这个,
export PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xct?oolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH
or
或者
The problem was that Xcode 5 replaces gcc with clang and adds in a "-triple" option that specifies OSX as the target. If you pass "-miphoneos-version-min=7.0" on both gcc command lines it works. You can see the clang command line if you pass "--verbose" to gcc. It's also necessary to add to the PATH for Xcode 5 so that cmake can find the necessary tools: export PATH=/Applications/Xcode5-DP6.app/Contents/Developer/Toolchains/XcodeDefault.xct??oolchain/usr/bin:/Applications/Xcode5-DP6.app/Contents/Developer/usr/bin:$PATH None of this is official.. but works for me so far.
问题是 Xcode 5 用 clang 替换了 gcc 并添加了一个“-triple”选项,将 OSX 指定为目标。如果在两个 gcc 命令行上都传递“-miphoneos-version-min=7.0”,它就可以工作。如果将“--verbose”传递给 gcc,您可以看到 clang 命令行。还需要添加到 Xcode 5 的 PATH 中,以便 cmake 可以找到必要的工具:export PATH=/Applications/Xcode5-DP6.app/Contents/Developer/Toolchains/XcodeDefault.xct??oolchain/usr/bin:/ Applications/Xcode5-DP6.app/Contents/Developer/usr/bin:$PATH 这些都不是官方的..但到目前为止对我有用。
I dont really understand how to to do this. Any help, please?
我真的不明白如何做到这一点。请问有什么帮助吗?
回答by Ossir
Check Build Settings
for your test target. This values should look similar:
检查Build Settings
您的测试目标。这个值应该看起来相似:
If you have any escaped symbol, consider to fix it. I had here : \"
. I just removed them
如果您有任何转义符号,请考虑修复它。我在这里:\"
。我刚刚删除了它们
Also notice: order is important!
还要注意:顺序很重要!
P.S. from GraehamFIt's always a good thing to Build -> Clean
and restart Xcode, so the changes to take affect
来自 GraehamF的PSBuild -> Clean
重新启动 Xcode总是一件好事,因此更改才会生效
回答by aUser
When I faced this error with an XCode project, I open the file ???.xcodeproj
(in a SubLime Text editor)and removed the below lines. The warning will no longer be there!
当我在 XCode 项目中遇到此错误时,我打开文件???.xcodeproj
(在 SubLime 文本编辑器中)并删除了以下几行。警告将不再存在!
LIBRARY_SEARCH_PATHS = (
"\"${PROJECT_DIR}/../../../../../usr/lib\"/**",
"\"${PROJECT_DIR}/../../../../../usr/lib\"/**",
);