タイトルの通り。本当はfastlaneとか使うか迷ったけどまずはこれで当分なんとかできそう。
1, 以下の内容shファイルをプロジェクトルートに作る。
#!/bin/bash
echo 'Build Android Release Resource'
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
echo ''
echo 'Build iOS Release Resource'
flutter build ios --release
ARCHIVE_PATH="$PWD/build/ios/Runner.xcarchive"
IPA_PATH="$PWD/build/ios/Runner.ipa"
xcodebuild -quiet -workspace ios/Runner.xcworkspace -scheme Runner -sdk iphoneos -configuration Release archive -archivePath $ARCHIVE_PATH
xcodebuild -quiet -allowProvisioningUpdates -exportArchive -archivePath $ARCHIVE_PATH -exportOptionsPlist ipaOptions.plist -exportPath $IPA_PATH
echo ''
echo 'Android Release Resource (ipa)'
find build/app/outputs -name "*.aab" -type f
echo ''
echo 'iOS Release Resource (ipa)'
find build/ios -name "*.ipa" -type f
2, exportOptionsPlistに指定するファイルを作る
自分はipaOptions.plist
という名前にした。これもプロジェクトルートに置く。
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
<key>uploadBitcode</key>
<false/>
<key>uploadSymbols</key>
<true/>
</dict>
</plist>
3, 実行
こんな感じのログが出る。xcodebuild
に-quiet
を付けているのでwarningかerrorだけ出る。
$ ./build.sh
Build Android Release Resource
Removed unused resources: Binary resource data reduced from 155KB to 130KB: Removed 15%
Running Gradle task 'bundleRelease'...
Running Gradle task 'bundleRelease'... Done 10.7s
✓ Built build/app/outputs/bundle/release/app-release.aab (22.8MB).
Build iOS Release Resource
Building foo.bar.myapp for device (ios-release)...
Automatically signing iOS for device deployment using specified development team in Xcode project: ABCDEFGHI
Running Xcode build...
└─Compiling, linking and signing... 22.2s
Xcode build done. 42.8s
Built /path/to/Runner.app.
2020-05-05 01:10:09.963 xcodebuild[59710:8626900] [MT] PluginLoading: Required plug-in compatibility UUID C80A9C11-3902-4885-944E-A035869BA910 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/RealmPlugin.xcplugin' not present in
:
(中略)
:
'/var/folders/ml/zjkhw_p17pjbrj2383y5qym40000gn/T/Runner_2020-05-05_01-13-41.823.xcdistributionlogs'.
Exported Runner to: /path/to/Runner.ipa
Android Release Resource (ipa)
build/app/outputs/bundle/release/app-release.aab
iOS Release Resource (ipa)
build/ios/Runner.ipa/Runner.ipa
$