LoginSignup
2
1

More than 3 years have passed since last update.

[Flutter] Codemagic の flavor 対応

Last updated at Posted at 2019-03-11

追記

Codemagic 自体に機能が追加された ので、今はそれを使うべきです。
(この記事は、ログとして一応残しておきます)


参考

CodemagicでFlutterアプリのビルド・配信をする — iOS編
Codemagic のアプデを受け、上記の素晴らしい記事に補足で行った対応です。

手順

1. Script を準備

codemagic/pre_build.sh
#!/bin/sh

# NOTE: codemagic の UI から以下の環境変数をセットすること
#       • FLAVOR: "development" / "staging" / "release"
#       • CONFIGURATION: "Debug" / "Release"

set -e # exit on first failed commandset
set -x # print all executed commands to the log

echo "----- Using Environment Variables -----"
echo "CONFIGURATION: ${CONFIGURATION}"
echo "FLAVOR: ${FLAVOR}"

# Provisioning Profile の解決をする際に合致しないIDを取ってきてしまう件の対策
/usr/bin/plutil -replace CFBundleIdentifier -string "com.done.sensuikan1973.sample.${FLAVOR}" ios/Runner/Info.plist

# xcodebuid の際に決め打ちで -scheme Runner -config Release のオプションが与えられちゃってる件の対策
cp "ios/Flutter/${CONFIGURATION}-${FLAVOR}.xcconfig" ios/Flutter/Release-production.xcconfigs

同じ内容で codemagic/pre_test.sh も作っておく。 integration test のための build でこけてしまうのを防ぎたいから。

2. Codemagic の UI から設定

環境変数のセット
image.png

pre_test.sh の指定
image.png

pre_build.sh の指定
image.png

3. 完了

もっと良い方法などありましたら🙏

2
1
0

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
2
1