繁体   English   中英

Apple Mach-O链接器(id)警告:为MacOSX构建,但是针对为iOS构建的dylib进行链接

[英]Apple Mach-O linker (id) warning : building for MacOSX, but linking against dylib built for iOS

从过去xCode 4中的某个点开始抱怨链接器问题:

ld:warning:为MacOSX构建,但是针对为iOS构建的dylib链接:/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks//CoreGraphics.framework/CoreGraphics

我已经检查了所有内容,但在配置中仍然没有任何可疑,它编译并运行。 我看到它唯一的东西是CoreGraphics.framework之前的双斜线,为什么我不知道。 尝试删除并在“构建阶段”上再次添加库,但没有帮助。

有时,通过查看正在使用的命令行的构建日志来调试Xcode问题会更容易。

如果从命令行构建,如果未指定-miphoneos-version-min ,则可以获取该消息

This compiles:
(where conftest.c just contains int main() {})
/Applications/Xcode5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 --sysroot /Applications/Xcode5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk --sysroot /Applications/Xcode5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk -miphoneos-version-min=6.0 conftest.c

And this gives the error:
/Applications/Xcode5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 --sysroot /Applications/Xcode5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk --sysroot /Applications/Xcode5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk  conftest.c
ld: building for MacOSX, but linking against dylib built for iOS Simulator file '/Applications/Xcode5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/usr/lib/libSystem.dylib' for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

检查主要目标和测试目标的框架搜索路径。

我的手里有很多垃圾。

有旧项目用XCode 4编写,刚刚开始在XCode 5中使用单元测试。

这是我必须让我的测试项目运行的最低要求

Project Navigator > click on project at top >
Targets > Build Settings > Framework Search Paths

TARGET:my_project
$(inherited)
"$(SRCROOT)"
"$(SRCROOT)/my_project"

TEST:my_projectTests
"$(SDKROOT)/Developer/Library/Frameworks"    <<XCTest.framework is here
"$(DEVELOPER_LIBRARY_DIR)/Frameworks"
"$(SRCROOT)/.."
"$(SRCROOT)"                             << Documents/my_project
"$(SRCROOT)/my_project"                  << Documents/my_project/my_project

where directory structure is
Documents/my_project
    my_project.xcodeproj
    /my_project

注意:如果将框架拖到XCode中。 XCode 5有养成硬编码路径的坏习惯

/Users/gbxc/Documents/my_project

应该

"$(SRCROOT)"                             << Documents/my_project
"$(SRCROOT)/my_project"                  << Documents/my_project/my_project

所以,如果你移动你的项目可能会遇到问题

检查什么是正确的最佳方法是创建一个运行测试的新单一视图项目。

Run the Test action
By default it fails but at least testing is running
then compare the  Framework Search Paths.

如果您正在使用Carthage并编译Mac应用程序,请搜索项目的Framework Search Paths您可能会发现类似$(PROJECT_DIR)/Carthage/Build/iOS

删除修复我的问题。

此问题是由于在Xcode中包含了错误的框架版本。 该项目是为Mac OS X构建的,但它使用的是iOS版本的框架。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM