2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Flutterでストアに提出できるrelease buildを一発で作るシェルスクリプト

Last updated at Posted at 2020-05-04

タイトルの通り。本当は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
$
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?