之前想做持續(xù)集成,然后在電腦上安裝了Jenkins,一通操作踩了無(wú)數(shù)坑之后,持續(xù)集成沒(méi)有搞好,后面在真機(jī)上運(yùn)行工程的時(shí)候反而出現(xiàn)了報(bào)錯(cuò)。錯(cuò)誤信息如下:
CodeSign /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app
cd /Users/me/Desktop/MyAppFolder1/MyAppFolder2/MyAppxcode
export CODESIGN_ALLOCATE=/Users/me/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Users/me/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Users/me/Downloads/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Signing Identity: "iPhone Developer: My Name (**********)"
Provisioning Profile: "iOS Team Provisioning Profile: com.**********.*********"
(********-****-****-****-************)
/usr/bin/codesign --force --sign **************************************** --entitlements /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/MyApp.app.xcent --timestamp=none /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app
/Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app: resource fork, Finder information, or similar detritus not allowed
Command /usr/bin/codesign failed with exit code 1
還有這種錯(cuò)誤:
dyld: Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/AppName
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/Frameworks/libswiftCore.dylib: mmap() error 1 at
address=0x008A1000, size=0x001A4000 segment=__TEXT in Segment::map() mapping
/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/APPLICATION_NAME/Frameworks/libswiftCore.dylib
然后真機(jī)運(yùn)行的時(shí)候也不斷的要求輸入管理員賬號(hào)密碼,關(guān)鍵是一直要求輸入,正確了也不能允許運(yùn)行。
現(xiàn)在提供自己的解決方案:
1.修改證書私鑰的訪問(wèn)控制權(quán)限
由于Jenkins的原因,我對(duì)鑰匙串進(jìn)行了一定的操作。我最終確認(rèn)應(yīng)該是這種操作導(dǎo)致了上述問(wèn)題。
- 將 鑰匙串 -> 登錄 上的開發(fā)者證書拷貝到鑰匙串 -> 系統(tǒng) 中。
- 然后在系統(tǒng)下選中證書,顯示簡(jiǎn)介,信任選擇始終信任。
- 再選中系統(tǒng)下開發(fā)者證書的私鑰,顯示簡(jiǎn)介后在訪問(wèn)控制中勾選“允許所有應(yīng)用程序訪問(wèn)該項(xiàng)目”。
4.重新運(yùn)行Xcode。
但是在搜索解決辦法的過(guò)程中,我發(fā)現(xiàn)了可能還有其他操作也會(huì)導(dǎo)致這樣的問(wèn)題,所以后面是一些其他原因?qū)е碌慕鉀Q辦法。
2.升級(jí)Xcode和系統(tǒng)
如果Xcode不是最新系統(tǒng),而手機(jī)系統(tǒng)版本又比較高,升級(jí)Xcode吧。為了保險(xiǎn)起見(jiàn),系統(tǒng)也升級(jí)。這個(gè)很有用。
3.Stack Overflow上的解決方式
Stack Overflow上面有一個(gè)這個(gè)提問(wèn),里面回答非常多,可見(jiàn)不少人遇到了這樣的問(wèn)題。我先精簡(jiǎn)幾個(gè)重要的解決辦法:
清除緩存派
這種方法主要是認(rèn)為緩存原因造成的,解決方式包括:Xcode Clean、刪除DerivedData(包括ModuleCache中的)、重新生成證書、Xcode重啟、Mac重啟、iPhone重啟,保證完全的清零狀態(tài),然后解決。-
修改設(shè)置參數(shù)派
這種方法認(rèn)為是參數(shù)的影響導(dǎo)致了問(wèn)題。所以需要修改Build setting里面的參數(shù)。Embedded Content Contains Swift Code 設(shè)置成 "Always Embed Swift Standard Libraries = YES"
Runpath Search Paths 設(shè)置成 $(inherited) @executable_path/Frameworks