iOS Development
BEST PRACTICE
Introduction
•

Christoph Lückler, BSc

•

Software Developer at UP TO ELEVEN

•

Specialization on iOS / OSX Development
...
Portfolio
Topics
•

GIT

•

Continuous Integration

•

Testing & Deployment

•

Xcode - Tips & Tricks
GIT
GIT
•

Distributed version control system

•

Initial release 07.04.2005

•

Strong support for non-linear development

•
...
GIT
•

Pros:
•

Speed

•

Work offline

•

Branching and tagging

•

Customizable
GIT
•

Git objects:
GIT
•

Setup global git config
!

•

Creating aliases
!

•

$ git config --global user.name "Christoh Lückler"
$ git config -...
GIT
•

Creating new repository
$ git init

!

./.git/config
./.git/HEAD
./.git/info/exclude
./.git/description
./.git/hooks...
GIT
•

Adding new files
!

•

Removing a file
!

•

$ echo "This is a new file" > file.txt
$ git add file.txt
$ git commit -m "...
GIT
•

Create new branch:
$ git branch testing
GIT
•

Checkout branch:
$ git checkout testing
GIT
•

Merge branch:
$ git merge testing
GIT
•

Pushing new branch:
$ git push <remote> <branch>

!

•

Deleting remote branch:
$ git push <remote> :<branch>

!

•...
GIT
•

Workflow:
Continuous Integration
Continuous Integration
•

Extreme Programming (XP)

•

Test-Driven Development (TDD)

•

Prevent integration problems

•

...
Continuous Integration
Extreme Programming
•

Short development cycles

•

High frequent releases

•

Pair programming

•

Flat management struct...
Test-Driven Development
Add a test

Run tests see 

new failure

Write some code

Refactor

Run tests 

see all pass
Bots
•

Build, analyze and test apps

•

Need OSX Server 10.9 (XCode Service)

•

GIT & SVN support

•

Build & test stati...
Bots
Jenkins
•

