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

iOS Build Automation with Jenkins

iOS Build Automation with Jenkins

Presented at CocoaConf Chicago 2013.

Ben Scheirman

March 08, 2013
Tweet

More Decks by Ben Scheirman

Other Decks in Programming

Transcript

  1. Integration Problems • Machine-specific configuration • Merge conflicts • Contention

    on core files (project.pbxproj) • Bad changes committed • Updating certificates / profiles Friday, March 8, 13
  2. “Many teams find that this approach leads to significantly reduced

    integration problems and allows a team to develop cohesive software more rapidly” - Martin Fowler Friday, March 8, 13
  3. More useful plugins Github Plugin IM Notifier Status Monitor Hipchat

    Notifier (or Campfire) 100’s of others Friday, March 8, 13
  4. Compiles Runs Static Analyzer Runs Unit Tests Packages IPAs Generates

    Documentation Archives dSYMs Uploads to Testflight Increments build number Installs the latest distribution certificates & profiles Publishes Code Coverage Reports Inspects for code smells Friday, March 8, 13
  5. Our Mission: Figure out how to do all that.... ON

    THE COMMAND LINE Friday, March 8, 13
  6. Building the Xcode Project xcodebuild -workspace Foo.xcworkspace \ -scheme Foo

    \ -sdk iphonesimulator \ -configuration Debug \ ONLY_ACTIVE_ARCH=NO clean build Friday, March 8, 13
  7. Running Tests xcodebuild -workspace Foo.xcworkspace \ -scheme Foo \ -sdk

    iphonesimulator \ -configuration Debug \ ONLY_ACTIVE_ARCH=NO TEST_AFTER_BUILD=YES \ clean build Friday, March 8, 13
  8. Xcodebuild-rb XcodeBuild::Tasks::BuildTask.new do |t| t.sdk = "iphoneos" t.configuration = "Release"

    t.workspace = workspace t.scheme = scheme t.add_build_setting("ONLY_ACTIVE_ARCH", "NO") t.after_build do |build| derived_dir = build.environment['BUILT_PRODUCTS_DIR'] `rm -rf #{output_dir} && mkdir -p #{output_dir}"` `cp -R #{derived_dir}/* #{output_dir}"` end t.formatter = XcodeBuild::Formatters::ProgressFormatter.new end Friday, March 8, 13
  9. Xcodebuild-rb $ rake -T rake xcode:archive # Creates an archive

    build of the specified target(s). rake xcode:build # Builds the specified target(s). rake xcode:clean # Cleans the build using the same build settings. rake xcode:cleanbuild # Builds the specified target(s) from a clean slate. rake xcode:install # Builds and installs the target rake xcode:settings # Prints the full Xcode build settings Friday, March 8, 13
  10. Building an IPA /usr/bin/xcrun -sdk iphoneos \ PackageApplication \ -v

    \ "build/Foo.app" -o "build/Foo.ipa" Friday, March 8, 13
  11. Generating Appledoc appledoc \ --project-name Foo \ --project-company "Acme, Inc"

    \ --company-id com.acme \ --output docs \ --create-html \ --no-create-docset \ --ignore Pods \ --keep-intermediate-files . Friday, March 8, 13
  12. Uploading to Testflight /usr/bin/curl "http://testflightapp.com/api/builds.json" \ -F file=@"build/Foo.ipa" \ -F

    dsym=@"build/Foo.app.dSYM.zip" \ -F api_token="..." \ -F team_token="..." \ -F notes=@"RELEASE_NOTES" Friday, March 8, 13