Slide 1

Slide 1 text

iContinuousIntegration Oleksandr Dodatko Dnepropetrovsk, Ukraine. 2012

Slide 2

Slide 2 text

Introduce yourselves please

Slide 3

Slide 3 text

I came to iOS from C++ and was disappointed All code in a single project Hard to reuse common functionality No unit tests No build automation All other developers solved these problems years ago

Slide 4

Slide 4 text

IOS developers do not use modern engineering practices Only 10% do unit testing 33% use nothing but Apple supplied components 28% copy-paste third-parties to their projects

Slide 5

Slide 5 text

Copy-paste style libraries Regex Kit Lite Touch XML Touch JSON Magical Record Cocoa Lumberjack and many more ...

Slide 6

Slide 6 text

WHY ?

Slide 7

Slide 7 text

Magicalpanda : “I'm not sure what the benefits are to everyone...” Magicalpanda : “as long as I can still use the Source Code approach, I'm ok with having a separate target in the project that dumps out a static library” tonyxiao : “I don't really care to compile from source”

Slide 8

Slide 8 text

Ok. Why should we care?

Slide 9

Slide 9 text

Use Static Libraries

Slide 10

Slide 10 text

Add a Library Sub-project

Slide 11

Slide 11 text

Set up Dependencies

Slide 12

Slide 12 text

Set up Dependencies

Slide 13

Slide 13 text

Do not forget about the header path

Slide 14

Slide 14 text

Library Usage Benefits Clear design No linker conflicts A better way to reuse code

Slide 15

Slide 15 text

Yes. It works! “ BTW, thanks for your pull request. I have't had time to review it all yet, but most of it looks good. “ Saul Mora. Founding Panda. [email protected] appunite / CLCascade has accepted our patch

Slide 16

Slide 16 text

Find our forks at github.com/EmbeddedSources

Slide 17

Slide 17 text

Let's discuss unit tests

Slide 18

Slide 18 text

I recommend ... Easy to debug failed tests Easy to use files with test data bundles Generates jUnit compatible reports

Slide 19

Slide 19 text

GHUnit : unit test is an iOS application

Slide 20

Slide 20 text

Unit test life cycle Pass test data files to the test program Launch the test program Publish test reports

Slide 21

Slide 21 text

iOS sandbox makes things complicated

Slide 22

Slide 22 text

Application Launch Demo

Slide 23

Slide 23 text

iphonesim launch "$DEPLOYMENT_DIR/CITest.app" 4.2 ipad NOTE : Use only FULL PATH to the app as shown above Launching app without xCode

Slide 24

Slide 24 text

TEMP_DIR=$(/usr/bin/getconf DARWIN_USER_TEMP_DIR) All Test results are here : $TEMP_DIR/test-results Collecting Test Results

Slide 25

Slide 25 text

Requires sudo under Lion

Slide 26

Slide 26 text

Before you run a test... killall -KILL -c "iphonesim" killall -KILL -c "iPhone Simulator" GHUNIT_AUTORUN WRITE_JUNIT_XML GHUNIT_AUTOEXIT

Slide 27

Slide 27 text

Unit tests reduce risks due to early error discovery

Slide 28

Slide 28 text

Jenkins job should build and deploy in one click There should be no interaction with the user

Slide 29

Slide 29 text

Building without xCode xcodebuild -project CITest.xcodeproj -sdk iphonesimulator4.3 -configuration Release -target CITest -parallelizeTargets clean build xcodebuild -project CITest.xcodeproj -sdk iphonesimulator4.3 -configuration Release -target CITest -parallelizeTargets clean build

Slide 30

Slide 30 text

Demo time

Slide 31

Slide 31 text

Deliver your beta builds as *.ipa files using TestFlight

Slide 32

Slide 32 text

Creating Installable *.ipa File /usr/bin/xcrun -sdk iphoneos PackageApplication -v "${BUILD_DIR}/Release- iphoneos/CITest.app" -o "${DEPLOYMENT_DIR}/CITest.ipa"

Slide 33

Slide 33 text

Demo time

Slide 34

Slide 34 text

Create one more target for static analyzer in each of your projects

Slide 35

Slide 35 text

You'll get

Slide 36

Slide 36 text

Custom iOS frameworks – a more native way to reuse the code

Slide 37

Slide 37 text

A framework is A special kind of NSBundle A directory with a special structure A fat universal binary for BOTH the device AND the simulator

Slide 38

Slide 38 text

MyFramework.framework |-------> MyFramework (universal static library) |------->Headers (symlink) |------->Resources (symlink, optional) |------->Versions Actual files should be here |------------| |------------|--->A (all symlinks lead here) Framework directory structure

Slide 39

Slide 39 text

lipo -create -output Creating a universal binary

Slide 40

Slide 40 text

Thank you for your time You apply Unit tests Automated builds TestFlight deployment You receive Early errors discovery Reduced project risks High application quality

Slide 41

Slide 41 text

Contacts Oleksandr Dodatko mail/jabber : [email protected] Skype : [email protected] Github page : https://github.com/dodikk https://github.com/EmbeddedSources