facebook twitter hatena line email

Fastlane/セットアップ/ios

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

iosでのセットアップ

Unity-iPhone.xcworkspaceがある場所に移動してから

$ fastlane init
 What would you like to use fastlane for?
1. 📸  Automate screenshots
2. 👩‍✈️  Automate beta distribution to TestFlight
3. 🚀  Automate App Store distribution
4. 🛠  Manual setup - manually setup your project to automate your tasks

とりあえずTestFlightの自動化で、2を選択

Apple ID Username:
Password: ********
Please enter the 6 digit code:

Apple IDや6codeなどを入れる

Multiple App Store Connect teams
1) "hoge inc" (122xxxxxx)
2) "hogetaro" (118xxxxxx)
Multiple teams found on the Developer Portal, please enter the number of the team you want to use:
1) Nxxxxxxxxx "hoge inc" (Company/Organization)
2) 8xxxxxxxxx "hogetaro" (Individual)

teamsが複数あるときは、設定したいteamを選択

TestFlightへのベータ版配布を自動化

$ fastlane init
 What would you like to use fastlane for?
1. 📸  Automate screenshots
2. 👩‍✈️  Automate beta distribution to TestFlight
3. 🚀  Automate App Store distribution
4. 🛠  Manual setup - manually setup your project to automate your tasks

2を選択

出力ファイル

fastlane/Appfile

app_identifier("com.example.xxxxx) # The bundle identifier of your app
apple_id("hogexxxx@example.com") # Your Apple Developer Portal username

itc_team_id("118xxxxxxxx") # App Store Connect Team ID
team_id("8xxxxxxxxxxxx") # Developer Portal Team ID

↑データはフィルタリングしてある

fastlane/Fastfile

default_platform(:ios)

platform :ios do
  desc "Push a new beta build to TestFlight"
  lane :beta do
    increment_build_number(xcodeproj: "Unity-iPhone.xcodeproj")
    build_app(workspace: "Unity-iPhone.xcworkspace", scheme: "Unity-iPhone")
    upload_to_testflight
  end
end

appleでfastlane用アプリパスを生成

  1. https://appleid.apple.com/account/manage
  2. アプリ用パスワード
  3. アプリ名は、何でも良いが、とりあえず、fastlaneとし、パスワードを生成する
axxx-xxxx-xxxx-xxxx

fastlane用設定追加

fastlane/.env.default

FASTLANE_USER=hogehoge@exampl.com(appleのid)
FASTLANE_PASSWORD=(appleのパス)
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD=axxx-xxxx-xxxx-xxxx

FASTLANE_PASSWORDは、なくても配信はできる。

TestFlightへアップロード

fastlane beta

Fastfile内に、increment_build_numberがあるので、実行のたびにCFBundleVersionが+1される

アップロードエラーその1

1.35.0のバージョンは既にリリースされてるので、別のバージョンにする。

ERROR: [ContentDelivery.Uploader] Asset validation failed (90186) Invalid Pre-Release Train. The train version '1.35.0' is closed for new build submissions 
[00:28:47]: ERROR: [ContentDelivery.Uploader] Asset validation failed (90062) This bundle is invalid. The value for key CFBundleShortVersionString [1.35.0] in the Info.plist file must contain a higher version than that of the previously approved version [1.35.0]. Please find more information about CFBundleShortVersionString at 

アップロードエラーその2

エラー詳細

 fastlane precheck just tried to inspect your app's metadata for App Store guideline violations and ran into a problem. We're not sure what the problem was, but precheck failed to finished. You can run it in verbose mode if you want to see the whole error. We'll have a fix out soon

xcode/Windows/Oganaizerで、upload対応すれば良い。

アップロードエラーその3

エラー詳細

[!] The provided entity includes an attribute with a value that has already been used - The version number has been previously used. - /data/attributes/versionString
<pre>
既に同じversionが上がってるので、バージョンを上げる。

AppStoreへの配布の自動化

$ fastlane init
 What would you like to use fastlane for?
1. 📸  Automate screenshots
2. 👩‍✈️  Automate beta distribution to TestFlight
3. 🚀  Automate App Store distribution
4. 🛠  Manual setup - manually setup your project to automate your tasks

3を選択

出力ファイル

fastlane/Appfile

app_identifier("com.example.xxxxx) # The bundle identifier of your app
apple_id("hogexxxx@example.com") # Your Apple Developer Portal username

itc_team_id("118xxxxxxxx") # App Store Connect Team ID
team_id("8xxxxxxxxxxxx") # Developer Portal Team ID

↑データはフィルタリングしてある

fastlane/Fastfile

platform :ios do
  desc "Push a new release build to the App Store"
  lane :release do
    increment_build_number(xcodeproj: "Unity-iPhone.xcodeproj")
    build_app(workspace: "Unity-iPhone.xcworkspace", scheme: "Unity-iPhone")
    upload_to_app_store(skip_metadata: true, skip_screenshots: true)
  end
end

ビルドしたファイル一覧取得

$ fastlane pilot builds
| 1.38.0    | 7       | 0        |
| 1.36.0    | 6       | 0        |
| 1.38.0    | 4       | 1        |
| 1.38.0    | 3       | 0        |

ios端末登録

nameは誰の端末かを判断する文字列で適当に決めて良い。udidはxcodeメニューのDevicesAndSimulatorsから確認できる。

fastlane run register_device name:"iPadPro1" udid:"0000xxxx-000xxxxxxxxxxxxx"
fastlane renew_profiles

buildNumberのインクリメントから年月日番号へ

- increment_build_number(xcodeproj: "Unity-iPhone.xcodeproj")
+ increment_build_number(xcodeproj: "Unity-iPhone.xcodeproj", build_number: Time.now.strftime("%Y%m%d%H%M"))

参考:https://speakerdeck.com/starhoshi/ios-ga-fastlane-nara-android-mo-fastlane-nicheng-tutemiteha