Continous Integretion for Unity

起因

  • 公司有 Unity 專案,需輸出 iOS project 並打包成 ipa 的需求,ipa 有可能是Enterprise program(for BU 測試用),以及 Developer program(上架到 AppStore)

  • 測試期間常重複上述建置動作,相當繁瑣且耗時,思考將流程自動化

建置流程如下

  1. Unity build iOS project

  2. Set iOS project configure, Such as Code sign, Provision Profile, Build Settings etc

  3. Export ipa for Enterprise or Appstore

Unity build iOS project

  • Unity 有 API 專門在處理 iOS Build,先將 Builder.cs 和 XcodeProjectConfigurator.cs 這兩個檔案放到 Unity 專案下的 Assets/Editor裡

  • 進行指令輸出,這邊要注意的是 -projectPath,Folder名稱不能有空白

    /Applications/Unity/Unity.app/Contents/MacOS/Unity \
    -projectPath "/path/to/your/Product" \
    -quit \
    -batchmode \
    -executeMethod "Builder.BuildiOS"
  • 輸出過程不順利,遇到 Plugins coliding with each other 的錯誤訊息,更慘的是第一時間完全沒有 Console 可以看 log~Or2,好在有 log 檔,在 ~/Library/Logs/Unity/Editor.log

  • 查到關鍵的錯誤訊息,解決方法是去調整該檔的 plugin settings,把OS改成OSX就可以了,x64和x86下的VuforiaWrapper.dll都要調

Set iOS project configure

  • Builder.cs 負責 Unity 建置 iOS 專案,在這個檔案裡我額外加了一個設定,把 AutomaticSigning 的功能關掉

  • XcodeProjectConfigurator.cs 在 Build 完之後,針對 iOS build property 進行設定,例如Code Sign 和 Provision_Profile

Export ipa for Enterprise or Appstore

Last updated

Was this helpful?