Open Source (http://jenkins-ci.org)

•

Supports several build tools (Maven, LLMV, …)

•

Used in organizations...
Jenkins
Testing & Deployment
Test levels
•

Unit testing

•

Integration testing

•

System testing

•

Acceptance testing (Beta Tests)
Test levels
Unit Tests
•

Test the result not the implementation
(Compare result with specification)

•

White-Box-Test

•

n * functio...
Zoo Keeper Example
https://github.com/OE8CLR/CLZooKeeper.git
Zoo Keeper Example
•

Develop a simple iOS Application that can store
and display animals in one zoo

•

Every animal has ...
Zoo Keeper Example

!

Zoo!

Array *animals;

!

- (void)addAnimal:
- (void)removeAnimal:
- (int)countOfAnimals

!

Animal...
Zoo Keeper Example
Alpha & Beta Testing
•

Alpha Testing:
•
•

Tested by potential users or test team

•
•

Internal user acceptance test

Sh...
TestFlight
•

Free service

•

Distributing apps for Adhoc-Testing

•

Supports Android, iOS and Windows

•

Supervise tes...
Crittercism
•

Free service / Subscription plans

•

Monitor live app performance

•

Collect crashlogs and evaluate them
...
Google Analytics
•

Live statistics from where the app is running

•

Track usage to optimize further releases

•

Gather ...
Google Analytics
Kärnten Card iOS App, 19.06. - 30.09.2013
Xcode - Tips & Tricks
Shortcuts
•

Chose open location: Shift+OPT

•

Open Quickly: CMD+Shift+O

•

Shift between *.m and *.h: CTRL+CMD+↑!

•

C...
Behaviors
Snippets
•

Write code: NSLog(@"<#string#>");

•

Drag and drop into „Code Snippet pane“

•

Edit snippet properties
Interface Builder
•

Select overlapping elements: CTRL+Shift+Click

•

Reuse customized objects (Drag & Drop in Library)

...
Debugger
•

Set Breakpoint and write into Debugger Log:
•
•

Get variables: frame variable

•
•

Print object description:...
Build Targets
•

Build Settings -> Preprocessor Macros

// Initialize Crittercism for crash logging when app is not in deb...
NSNotificationCenter
•

Broadcast notifications within a program

•

Register objects to receive NSNotifications

•

Attach o...
Blocks
•

Apple extension to the C language

•

Encapsulate code like a function
void (^helloWorldBlock)(void) = ^{
NSLog(...
Multithreading
•

Grand Central Dispatch introduced with iOS 4.0

•

After iOS 6.0 automatically retain and release

•

GC...
Documentation
•

Human-readable source code comments

•

Types:
•

@param [param] [Description]

•

@return [Description]
...
Documentation
/**
* Verifies a given pin on the CCMP.
*
* @warning Can throw CCMPException
*
* @param msisdn MSISDN, for e...
Documentation
•

Create documentation with AppleDoc
CocoaPods
•

Dependency management tool

•

Idea comes from JavaEE (Maven)

•

Runs on Ruby

•

Save repository space

•

...
CocoaPods
•

Fix issue with Unit Tests:
•

Project > Info > Configuration

•

Change Base on Configuration File to Pods
References
Beginning iOS 6
Development
•

Released: 9. Jan 2013

•

http://www.iphonedevbook.com
NSHipster
•

Released: 12. Nov. 2013

•

http://www.nshipster.com

first edition

nshipster

NS

obscure topics
in cocoa &...
Stackoverflow
•

Question and Answer site for programmers

•

Most problems are solved

•

Think first, then answer

•

Don’...
Upcoming SlideShare
Loading in …5
×

iOS Development @ FH Kärnten 23.11.2013

944 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

iOS Development @ FH Kärnten 23.11.2013

  1. 1. iOS Development BEST PRACTICE
  2. 2. Introduction • Christoph Lückler, BSc • Software Developer at UP TO ELEVEN • Specialization on iOS / OSX Development • http://github.com/OE8CLR • http://google.com/+ChristophLückler
  3. 3. Portfolio
  4. 4. Topics • GIT • Continuous Integration • Testing & Deployment • Xcode - Tips & Tricks
  5. 5. GIT
  6. 6. GIT • Distributed version control system • Initial release 07.04.2005 • Strong support for non-linear development • Efficient handling of large projects • Toolkit-based design
  7. 7. GIT • Pros: • Speed • Work offline • Branching and tagging • Customizable
  8. 8. GIT • Git objects:
  9. 9. GIT • Setup global git config ! • Creating aliases ! • $ git config --global user.name "Christoh Lückler" $ git config --global user.email christoph.lueckler@ut11.net $ git config --list $ git config --global alias.slog "log --oneline --graph" $ git config --global alias.st "status" $ git config --global alias.unstage "reset HEAD" Clone repository $ git clone https://github.com/git/git.git OfficialGit
  10. 10. GIT • Creating new repository $ git init ! ./.git/config ./.git/HEAD ./.git/info/exclude ./.git/description ./.git/hooks/applypatch-msg.sample ./.git/hooks/commit-msg.sample ./.git/hooks/post-update.sample ./.git/hooks/prepare-commit-msg.sample ./.git/hooks/update.sample ./.git/hooks/pre-commit.sample ./.git/hooks/pre-rebase.sample ./.git/hooks/pre-applypatch.sample
  11. 11. GIT • Adding new files ! • Removing a file ! • $ echo "This is a new file" > file.txt $ git add file.txt $ git commit -m "Added a new file" $ git rm file.txt $ git commit -m "Removed a file" Change a file $ echo "Changed text" >> file.txt $ git add file.txt $ git commit -m "Changed a file"
  12. 12. GIT • Create new branch: $ git branch testing
  13. 13. GIT • Checkout branch: $ git checkout testing
  14. 14. GIT • Merge branch: $ git merge testing
  15. 15. GIT • Pushing new branch: $ git push <remote> <branch> ! • Deleting remote branch: $ git push <remote> :<branch> ! • Pushing new tag $ git push <remote> <tag>
  16. 16. GIT • Workflow:
  17. 17. Continuous Integration
  18. 18. Continuous Integration • Extreme Programming (XP) • Test-Driven Development (TDD) • Prevent integration problems • Continuous builds • Automate distribution
  19. 19. Continuous Integration
  20. 20. Extreme Programming • Short development cycles • High frequent releases • Pair programming • Flat management structure • Good structured code
  21. 21. Test-Driven Development Add a test Run tests see 
 new failure Write some code Refactor Run tests 
 see all pass
  22. 22. Bots • Build, analyze and test apps • Need OSX Server 10.9 (XCode Service) • GIT & SVN support • Build & test statistics (GUI) • Manage Bots via Log Navigator or Web Browser
  23. 23. Bots
  24. 24. Jenkins • Open Source (http://jenkins-ci.org) • Supports several build tools (Maven, LLMV, …) • Used in organizations (Facebook, Yahoo, Dell, …) • Easy installation • Plugin support
  25. 25. Jenkins
  26. 26. Testing & Deployment
  27. 27. Test levels • Unit testing • Integration testing • System testing • Acceptance testing (Beta Tests)
  28. 28. Test levels
  29. 29. Unit Tests • Test the result not the implementation (Compare result with specification) • White-Box-Test • n * functions == n * tests • Method could contain bugs • Prevent new issues
  30. 30. Zoo Keeper Example https://github.com/OE8CLR/CLZooKeeper.git
  31. 31. Zoo Keeper Example • Develop a simple iOS Application that can store and display animals in one zoo • Every animal has a firstname, lastname, nickname and birthday • The user should be able to add and remove animals from the zoo
  32. 32. Zoo Keeper Example ! Zoo! Array *animals; ! - (void)addAnimal: - (void)removeAnimal: - (int)countOfAnimals ! Animal! String *firstName; String *lastName; String *nickName; NSDate *birthdate; ! - (NSString)name - (int)age
  33. 33. Zoo Keeper Example
  34. 34. Alpha & Beta Testing • Alpha Testing: • • Tested by potential users or test team • • Internal user acceptance test Should be done before beta testing Beta Testing: • External user acceptance test
  35. 35. TestFlight • Free service • Distributing apps for Adhoc-Testing • Supports Android, iOS and Windows • Supervise testers • Own SDK to monitor app performance
  36. 36. Crittercism • Free service / Subscription plans • Monitor live app performance • Collect crashlogs and evaluate them • Github issue integration
  37. 37. Google Analytics • Live statistics from where the app is running • Track usage to optimize further releases • Gather device information • Custom variables available • Can track crashes and exceptions
  38. 38. Google Analytics Kärnten Card iOS App, 19.06. - 30.09.2013
  39. 39. Xcode - Tips & Tricks
  40. 40. Shortcuts • Chose open location: Shift+OPT • Open Quickly: CMD+Shift+O • Shift between *.m and *.h: CTRL+CMD+↑! • Comment current line: CMD+Shift+7! • Move focus: CMD+J! • CMD+U | CMD+B | CMD+R | CMD+.
  41. 41. Behaviors
  42. 42. Snippets • Write code: NSLog(@"<#string#>"); • Drag and drop into „Code Snippet pane“ • Edit snippet properties
  43. 43. Interface Builder • Select overlapping elements: CTRL+Shift+Click • Reuse customized objects (Drag & Drop in Library) • Jumping to class: CMD+DoubleClick! • Autolayout: Don’t think too difficult
  44. 44. Debugger • Set Breakpoint and write into Debugger Log: • • Get variables: frame variable • • Print object description: expr -o -- [ObjectName] Thread list: thread list Hover to object in code to get details in GUI
  45. 45. Build Targets • Build Settings -> Preprocessor Macros // Initialize Crittercism for crash logging when app is not in debugging mode #ifndef DEBUG [Crittercism enableWithAppID:@“ABC0815”]; #endif
  46. 46. NSNotificationCenter • Broadcast notifications within a program • Register objects to receive NSNotifications • Attach objects or information to notification • Every cocoa program has it’s own defaultCenter ! [[NSNotificationCenter defaultCenter] postNotificationName: @"sentPinResponseRecieved" object: bop.response]; [[NSNotificationCenter defaultCenter] addObserver: selector: name: object: self @selector(pinSentNotification:) @"sentPinResponseRecieved" nil];
  47. 47. Blocks • Apple extension to the C language • Encapsulate code like a function void (^helloWorldBlock)(void) = ^{ NSLog(@"Hello World"); }; helloWorldBlock(); int (^returnNumberBlock)(void) = ^{ return 42; }; int value = returnNumberBlock();
  48. 48. Multithreading • Grand Central Dispatch introduced with iOS 4.0 • After iOS 6.0 automatically retain and release • GCD is a C level API -> No exception handling • Queuing tasks for dispatch (Multithreading) • 3 Queue-Types
  49. 49. Documentation • Human-readable source code comments • Types: • @param [param] [Description] • @return [Description] • @see [selector] • @warning [Description]
  50. 50. Documentation /** * Verifies a given pin on the CCMP. * * @warning Can throw CCMPException * * @param msisdn MSISDN, for example: 436766688000 * @param pin PIN, for example: 1234 */ - (void)verifyMsisdn:(NSNumber *)msisdn withPin:(NSString *)pin NS_AVAILABLE_IOS(6_0);
  51. 51. Documentation • Create documentation with AppleDoc
  52. 52. CocoaPods • Dependency management tool • Idea comes from JavaEE (Maven) • Runs on Ruby • Save repository space • Tutorial | Xcode Plugin
  53. 53. CocoaPods • Fix issue with Unit Tests: • Project > Info > Configuration • Change Base on Configuration File to Pods
  54. 54. References
  55. 55. Beginning iOS 6 Development • Released: 9. Jan 2013 • http://www.iphonedevbook.com
  56. 56. NSHipster • Released: 12. Nov. 2013 • http://www.nshipster.com first edition nshipster NS obscure topics in cocoa & objective-c mattt thompson
  57. 57. Stackoverflow • Question and Answer site for programmers • Most problems are solved • Think first, then answer • Don’t believe everything

×