あちらこちらで目にするCIの経験がないので、今更ながら
GitHub上のiOSプロジェクトでもTravis CI × CodecovでCIしたい!
を参考にTravis CIを試してみた。
色々なサイトを調べて一番シンプルな.travis.ymlはこんな感じになった。
.travis.yml
language: objective-c
osx_image: xcode8.3
before_install:
# - brew update
# - brew install carthage
- carthage bootstrap --platform ios
script:
- xcodebuild test -scheme CIWorkflowSample -configuration Debug -destination 'platform=iOS Simulator,OS=10.3,name=iPhone 7 Plus' | bundle exec xcpretty -c
設定した内容は
-
Carthageを利用 -
Carthageを利用するためのHomebrewの設定は不要
brew install carthageしたらエラーになったのでbrew系コマンドは削除。もし必要ならCarthageをアップデートしてもよさそう。
Error: carthage 0.20.1 is already installed
To upgrade to 0.22.0, run `brew upgrade carthage`
- Travis CIのログ制限に引っかかるということなので
xcprettyを利用 -
xcprettyをインストールするためにBundlerを利用する。 -
Bundlerを利用していてプロジェクトのルートにGemfileがある場合は
If there is a Gemfile in your project’s root directory, the pod command is not executed, but instead Bundler is used as a wrapper to pod as follows:
bundle exec pod install
「bundle execを利用しろ」とあるので(Dependency Management)、xcprettyもbundle exec xcpretty で実行する
-
-destinationに設定する内容は以下のようなコマンドを実行してエラーで一覧を表示させて調べる。
xcodebuild test -scheme CIWorkflowSample -destination 'foo=bar'