解決iOS工程被Xcode識別成Mac工程的問題

[題外介紹:其實本宅也是一名程序員,各種經(jīng)驗和問題總結(jié)也不少,只是工作比較忙,很少在網(wǎng)上發(fā)文。本著互聯(lián)分享精神,但各種網(wǎng)站賬號太多,不一一發(fā)了]

首先,這種問題一般出現(xiàn)在拷貝工程到另一臺Mac上,用Xcode打開后,發(fā)現(xiàn)沒法運行:Xcode竟然把它識別成Mac工程了,target在Xcode上的device選項竟然只有My Mac 64-bit”,能編譯才怪呢!而拷回到原Mac上打開編譯,運行正常,當(dāng)前Mac打開其他工程也是正常的!

那么,是什么導(dǎo)致工程被Xcode識別出錯呢?Xcode的bug我們這里就不說了,檢查發(fā)現(xiàn)項目工程的.xcodeproj文件,在查看內(nèi)容時(通常有三個:project.pbxproj, project.xcworkspace和xcuserdata文件夾)。xcuserdata里面有在不同Mac上打開后產(chǎn)生的緩存文件,這時候肯定有與之前Mac上編譯相關(guān)的緩存文件,當(dāng)前Xcode不能正常識別它,這也是問題所在!

解決方法,關(guān)閉工程,查看.xcodeproj文件里的內(nèi)容,刪除xcuserdata文件夾;重新打開項目工程,重新看到device列表里出現(xiàn)iPhone真機和模擬器了!command+shift+K清理一下,然后編譯、運行。OK,應(yīng)該沒事了,Xcode在運行程序時會自動根據(jù)配置信息重新生成xcuserdata文件的。

說明:英文好的話,你可以了解一下xcuserdata:說明:

project.xcworkspace說明:

? ? ? is a directory of files describing the workspace or projects. Although some of the answers here indicate it is unnecessary and should be ignored for source control, I don't agree, but it's going to be highly dependent upon how you use your environment. Generally, the contents of the project.xcworkspace directory contains the contents.xcworkspace data file, which lists the projects that are included as top-level entities in your project。

xcuserdata說明:You can safely delete the xcuserdata directories. It basically contains personal settings like breakpoints, user interface layout, open files, automatic snapshots configuration and so on。

結(jié)論:

an xcuserdata directory, which contains each user's settings (should be ignored for source code controL), and xcshareddata, which is data shared by users who share a project, and should be under source control.

in environments where you don't share workspaces, or where you use simple workspaces, you can ignore these as well, however in environments where you put related projects in the same workspace and share that configuration, you may well want to keep these.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的閱讀 13,643評論 5 6
  • App Programming Guide for iOS翻譯 https://developer.apple.c...
    鋼鉄俠閱讀 1,248評論 0 1
  • 神話是以故事的形式表達遠古人民對自然、社會現(xiàn)象的認(rèn)識和愿望,是“通過人民的幻想用一種不自覺的藝術(shù)形式加工過的自然和...
    真縝閱讀 2,300評論 0 4
  • 生活中每個人都會有各種各樣的選擇,我常常在想到底是我選擇了生活,還是生活選擇了如今這樣子的我,可笑的我或許...
    cherry1942閱讀 442評論 0 0
  • 最近晚上經(jīng)常刷微博,才發(fā)現(xiàn)之前一直被自己鄙視的微博原來可以這么好玩。各種好玩的段子,搞笑的視頻,可愛的小孩子。讓笑...
    楠苜閱讀 348評論 4 1

友情鏈接更多精彩內(nèi)容