‘Fastlane’ タグのついている投稿
Fastlaneの基本 〜gym入れてみる〜
Fastlaneファイルの基本構造を確認したところで、
次にパッケージを1つ動かしてみようと思います
gymを入れてみました。ipaファイルを作るパッケージです
sudo gem install gymでインストールします
test:FastlaneTest test$ gym --workspace "FastlaneTest.xcodeproj/project.xcworkspace" --scheme "FastlaneTest" --clean --use_legacy_build_api
[11:38:10]: Using legacy build system - waiting for radar to be fixed: https://openradar.appspot.com/radar?id=4952000420642816
[11:38:10]: xcrun xcodebuild -list -workspace 'FastlaneTest.xcodeproj/project.xcworkspace'
+----------------------+--------------------------------------------+
| Summary for gym 1.6.2 |
+----------------------+--------------------------------------------+
| workspace | FastlaneTest.xcodeproj/project.xcworkspace |
| scheme | FastlaneTest |
| clean | true |
| use_legacy_build_api | true |
| destination | generic/platform=iOS |
| output_name | FastlaneTest |
| output_directory | . |
| silent | false |
| buildlog_path | ~/Library/Logs/gym |
+----------------------+--------------------------------------------+
〜中略〜
[11:38:34]: Successfully exported and compressed dSYM file
[11:38:34]: Successfully exported and signed the ipa file:
[11:38:34]: /Users/test/WorkSpace/test/FastlaneTest/FastlaneTest.ipa
ipaファイルができていることが確認できます!
—use_legacy_build_api をパラメータに入れていないと
“The operation couldn’t be completed. (IDEDistributionErrorDomain error 1.)”
というエラーが発生するようです(参考:http://qiita.com/takecian/items/6d34448d61c69e0d4a7f)
以上を確認した上で、最初に作ったFastlaneファイルにgymを入れてみます
1 fastlane_version "1.81.0"
2 default_platform :ios
3
4 platform :ios do
5 before_all do
6 say ["before all"]
7 end
8
9 desc "テストですよー"
10 lane :test do
11 gym(
12 workspace: "FastlaneTest.xcodeproj/project.xcworkspace",
13 scheme: "FastlaneTest",
14 clean: true,
15 use_legacy_build_api: true
16 )
17 end
18
19 desc "テストですよー2"
20 lane :test2 do |options|
21 say [options[:hoge]]
22 end
23
24 after_all do |lane|
25 say ["after all"]
26 end
27
28 error do |lane, exception|
29 say ["エラー"]
30 end
31 end
ipaファイルを消して実行
test:fastlane test$ fastlane test
[14:29:08]: -------------------------------------------------
[14:29:08]: --- Step: Verifying required fastlane version ---
[14:29:08]: -------------------------------------------------
[14:29:08]: fastlane version valid
[14:29:08]: ------------------------------
[14:29:08]: --- Step: default_platform ---
[14:29:08]: ------------------------------
[14:29:08]: Driving the lane 'ios test' 🚀
[14:29:08]: -----------------
[14:29:08]: --- Step: say ---
[14:29:08]: -----------------
[14:29:08]: $ say 'before all'
[14:29:10]: -----------------
[14:29:10]: --- Step: gym ---
[14:29:10]: -----------------
[14:29:10]: Using legacy build system - waiting for radar to be fixed: https://openradar.appspot.com/radar?id=4952000420642816
[14:29:10]: xcrun xcodebuild -list -workspace 'FastlaneTest.xcodeproj/project.xcworkspace'
+----------------------+--------------------------------------------+
| Summary for gym 1.6.2 |
+----------------------+--------------------------------------------+
| workspace | FastlaneTest.xcodeproj/project.xcworkspace |
| scheme | FastlaneTest |
| clean | true |
| use_legacy_build_api | true |
| destination | generic/platform=iOS |
| output_name | FastlaneTest |
| output_directory | . |
| silent | false |
| buildlog_path | ~/Library/Logs/gym |
+----------------------+--------------------------------------------+
〜中略〜
[14:29:45]: Successfully exported and compressed dSYM file
[14:29:45]: Successfully exported and signed the ipa file:
[14:29:45]: /Users/test/WorkSpace/test/FastlaneTest/FastlaneTest.ipa
[14:29:45]: -----------------
[14:29:45]: --- Step: say ---
[14:29:45]: -----------------
[14:29:45]: $ say 'after all'
+------+-------------------------------------+-------------+
| fastlane summary |
+------+-------------------------------------+-------------+
| Step | Action | Time (in s) |
+------+-------------------------------------+-------------+
| 1 | Verifying required fastlane version | 0 |
| 2 | default_platform | 0 |
| 3 | say | 1 |
| 4 | gym | 35 |
| 5 | say | 1 |
+------+-------------------------------------+-------------+
[14:29:46]: fastlane.tools finished successfully 🎉
例えば、FastlaneTestスキーマをコピーしたFastlane2も
10 lane :test do
11 gym(
12 workspace: "FastlaneTest.xcodeproj/project.xcworkspace",
13 scheme: "FastlaneTest2",
14 clean: true,
15 use_legacy_build_api: true
16 )
とschemeの値を編集すれば同じようにipaファイルが作成されます
次はリリースまでの一通りのパッケージを入れた状態のFastlaneファイルを用意してみようかと思います
Fastlaneの基本 〜構造を知る〜
iOSアプリ生成時のコストを下げる事を目標にFastlaneを勉強中なのですが、
検索かけてもなかなかまとまった記事が見つからないので
自分の脳内整理の為に簡潔にまとめてみました
テスト用ということで、まずViewControllerを1つ用意したFastlaneTestというプロジェクトを作り、
Fastlaneをインストールして早速動作確認
Fastlaneファイルの基本構造こんな感じ
1 fastlane_version "1.81.0"
2 default_platform :ios
3
4 platform :ios do
5 before_all do
6 say ["before all"]
7 end
8
9 desc "テストですよー"
10 lane :test do
11 say ["テストですよー"]
12 end
13
14 desc "テストですよー2"
15 lane :test2 do |options|
16 say [options[:hoge]]
17 end
18
19 after_all do |lane|
20 say ["after all"]
21 end
22
23 error do |lane, exception|
24 say ["エラー"]
25 end
26 end
fastlane [lane名]で実行します
そうするとbefore_all→[lane名]→after_allの順番で走ることがわかります
因みにsay[]はボイスが流れるactionです
エラーが発生した場合はerrorの中身が走り、after_allは実行されません
test:fastlane test$ fastlane test
[12:06:55]: -------------------------------------------------
[12:06:55]: --- Step: Verifying required fastlane version ---
[12:06:55]: -------------------------------------------------
[12:06:55]: fastlane version valid
[12:06:55]: ------------------------------
[12:06:55]: --- Step: default_platform ---
[12:06:55]: ------------------------------
[12:06:55]: Driving the lane 'ios test' 🚀
[12:06:55]: -----------------
[12:06:55]: --- Step: say ---
[12:06:55]: -----------------
[12:06:55]: $ say 'before all'
[12:06:56]: -----------------
[12:06:56]: --- Step: say ---
[12:06:56]: -----------------
[12:06:56]: $ say 'テストですよー'
[12:06:58]: -----------------
[12:06:58]: --- Step: say ---
[12:06:58]: -----------------
[12:06:58]: $ say 'after all'
+------+-------------------------------------+-------------+
| fastlane summary |
+------+-------------------------------------+-------------+
| Step | Action | Time (in s) |
+------+-------------------------------------+-------------+
| 1 | Verifying required fastlane version | 0 |
| 2 | default_platform | 0 |
| 3 | say | 1 |
| 4 | say | 1 |
| 5 | say | 1 |
+------+-------------------------------------+-------------+
[12:06:59]: fastlane.tools finished successfully 🎉
test:fastlane test$ fastlane test2 hoge:aaa
[17:53:38]: -------------------------------------------------
[17:53:38]: --- Step: Verifying required fastlane version ---
[17:53:38]: -------------------------------------------------
[17:53:38]: fastlane version valid
[17:53:38]: ------------------------------
[17:53:38]: --- Step: default_platform ---
[17:53:38]: ------------------------------
[17:53:38]: Driving the lane 'ios test2' 🚀
[17:53:38]: -----------------
[17:53:38]: --- Step: say ---
[17:53:38]: -----------------
[17:53:38]: $ say 'before all'
[17:53:39]: -----------------
[17:53:39]: --- Step: say ---
[17:53:39]: -----------------
[17:53:39]: $ say 'aaa'
[17:53:40]: -----------------
[17:53:40]: --- Step: say ---
[17:53:40]: -----------------
[17:53:40]: $ say 'after all'
+------+-------------------------------------+-------------+
| fastlane summary |
+------+-------------------------------------+-------------+
| Step | Action | Time (in s) |
+------+-------------------------------------+-------------+
| 1 | Verifying required fastlane version | 0 |
| 2 | default_platform | 0 |
| 3 | say | 1 |
| 4 | say | 1 |
| 5 | say | 1 |
+------+-------------------------------------+-------------+
[17:53:41]: fastlane.tools finished successfully 🎉
今回はここまで
次回はgymを入れてipaファイルを作ってみようと思います