Codemagicとは:
・Windows環境からでもMacなしでiOSビルドが可能
・GitHub/GitLabなどと簡単に連携
・無料プランで手軽にスタート可能
🔍 必要なもの
・Windows PC
・Flutterアプリのリポジトリ(GitHubなど)
・Codemagicのアカウント(無料で登録可能)
🛠 CodemagicでiOSシミュレーター向けにビルドする手順
① Codemagicとリポジトリを連携する
Codemagicにログインし、Flutterアプリのリポジトリを登録します。
https://codemagic.io/start/
Codemagicで「Add Application」を選択
GitHubなどで認証し、リポジトリを選択
② codemagic.yamlの設定
Flutterプロジェクトのルートに以下のcodemagic.yamlを作成します。
workflows:
ios-simulator-test:
name: iOS Simulator Test
environment:
flutter: stable
xcode: latest
scripts:
- flutter packages pub get
- flutter analyze
- flutter test
- flutter build ios --simulator --debug --no-codesign
artifacts:
- build/ios/iphonesimulator/*.app
この設定で、Codemagic上でシミュレーター用のiOSアプリが作成されます。
③ 変更をコミットしてGitHubにプッシュ
作成したファイルをコミット・プッシュします。
git add codemagic.yaml
git commit -m "Add codemagic.yaml for iOS simulator test"
git push origin main
④ Codemagicでビルドを開始 🎯
Codemagicで以下を行います。
「Start new build」をクリック
ワークフローを選択(ios-simulator-test)
「Start new build」を再度クリックしてビルドを開始
Codemagicがクラウド上でiOSシミュレーター向けアプリを生成します。
🌟 Windowsで動作確認をする方法
ビルドが成功すると、iOSシミュレーター用の.appファイルが生成されます。
Windows環境から手軽に確認するには Appetize.io がおすすめです。
📱 Appetize.ioを使ってブラウザで確認
Codemagicで生成した.appフォルダをZip圧縮してダウンロード
https://appetize.io/
にアクセス
zipファイルをアップロードして起動
ブラウザ上ですぐにシミュレーターが起動し、アプリの動作を手軽に確認できます。
🚩 注意点
Codemagicの無料枠にも一定の時間制限(500分/月)がありますが、個人開発には十分です。
‼️補足
こんなエラーが出ました。
Error: The plugin "firebase_core" requires a higher minimum iOS deployment version than your application is targeting.
To build, increase your application's deployment target to at least 13.0 as described at https://flutter.dev/to/ios-deploy
Error running pod install
Podfile をiosフォルダ以下に格納する必要があるのですが、
そのためにはpodコマンドを使用する必要があります。
しかし、Windowsからでは使用できないので、LinuxとかMac OSの使用が必要となります。
これを回避するために、CursorでPodfileを生成してもらうと便利です。
これに付随して、必要に応じてpbxprojファイル等も変更してくれるので、便利🎉