TL; DR
Cocoapods の script_phase を使う
project.yml
name: ExampleApp
targets:
ExampleApp:
type: application
platform: iOS
sources: ExampleApp
prebuildScripts:
- name: Run SwiftLint
script: ${PODS_ROOT}/SwiftLint/swiftlint
postbuildScripts:
- name: Run Fabric
script: "${PODS_ROOT}/Fabric/run"
↑こんな project.yml だったときに
$ xcodegen
$ pod install
xcodegen
-> pod install
すると、postbuildScripts
の後に Cocoapods の script が追加される。
Fabric の script は Cocoapods のものよりも後(一番最後)に呼ばないといけないので、困る。
なので、以下のように一番最後に追加したい script は Podfile に書く。
--- a/Podfile
+++ b/Podfile
@@ -7,4 +7,7 @@ target 'ExampleApp' do
pod 'Fabric', '~> 1.7.2'
pod 'Crashlytics', '~> 3.9.3'
+
+ script_phase :name => 'Run Fabric',
+ :script => '"${PODS_ROOT}/Fabric/run"'
end
Podfile に移動した script は project.yml から消す。
--- a/project.yml
+++ b/project.yml
@@ -7,6 +7,3 @@ targets:
prebuildScripts:
- name: Run SwiftLint
script: ${PODS_ROOT}/SwiftLint/swiftlint
- postbuildScripts:
- - name: Run Fabric
- script: "${PODS_ROOT}/Fabric/run"
そうしてから xcodegen
-> pod install
すると、 Build Phases の最後に [CP-User] Run Fabric
という名前の script が追加されて、めでたしめでたし。