2011-08-24 24 views
25

從過去的Xcode 4的某一點開始建造dylib:蘋果Mach-O的連接(ID)警告:建設MacOSX的,但抱怨連接問題鏈接針對於iOS

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

我已經檢查過了但仍然沒有可疑的配置,它編譯和運行。 我唯一看到的是CoreGraphics.framework之前的雙斜槓,爲什麼我不知道。試圖刪除並再次添加庫「建設階段」,沒有幫助。

回答

-3

此問題是由於在Xcode中包含錯誤的框架版本。該項目是爲Mac OS X構建的,但它使用iOS版本的框架。

5

有時,通過查看它所使用的命令行的構建日誌來調試Xcode問題會更容易。

如果你在命令行建設,就可以得到該消息,如果你不指定-miphoneos版本分鐘=

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) 
+0

這就解決了我的問題,有我的美味upvote。 – Gui13

+4

在Xcode項目中添加這些thnigs的位置?我正在從Xcode編譯,而不是從命令行編譯...這是我得到的錯誤 ** ld:爲iOS模擬器構建,但鏈接爲爲MacOSX文件構建的dylib'/usr/lib/libSystem.B .dylib'for architecture i386 clang:錯誤:連接器命令失敗,退出代碼1(使用-v查看調用)** 在_Other連接器Flat_節中有一個libSystem.B.dylib條目..但刪除它不能解決問題。 – Ans

4

檢查框架搜索路徑,你的主要目標和你的測試目標。

我有很多垃圾在我的。

不得不寫的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. 
+0

更改* Tests目標中的搜索框架順序爲我解決了它。確保$(繼承)不在「$(SDKROOT)/ Developer/Library/Frameworks」之前。 – Marius

0

如果您使用迦太基和編譯Mac應用程序,搜索項目的Framework Search Paths你可能會發現類似$(PROJECT_DIR)/Carthage/Build/iOS

刪除,解決了我的問題。