新しいアプリを作ろうとおもうと、ライブラリ管理ツールやCI用の設定をすることになる。
これが、毎回だとめんどう。。。。
そこで、作成例のプロジェクトで作ってみた。
作成例:https://github.com/ppengotsu/iosProjectTemplate
また、最後にxcodeでプロジェクト作ったあとに、上記テンプレートと再現する方法を載せます。
目的
iOSアプリのローカルビルド、テストの簡易化
Bitrise(CI)でのビルドとローカルでのビルド環境をできる限り近づける
やってないこと
ストア申請(fastlaneでできるけど、このスクリプトではlane設定していない。また、自分がまだfastlaneでの申請を試していないため)
使用するツール
ツール名 | 目的 |
---|---|
Xcode | |
rbenv | Rubyのバージョン固定のため |
HomeBrew | |
carthage | |
cocoapods | |
fastlane | ビルド、申請などの簡易化 |
Bundle | cocoapodsとfastlaneのバージョン管理 |
再現方法
下記スクリプトを実行するとほぼ再現できます。
最新:https://github.com/ppengotsu/iosProjectTemplate/blob/master/init_project.sh
bashscript.sh
#!/bin/sh
# プロジェクトに、必要な初期設定などをします。
#
#
#
#
# HomeBrew
if [ ! -f "/usr/local/bin/brew" ]; then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# rbenv
if [ ! -f "/usr/local/bin/rbenv" ]; then
brew update
brew install rbenv
fi
# fix Ruby Version
rbenv local 2.1.0
# bundler
rbenv exec gem install bundler
rbenv rehash
touch Gemfile
echo "source \"https://rubygems.org\" " >> Gemfile
echo "gem 'fastlane', '1.89.0' " >> Gemfile
echo "gem 'cocoapods', '1.0.0' " >> Gemfile
rbenv exec bundle install --path bundle
# carthage
if [ ! -f "/usr/local/bin/carthage" ]; then
# carthage install
brew update
brew install carthage
fi
touch Cartfile #make Cartfile (like Podfile)
carthage update --platform iOS
#fastlane
rbenv exec bundle exec fastlane init
#cocoapods
rbenv exec bundle exec pod init
rbenv exec bundle exec pod install
#test
rbenv exec bundle exec fastlane test #run test code
再現できていない部分は、
fastlaneのlane設定です。
それぞれで、設定してください