Open CCRogerWang opened 7 years ago
[iOS] unknown: Encountered an unknown error (757: unexpected token at '2018-04-26 12:47:33.830 simctl[92572:914929] CoreSimulator detected Xcode.app relocation or CoreSimulatorService version change. Framework path (/Applications/Xcode/Xcode_8.3.3.app/Contents/Developer/Library/PrivateFrameworks/CoreSimulator.framework) and version (375.21) does not match existing job path (/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/XPCServices/com.apple.CoreSimulator.CoreSimulatorService.xpc) and version (494.33). Attempting to remove the stale service in order to add the expected version. ') during validation.
可能是因為有多個xcode在電腦裡,使用:
xcode-select -s [Xcode的完整路徑]
就解決了。
事前準備
請安裝CocoaPods, 並且更新到最新版本。
開始 - Create Development pod
使用 pod lib create [Library name]
輸入完後稍等一下會出現幾個問題需要填寫,如圖示。
等pod跑完後會自動開啟Xcode。 來看一下目錄結構:
來做一個Lib
首先新增一個Swift檔案在classes的資料夾,命名為foo.swfit。
這是一個class包含一個class func fooPrint。
}
Done!現在跑一下程式,出現foo。
如何更新
來新增一個function,打開foo.swift,加上以下的程式碼。
再回到ViewController.swift,修改一下。
看一下Xcode,會報錯是正常的。
做完pod install後,build & run,會看到
foo
fooShow
就成功了,到目前為止是Create Development Pods的教學。
把MyLib丟到Github
略~
在Github產生一個新的spec (存放podspecs)
在github產生一個demo-roger-specs
上傳到github,這個資料夾就可以砍了
在CocoaPods新增自己的spec
CocoaPodsp會把這個spec複製一份到 "~/.cocoapods/repos" 裡面
編輯podspec
回到MyLib.podspec
s.summary,s.description盡量寫,description一定要比summary長。
必要修改的欄位:
s.homepage = 'https://github.com/demo-MyLib'
s.source = 'git@github.com:demo-MyLib.git'
因為不開源
s.license = 'MIT' -> 'proprietary'
另外LICENSE檔案也要改掉,輸入
接下來驗證podspec是否正確
Cocoapods會因為一些無關痛癢的warnings造成驗證失敗,因為是要自己用,所以加入 --allow-warnings 略過。
將MyLib連結到私有庫
測試通過後,需要先在MyLib打上tag。
再把MyLib連結到剛剛建立的私有庫。
安裝Private Pod
指定private spec的位置,就是demo-roger-specs的位置,再把private pod加到專案的Podfile
更新Private Pod
依照上述的步驟,新增一個function:fooUpdate(),並且把ReplaceMe.swift刪掉。
測試
開啟terminal run pod update。
打開專案,可以看到裡面的ReplaceMe.swift已經不見,而且多了一個fooUpdate function。
刪除private spec