LoginSignup
25
24

More than 5 years have passed since last update.

UnityプロジェクトをJenkinsを使用してXCode8対応した

Last updated at Posted at 2016-09-20

XCode7で正常にビルドできていたところからどう修正したかの備忘録です。

環境
- Unity5.3.5f1
- XCode8.0

xcodebuildコマンドでめっちゃエラーでる

シェルスクリプト
xcodebuild -project "${XCODE_PROJECT_FILE}" \
  -configuration "${CONFIGURATION}" \
  CODE_SIGN_IDENTITY="${CODESIGN_NAME}" \
  PROVISIONING_PROFILE="${PROVISIONING_PROFILE}"
Signing for Unity-iPhone requires a development team. Select a development team in the project editor.
Code signing is required for product type 'Application' in SDK 'iOS 10.0'

このような感じでビルドが成功しない。

  • どうやらXCode8からCodesign/ProvisioningProfileは Automatic にすることが推奨されている
  • xcodeprojectの設定とxcodebuildによる指定が異なる場合、Archive化できない

解決法

xcodeproj(project.pbxproj)の設定をUnityの XCodeAPI で上書き

XCodeProjectUpdater.cs

  [PostProcessBuild]
  static void OnPostProcessBuild(BuildTarget buildTarget, string path)
  {
    string projPath = buildPath + "/Unity-iPhone.xcodeproj/project.pbxproj";

    PBXProject proj = new PBXProject();
    proj.ReadFromString(File.ReadAllText(projPath));

    string target = proj.TargetGuidByName("Unity-iPhone");

    // 色々設定更新(実際はJenkinsのオプション引数で各種情報を取得)
    proj.SetBuildProperty(target, "DEVELOPMENT_TEAM", teamPrefix); // チーム名はADCで確認できるPrefix値を設定する
    proj.SetBuildProperty(target, "CODE_SIGN_IDENTITY", codesignName);
    proj.SetBuildProperty(target, "PROVISIONING_PROFILE_SPECIFIER", provisioningProfileName); // XCode8からProvisioning名で指定できる

    proj.WriteToFile(projPath);
  }

Jenkins側のシェルではオプションを指定せずにビルドを行う

シェルスクリプト
xcodebuild -project "${XCODE_PROJECT_FILE}" -configuration "${CONFIGURATION}"

上記処置でビルドは無事成功したが、
Unity Cloud Buildを利用することになる日は近い・・・!

参考:
Xcode 8: xcodebuildで、Automatic Signingに対応する
[iOS 10] Xcode 8 の新しい Signing 機能について
What’s New in Xcode

25
24
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
24