Better iOS development with Groovy

Rahul Somasunderam (@rahulsom)

About me

Where I work

BoxCutter

 

 

Why iOS?

And why at a this conference?

What does it take to build an iOS app?

XCode or AppCode

Swift vs Objective-C

  • Tooling

  • Libraries

Dependency management

  • Libraries vs frameworks

 

 

And I don’t mean transitive dependencies…​

Dependencies

  • Your app needs dependencies

  • Dependencies can be installed with Cocoapods

  • Cocoapods is a ruby gem

  • Ruby gems can be installed with Bundler

  • You WANT ruby in the user space; so RBENV

  • There is a brew formula for RBENV

  • brew is installed using system ruby

Build Tools

Not 10 bullet points telling you to point and click at things.

 

XcodeBuild

xcodebuild \
    -scheme Todos \
    -workspace Todos.xcworkspace \
    -sdk iphonesimulator \
    -configuration Debug \
    DSTROOT=/Users/rahul/src/Todos/build/dst \
    OBJROOT=/Users/rahul/src/Todos/build/obj \
    SYMROOT=/Users/rahul/src/Todos/build/sym \
    SHARED_PRECOMPS_DIR=/Users/rahul/src/Todos/build/shared \
    -destination \
    'platform=iOS Simulator,id=CAB835ED-3EE2-47B6-AD74-C06675651CEF' \
    test

XcodeBuild

  • Too complex commands - Unruly bash scripts

  • Different tools for build, upload to testflight, hockeyapp

  • Very little documentation, very steep learning curve

  • What about functional testing?

xctool

xctool \
    -workspace Todos.xcworkspace \
    -sdk iphonesimulator \
    -scheme Todos \
    test

xctool

  • Written in Objective-C

  • Needs advanced knowledge of Objective-C

  • What about functional testing?

Nomad CLI

ios profiles:list --team=ABCDE56789
ipa build && ipa distribute

Nomad CLI

  • Written in ruby

  • Great support for certificates, distribution profiles

  • Great support for distribution using iTunesConnect

  • What about testing?

What we need

  • Flexible build system

  • Support for distribution

  • Support for functional testing

  • Easy to install, even if you’re an enterprise software company

  • Easy to run

Gradle Xcode Plugin

buildscript {
  repositories {
    maven { url "https://plugins.gradle.org/m2/" }
  }
  dependencies {
    classpath "gradle.plugin.org.openbakery:xcodePlugin:0.11.3"
  }
}
apply plugin: "org.openbakery.xcodeplugin"
xcodebuild {
  workspace = 'Todos.xcworkspace'
  scheme = 'Todos'
  target = 'Todos'
  sdk = 'iphonesimulator'
}

Gradle Xcode Plugin

./gradlew xcodetest
./gradlew appstoreUpload

Functional Testing

UIAutomation using Instruments

  • Record and Playback

  • DOM Tree access

  • Refactoring

  • Managing State

  • Tuneup JS? Bwoken?

Appium

  • Based on Selenium

  • Clients for several languages including Java

  • Makes your app stateless

Groovy + Spock

  • Spock’s expressive testing

  • Groovy’s metaprogramming to improve access to DOM

Continuous Integration

Jenkins

  • Cloudbees runs a very old version of OSX and XCode.

  • Bring your own Jenkins and/or Bring your own slaves.

Immutable slaves

  • There’s no Docker for OSX

  • But there is vagrant. [fragment]Kind of

  • You’re better off managing slaves as mutable instances

Travis CI

  • Recently added GA support for XCode

  • Can’t run appium yet.

Resources

Thanks