📂
JackyChen的精神時光屋
  • About
  • iPlayground
    • iPlayground 2020
      • iPlayground submit 2020
    • iPlayground 2019
      • Untitled
      • iPlayground submit 2019
  • WWDC
    • 2020 WWDC
    • 2019 WWDC
    • 2018 WWDC
      • What's New in Testing
      • BusinessChat
    • 2016 WWDC
      • What's New in the Apple Push Notification Service
  • AR/VR
    • ARKit plugin at Unity
    • ARKit
    • AR/VR 實習作品分享
    • Google Blocks
  • CI/CD
    • Continous Integretion for Unity
    • 拯救地球大作戰-自動化設定注意事項
    • Provisioning Profile 自動化更新
    • Make ipa file with personal team of code sign
    • Xcode11 版號問題
  • Test
    • Cucumberish
    • XCUITest
    • Design Patterns in XCUITest
    • Unit Test
  • User Interface
    • IBDesignable 和 IBInspectable
    • iOS 使用貝塞爾曲線繪製路徑
    • UIStatusBarStyle
    • iOS Devices Specification
    • Vector Image
    • Launch Screen
    • Haptic Feedback
    • Good Works for Storyboard
    • Cell 展開收合效果
    • ScrollView
    • Swift lazy
    • Lottie
  • Foundation
    • Adding a Custom Font to Your App
    • WKWebView how to work with javascript
    • Global Central Dispatch
    • HealthKit
    • Error Handling
    • Debug with LLDB
    • Application Lifecycle
    • Swift Codable
    • Push Notifications
    • AVFoudation
  • Others
    • C語言指標概念
    • UnsafePointer(Swift)
    • iOS News Reference
    • Blender
    • Free Web Server
    • Firebase
    • Firebase migration
    • GraphQL
    • Ruby
    • zsh command line
    • visudo
  • Security
    • 課程:App資安規劃與實作
    • KeyChain
    • iOS反組譯程序
    • Arxan
  • Git
    • Git
    • xcodeproj 合併衝突
    • Pull Request
  • Machine Learning
    • CoreML
    • Vision
    • Turi Create
  • 待分類
    • ABI Stability and More
    • Mirror
    • Carthage
    • SwiftUI
    • MVVM
    • OpenSSL
    • USDZ Convert
    • Nexus repository and gitlfs
Powered by GitBook
On this page
  • 起因
  • 建置流程如下
  • Unity build iOS project
  • Set iOS project configure
  • Export ipa for Enterprise or Appstore

Was this helpful?

  1. CI/CD

Continous Integretion for Unity

PreviousGoogle BlocksNext拯救地球大作戰-自動化設定注意事項

Last updated 5 years ago

Was this helpful?

起因

  • 公司有 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都要調

Plugin 'VuforiaWrapper.dll' is used from several locations:
Assets/Plugins/x64/VuforiaWrapper.dll would be copied to <PluginPath>/VuforiaWrapper.dll
Assets/Plugins/x86/VuforiaWrapper.dll would be copied to <PluginPath>/VuforiaWrapper.dll

Please fix plugin settings and try again.

Set iOS project configure

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

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

project.SetBuildProperty(target, "CODE_SIGN_IDENTITY", "iPhone Distribution: XXXXXXXX CO.,LTD.");
project.SetBuildProperty(target, "PROVISIONING_PROFILE", "6999xxxx-1b0f-4c19-be86-62bbb3d6xxxx");

Export ipa for Enterprise or Appstore

  • 在這一階段,我們將之前建置 iOS project 的這段功能擴充到 fastlane,再和 gym 一起使用,就可以將所有步驟整合起來,照著下面網頁教學步驟,很順利的就完成了

desc "Submit a new Beta Build"
  desc "This will also make sure the profile is up to date"
  lane :beta do
    unity(
      execute_method: 'Builder.BuildiOS'
    )    

  provisioningProfiles={"tw.com.xxx.EnterpriseTestApp": "EnterpriseTestApp_InHouse_2018"}

    gym(
        project: './Build/Unity-iPhone.xcodeproj',
        scheme: 'Unity-iPhone',
        export_method: 'enterprise',
        export_options:{provisioningProfiles: provisioningProfiles},
        output_directory: './Build'
    )

Unity iOS で fastlane を使って ipa をビルドする(前編)
Unity - Scripting API: BuildPipeline.BuildPlayer
Unity Build若出錯,查log的地方
Error when building: Plugins colliding with each other
Unity iOS 省心打包(二)
Unity iOS で fastlane を使って ipa をビルドする(後編)
在 fastlane 擴充新的 action: unity