♠️

Codemagicでflutter build ipaが使用できるようになった

2021/01/13に公開

はじめに

先日(1/11)、CodemagicのSlackのannouncementsチャンネルでこんなアナウンスがありました。

Faster iOS builds with the flutter build ipa command :rocket:
Starting from Flutter version 1.24.0-6.0, Flutter has a new command for building iOS app archives: flutter build ipa. It optimizes how the .ipa file is created from the Flutter source and may significantly reduce your Codemagic iOS build times.
To use this build command with Flutter builds configured in the UI, select the Use flutter build ipa checkbox in App settings > Build > iOS build command.
You can also use it in your codemagic.yaml configuration, see an example here.
Note that:

  • This command is not available on Flutter stable channel yet.
  • You still need to set up code singing in your Codemagic configuration.

Flutter 1.24.0–6.0以降のバージョンで使えるようになったflutter build ipaがCodemagicでも使えるようになったようです。

flutter build ipaについてはmonoさんのブログがわかりやすかったです。
flutter build ipa でiOS向けのビルドとアーカイブを同時に実行 🍎

使い方

App settingからBuildの設定項目を開きます。すると中央くらいにiOS build commandとしてflutter build ipaが選択できます。
スクリーンショット 2021-01-13 10.57.20.png

ただし、これはFlutter versionをchannel Betaにしないと使えないのでその点を注意してください。
スクリーンショット 2021-01-13 10.59.27.png

ハマった点

主にFlutter versionをchannel Betaにしたことによるのが原因です。firebaseを使用している場合はこのようなエラーに遭遇する可能性があります。

Because every version of flutter_localizations from sdk depends on intl 0.17.0-nullsafety.2 and firebase_auth_web >=0.3.0-dev.1 depends on intl ^0.16.1, flutter_localizations from sdk is incompatible with firebase_auth_web >=0.3.0-dev.1.
And because firebase_auth >=0.19.0+1 depends on firebase_auth_web ^0.3.2+5, flutter_localizations from sdk is incompatible with firebase_auth >=0.19.0+1.
So, because memesan depends on both firebase_auth ^0.19.0+1 and flutter_localizations any from sdk, version solving failed.
pub finished with exit code 1

flutter_localizationsはflutter sdkのものを使用しており、intl 0.17.0-nullsafety.2に依存していますが、firebase_auth_web はintl ^0.16.1に依存しています。firebase_auth_webを直接的に使っていない場合はこのissueのコメントにある通り、pubspec.yamlに以下を追加します。

dependency_overrides:
  intl: ^0.17.0-nullsafety.2

また、deployment targetが10より小さい場合、pod install時に以下のエラーが発生したので、Podfileを修正しました。

[!] CocoaPods could not find compatible versions for pod "firebase_auth":
  In Podfile:
        firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)

Specs satisfying the `firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)` dependency were found, but they required a higher minimum deployment target.

まとめ

Flutter 1.24.0–6.0以降のバージョンで使えるようになったflutter build ipaがCodemagicでも使えるようになったようなので共有しました。flutter build ipaを使うとビルド時間も短縮できるようなので使っていきたいですね。また、channel Stableで使えるようになるともっと使いやすくなりそうです。

Discussion