LoginSignup
11
6

More than 5 years have passed since last update.

xcodebuildのexportFormatが使えなくてエラーになったときの対処法

Last updated at Posted at 2017-04-07

概要

Xcode Release NotesのXcode8.3の項目には以下のことが書かれています。

The -exportFormat parameter of the -exportArchive option for xcodebuild has been removed.
To set the export format, use the -exportOptionsPlist parameter to specify an export plist file with the method key set to the desired format.
For more information on the keys and values for the export plist, run xcodebuild -help on the command line.

Xcode8.3にバージョンアップするなら、exportFormatオプションを使わないように修正する必要があります。

要約

  • Archiveからipa作るときは、もうexportFormatが使えないよ
  • 作るときはexportOptionPlistオプションを指定してね

ターゲット

  • Xcodeでのビルドをxcodebuildで行っている
  • Xcode8.3未満のバージョンを使っていた

詳細

今までipaを作る時に使用していたxcodebuildコマンド

$ xcodebuild -exportArchive -archivePath <xcarchiveまでのパス> -exportPath <ipaをexportするパス> -exportFormat ipa -exportProvisioningProfile <プロビジョニングプロファイル名>

Xcode8.3環境で上記コマンドを実行すると、exportFormatは使えないよと怒られる。

xcodebuildを見てみる

$ xcodebuild -h

Usage: xcodebuild [-project <projectname>] [[-target <targetname>]...|-alltargets] [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...
       xcodebuild [-project <projectname>] -scheme <schemeName> [-destination <destinationspecifier>]... [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...
       xcodebuild -workspace <workspacename> -scheme <schemeName> [-destination <destinationspecifier>]... [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...
       xcodebuild -version [-sdk [<sdkfullpath>|<sdkname>] [<infoitem>] ]
       xcodebuild -list [[-project <projectname>]|[-workspace <workspacename>]] [-json]
       xcodebuild -showsdks
       xcodebuild -exportArchive -archivePath <xcarchivepath> -exportPath <destinationpath> -exportOptionsPlist <plistpath>
       xcodebuild -exportLocalizations -localizationPath <path> -project <projectname> [-exportLanguage <targetlanguage>...]
       xcodebuild -importLocalizations -localizationPath <path> -project <projectname>

この中の↓を使う。

xcodebuild -exportArchive -archivePath <xcarchivepath> -exportPath <destinationpath> -exportOptionsPlist <plistpath>

exportOptions.plistを作成する

xcodebuildでipa作成 -exportOptionsPlist対応版を参考に作成しました。
私の場合、teamIDがないと怒られたので追加しました。
teamIDはAppleMemberCenter > MembershipのTeam IDで確認できます。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>teamID</key>
    <string>**********(MyTeamID)</string>
    <key>method</key>
    <string>app-store</string>
    <key>uploadBitcode</key>
    <false/>
    <key>uploadSymbols</key>
    <true/>
</dict>
</plist>

Archiveからipaを作るコマンドを修正する

$ xcodebuild -exportArchive -archivePath <xcarchiveまでのパス> -exportPath <ipaをexportするパス> -exportFormat ipa -exportProvisioningProfile <プロビジョニングプロファイル名>

を以下のように修正。

$ xcodebuild -exportArchive -archivePath <xcarchiveまでのパス> -exportPath <ipaをexportするパス> -exportOptionsPlist <exportOptions.plistまでのパス>

コマンド実行する

これでバイナリができr...エラー吐いた…。

> Error Domain=IDEDistributionErrorDomain Code=1 "No valid iOS Distribution signing identities belonging to team **********(MyTeamID) were found." UserInfo={NSLocalizedDescription=No valid iOS Distribution signing identities belonging to team **********(MyTeamID) were found.}

どうやらexportOptions.plistで指定したTeamIDに対応した証明書がないようです。
入れてたはずだよなと思って確認したところ、証明書に「この証明書は取り消されました」と書かれていた。
こいつを正しい有効な証明書に変更したらエラーは無くなりました。

まとめ

  • Xcode8.3からはexportFormatオプションは使用不可
  • exportOptions.plistを作成して、exportOptionsPlistを指定する
  • ipa作成の際、証明書が切れていないか確認する

追記

2017/4/7(金)(ついさっき)、Xcode8.3.1がリリースされました。
Release Noteを見たところ、以下のことが書かれていました。

# Xcode 8.3.1

## Deprecation and Removal Notices
- Due to the resolved app archives issue listed below, we will soon be deprecating Xcode 8.3, at which time app archives built with Xcode 8.3 will no longer be accepted by the App Store.
Build System

## Resolved Issues
- Fixed an issue that could produce app archives that were larger than necessary. Support for app archives built in Xcode 8.3 will be deprecated. (31302382)

要約

  • Xcode8.3でバイナリ作ると、容量が肥大化するバグを直したよ!
  • Xcode8.3で作ったバイナリはRejectするよ!

確認したところ、確かに容量が増えていました。
リジェクト要因にもなるのでXcode8.3の人は今すぐに8.3.1にアップデートしましょう…。

11
6
2

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
11
6