开发者

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

开发者 https://www.devze.com 2023-03-30 14:50 出处:网络
Starting from some point in the past xCode 4 in complain开发者_如何学Going about linker problems:

Starting from some point in the past xCode 4 in complain开发者_如何学Going about linker problems:

ld: warning: building for MacOSX, but linking against dylib built for iOS: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks//CoreGraphics.framework/CoreGraphics

I have checked everything but still nothing suspicious in the config and it compiles and runs. The only thing that I see it is double slashes before CoreGraphics.framework, why I do not know. Tried remove and add again library on "Build phases" that did not help.


Sometimes it's easier to debug Xcode problems by looking at the build log for the command lines it's using.

If you're building from the command line, you can get that message if you don't specify -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)


Check your Framework Search Paths for your Main target and your test Target.

I had a lot of crap in mine.

had old project written in XCode 4 and just started to use Unit Tests in XCode 5.

Here's the minimum I have to get my test project to run

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

Note: If you drag a framework into XCode. XCode 5 has bad habit of hardcoding the path

/Users/gbxc/Documents/my_project

should be

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

so if you moved your project might get problems

Best way to check whats correct is to create a new single view project that runs tests ok.

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


If you're using Carthage and compiling a Mac app, search on your project's Framework Search Paths you might find something like $(PROJECT_DIR)/Carthage/Build/iOS.

Removing that fixed my issue.


This issue is due to include a wrong framework version in Xcode. The project is built for Mac OS X, but it uses iOS version's framework.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号