Xcode CloudでFlutterのバージョンを指定してビルドを実行する方法
今回はXcode CloudでFlutterのバージョンを指定してビルドを実行する方法についてご紹介していきます。
Xcode CloudでFlutterのバージョンを指定してビルドを実行する方法
Xcode Cloudのチュートリアルを見ると、ci_scripts/ci_post_clone.shのサンプルコードは次のような記載になっていると思います。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#!/bin/sh # Fail this script if any subcommand fails. set -e # The default execution directory of this script is the ci_scripts directory. cd $CI_PRIMARY_REPOSITORY_PATH # change working directory to the root of your cloned repo. # Install Flutter using git. git clone https://github.com/flutter/flutter.git --depth 1 -b stable $HOME/flutter export PATH="$PATH:$HOME/flutter/bin" # Install Flutter artifacts for iOS (--ios), or macOS (--macos) platforms. flutter precache --ios # Install Flutter dependencies. flutter pub get # Install CocoaPods using Homebrew. HOMEBREW_NO_AUTO_UPDATE=1 # disable homebrew's automatic updates. brew install cocoapods # Install CocoaPods dependencies. cd ios && pod install # run `pod install` in the `ios` directory. exit 0 |
しかしこれではgit cloneの対象がstableバージョンとなっており、ローカルやdev環境のFlutterのバージョンとは異なってビルドが正確に動かない可能性があります。
例えば、Flutterのバージョンを3.27.1として指定したい場合は次のようにすると良いでしょう。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#!/bin/sh # Fail this script if any subcommand fails. set -e # The default execution directory of this script is the ci_scripts directory. cd $CI_PRIMARY_REPOSITORY_PATH # change working directory to the root of your cloned repo. # Install Flutter using git. FLUTTER_VERSION="3.27.1" git clone https://github.com/flutter/flutter.git --depth 1 -b $FLUTTER_VERSION $HOME/flutter export PATH="$PATH:$HOME/flutter/bin" # Install Flutter artifacts for iOS (--ios), or macOS (--macos) platforms. flutter precache --ios # Install Flutter dependencies. flutter pub get # Install CocoaPods using Homebrew. HOMEBREW_NO_AUTO_UPDATE=1 # disable homebrew's automatic updates. brew install cocoapods # Install CocoaPods dependencies. cd ios && pod install # run `pod install` in the `ios` directory. exit 0 |
これで私の場合はうまくいきました。
終わりに
今回はXcode CloudでFlutterのバージョンを指定してビルドを実行する方法についてご紹介いたしました。
ディスカッション
コメント一覧
まだ、コメントがありません