Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fastlane, Continuous Deployment to iOS

Fastlane, Continuous Deployment to iOS

Continuous Deployment to iOS

yohei sugigami

February 28, 2015

More Decks by yohei sugigami

Other Decks in Technology


  1. Install $ sudo gem install fastlane
 Successfully installed fastlane-0.1.9

    Successfully installed fastlane_core-0.1.1 Successfully installed deliver-0.7.10 Successfully installed snapshot-0.4.9 Successfully installed frameit-0.2.2 Successfully installed pem-0.3.4 Successfully installed sigh-0.3.3 Successfully installed produce-0.1.4 $ brew install xctool (for test)
 $ brew install imagemagick (for frameit)

  2. $ cd [your_project_folder] $ fastlane init
 INFO This setup

    will help you get up and running in no time. INFO First, it will move the config files from `deliver` and `snapshot` INFO into the subfolder `fastlane`. INFO Fastlane will check what tools you're already using and set up INFO the tool automatically for you. Have fun! Do you want to get started? This will move your Deliverfile and Snapfile (if they exist) (y/n) y Do you have everything commited in version control? If not please do so! (y/n) y INFO Created new folder './fastlane'. INFO ------------------------------ INFO To not re-enter your username and app identifier every time you run one of the fastlane tools or fastlane, these will be stored from now on. App Identifier (com.krausefx.app): com.hoge.fuga Your Apple ID: [email protected] INFO Created new file './fastlane/Appfile'. Edit it to manage your preferred app metadata information. Do you want to setup 'deliver', which is used to upload app screenshots, app metadata and app updates to the App Store or Apple TestFlight? (y/n) y INFO Loading up 'deliver', this might take a few seconds Phantomjs does not appear to be installed in /Users/hoge/.phantomjs/1.9.8/darwin/bin/phantomjs, installing! Init
  3. Successfully installed phantomjs. Yay! Removed temporarily downloaded files. Do you

    want Deliver to automatically create the Deliverfile for you based on your current app? The app has to be in the App Store to use this feature. (y/n) y First, you need to login with your iTunesConnect credentials. This is necessary to fetch the latest metadata from your app and use it to create a Deliverfile for you. If you have previously entered your credentials already, you will not be asked again. No username or password given. You can set environment variables: DELIVER_USER, DELIVER_PASSWORD ------------------------------------------------------------------------------------- The login information you enter will be stored in your Mac OS Keychain More information about that on GitHub: https://github.com/KrauseFx/CredentialsManager ------------------------------------------------------------------------------------- Password (for [email protected]): ********** INFO Could not find Apple ID based on the app identifier in the US App Store. Maybe the app is not yet in the store? INFO You can provide the Apple ID of your app using `apple_id '974739333'` in your `Deliverfile`
 Apple ID of your app (e.g. 284882215): 284882215
 INFO Going to download app metadata from iTunesConnect DEBUG [Transporter Output]: INFO: Transporter is searching for updated software components. Init
  4. ERROR [Transporter Error Output]: Your Apple ID or password was

    entered incorrectly. (-20101) It seems like the username or password for the account '[email protected]' is wrong. Do you want to re-enter your username and password? (y/n) n DEBUG [Transporter Output]: DBG-X: The error code is: -20101 FATAL Transporter transfer failed. WARN ERROR Your Apple ID or password was entered incorrectly. (-20101) FATAL Return status of iTunes Transporter was 1: Your Apple ID or password was entered incorrectly. (-20101) ERROR Your Apple ID or password was entered incorrectly. (-20101) Return status of iTunes Transporter was 1: Your Apple ID or password was entered incorrectly. (-20101) FATAL Could not download metadata from iTunes Connect. Do you have special characters in your password (Like ' or ")? FATAL Error occured with the setup program! Reverting changes now! INFO Deleting the 'fastlane' folder /Users/hoge/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/deliver-0.7.10/lib/deliver/ app_metadata.rb:302:in `read': No such file or directory @ rb_sysopen - /tmp/968761649.itmsp// metadata.xml (Errno::ENOENT) (ɾ_ɾ;) Your Apple ID or password was entered incorrectly
  5. INFO iTunes Transporter successfully finished its job DEBUG [Transporter Output]:

    DBG-X: Returning 0 INFO Successfully downloaded the latest package from iTunesConnect. INFO Modifying version '1.0.0' of app com.hoge.fuga Successfully created new metadata JSON file at './fastlane//deliver/metadata.json' Successfully created new Deliverfile at './fastlane//Deliverfile' Do you want to setup 'snapshot', which will help you to automatically take screenshots of your iOS app in all languages/devices? (y/n) y INFO Loading up 'snapshot', this might take a few seconds DEBUG Found 10 simulators. Successfully created SnapshotHelper.js './fastlane//SnapshotHelper.js' Successfully created new UI Automation JS file at './fastlane//snapshot.js' Successfully created new UI Automation JS file for iPad at './fastlane//snapshot-iPad.js' Successfully created new Snapfile at './fastlane/Snapfile' Do you want to use 'sigh', which will maintain and download the provisioning profile for your app? (y/n) y INFO 'deliver' enabled. INFO 'snapshot' enabled. INFO 'xctool' not enabled. INFO 'cocoapods' enabled. INFO 'sigh' enabled. INFO Created new file './fastlane/Fastfile'. Edit it to manage your own deployment lanes. INFO Successfully finished setting up fastlane Install
  6. before_all do # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..." # sh "./customShellScript.sh" team_id

 cocoapods increment_build_number xctool :test ipa({ workspace: "MyApp.xcworkspace", configuration: "Debug", scheme: "MyApp", }) end before_all
  7. lane :beta do sigh increment_build_number ipa({ workspace: "RSSReader.xcworkspace", configuration: "Release",

    scheme: "RSSReader", clean: "" }) deliver :skip_deploy, :beta end lane
  8. after_all do |lane| slack({ message: "Successfully deployed [App]", success: true,

    channel: 'development' }) end error do |lane, exception| # Something bad happened end after_all
  9. lane :beta do snapshot sigh crashlytics({
 # path to your

    'Crashlytics.framework' crashlytics_path: './Crashlytics.framework', api_token: '...', build_secret: '...', ipa_path: './app.ipa' }) end Crashlytics Beta
  10. lane :beta do snapshot sigh
 deploygate({ api_token: '...', user: 'target

    username or organization name', ipa: './ipa_file.ipa', message: "Build", }) end DeployGate
  11. Snapshot $ snapshot
 OR lane :snapshot do snapshot end

 ./fastlane/Fastfile $ fastlane snapshot

  12. Config snapshot & frameit #import "SnapshotHelper.js" var target = UIATarget.localTarget();

    var app = target.frontMostApp(); var window = app.mainWindow(); target.delay(3) captureLocalizedScreenshot("0-LandingScreen") ./fastlane/snapshot.js ./fastlane/Snapfile devices([ "iPhone 6", "iPhone 6 Plus", "iPhone 5", "iPhone 4s", "iPad Air" ]) languages([ "en-US", "de-DE", "es-ES" ]) Device, Language, Timing
  13. INFO Driving the lane 'beta' INFO Step: team_id INFO Setting

    Team ID to 'xxxxxxxxxx' for all build steps INFO Step: sigh INFO Login into iOS Developer Center INFO Login successful INFO Fetching all available provisioning profiles... INFO Checking if profile is available. (72 profiles found) INFO Downloading profile... INFO Successfully downloaded provisioning profile INFO Exported provisioning profile to '/Users/susieyy/go/src/github.com/wantedly/swift-rss- sample/Distribution_com.susieyy.rss.mobileprovision' INFO open '/Users/susieyy/go/src/github.com/wantedly/swift-rss-sample/ Distribution_com.susieyy.rss.mobileprovision' INFO Step: increment_build_number INFO agvtool next-version -all INFO Step: ipa INFO ipa build -w "RSSReader.xcworkspace" -c "Release" -s "RSSReader" --clean INFO Step: deliver INFO Got all information needed to deploy a new update ('1.0.0') for app 'com.susieyy.rss' INFO Uploading ipa file to iTunesConnect INFO Going to upload updated app to iTunesConnect INFO iTunes Transporter successfully finished its job INFO Successfully uploaded package to iTunesConnect. It might take a few minutes until it's visible online. INFO fastlane.tools finished successfully ./fastlane/Deliverfile $ fastlane beta