Error for iOS

weixin_33866037發表於2018-06-28

Error 1:

[WARN]Warning: Multiple build commands for output file /Developer/xxx/xxx.xxx
or
Error: Multiple commands produce '/Users/xxx/Library/Developer/Xcode/DerivedData/xxx-azkpjshzmzhpaeaegtxmlgrewbpt/Build/Products/Debug-iphoneos/xxx.app/Info.plist':
1) Target 'xxx' has copy command from '/Users/xxx/Documents/xxx/SupportingFiles/Info.plist' to '/Users/xxx/Library/Developer/Xcode/DerivedData/xxx-azkpjshzmzhpaeaegtxmlgrewbpt/Build/Products/Debug-iphoneos/xxx.app/Info.plist'
2) Target 'xxx' has process command with input '/Users/xxx/Documents/xxx/SupportingFiles/Info.plist'

解決方法:

In the Project Navigator, select your Xcode Project file. This will show you the project settings as well as the targets in the project. Look in the "Copy Bundle Resources" Build Phase. You should find the offending files in that list twice. Delete the duplicate reference.
Xcode is complaining that you are trying to bundle the same file with your application two times. stack overflow

選中Target,選Build Phase,在Copy Bundle Resources中刪除重複的檔案,如果發現檔案並沒有重複,可以先把檔案刪除,clean一下,然後問題就解決了~ 後面也可以刪除的檔案在加回去。如果是重複檔案的話就可以不用加回去了。

Error 2:

今天在使用cocoaPods的時候,發現報錯了,如下:


293993-aa64a140c37409d3.png
1
293993-20b01e91e760a9fc.png
2
293993-752ef73d883c8eff.png
3
293993-75be1c8dcdb5ecde.png
4
293993-d5cd26defcdfe31d.png
5

解決辦法:
照著後面給出的解決辦法連結,就可以找到解決辦法。是因為我剛剛建立的專案用的是Xcode9.4.1版本建立的,所以專案的Project Document下面的Project Format是Xcode 9.3-compatible,把這個設定改為9.3以下的就OK了~

首先選中當前專案檔案

293993-74151b9401f188e4.png
解決1
293993-e521a68d7b4494fe.png
解決2

Error 3:

昨天看了一下部落格,今天心血來潮想寫個簡單的macOS app,用Swift寫,在pod一些框架的時候,首先是遇到了上面Error 2的錯誤,改正之後,就是下面的錯誤了。

 The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.

解決辦法:Project ► (Select Your Project Target) ► Build Settings ► (Type 'swift' in Searchbar) Swift Compiler Language ► Swift Language Version ► Click on Language list to open it.

Xcode 9 Swift Language Version (SWIFT_VERSION) - Stack Overflow

Error 4:

今天該死的和同事合併程式碼報錯
_OBJC_IVAR_$_BDConversationCell._userNameLabel in: 某路徑
該錯誤是一種連結錯誤,Xcode不會直接定位到問題具體位置。

但其仍有一定的規律,大概是以下原因:
1.檢查是否誤匯入了問題中類的 .m 檔案;
報錯:

duplicate symbol _OBJC_IVAR_$_TestViewController._button in: /Users/Kingdev/Library/Developer/Xcode/DerivedData/測試OC-eluxicnvoptnsgcghlsslvbpkzzm/Build/Intermediates/測試OC.build/Debug-iphonesimulator/測試OC.build/Objects-normal/x86_64/ViewController.o /Users/Kingdev/Library/Developer/Xcode/DerivedData/測試OC-eluxicnvoptnsgcghlsslvbpkzzm/Build/Intermediates/測試OC.build/Debug-iphonesimulator/測試OC.build/Objects-normal/x86_64/TestViewController.o
ld: 3 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

原因:

293993-74261e6e36c63ec5.png
image

2.專案中是否存在同名的檔案 [①多人協作開發導致project檔案合併衝突 ②自己檔案與三方中檔案重名了]

報錯:

ld: 3 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

原因:

293993-be33d7e3fef6ecf9.png
image

若在專案中搜尋中搜尋發現,不存在同名的檔案,就可判斷出不是問題2。基本上就是問題3了。
3.在 TARGETS ——> Build Phases ——> Compiles Sources,看看出現問題的類是不是有重複的或路徑出現了問題。多人協作開發時就容易出現這種問題,project檔案衝突導致的。

解決:直接搜尋出現錯誤的檔名,會發現有兩個這個m檔案,直接刪除一個即可。

duplicate symbol _OBJC_IVAR

慢慢來,一步一個巴掌印~~~

持續更新。。。。

相關文章