Slide 1

Slide 1 text

The Complexities of iOS Programming Martin De Wulf Betatech Talk, 26/11/2013

Slide 2

Slide 2 text

Who am I? • Background in research (PhD) but turned into developer by the love of code. • 7 years doing research/teaching/programming at the university • 5 years doing web/mobile programming in startups and a web agency (Checkthis, Frontback, Mondial Telecom, “my media is rich”) • 3 years of 
 iOS:

Slide 3

Slide 3 text

I missed the gold rush
 of the app store. I was too busy.

Slide 4

Slide 4 text

iOS • Unix like OS: initially, Apple took Mac OSX and stripped it down. • But they iterated a lot since then. • What is specific to development for iOS?

Slide 5

Slide 5 text

It’s a mobile platform • Network is spotty/ Offline functionalities are hard (iCloud anyone?) • Memory is limited (Over 70MB of RAM, your app will probably be killed by the system) • It is very stateful: no refresh button.

Slide 6

Slide 6 text

Fluidity “60FPS or GTFO” @flyosity

Slide 7

Slide 7 text

How? Use concurrency! Do not do expensive CPU operations, disk accesses or blocking network requests on the main thread. The catches: If you access the UI on a background thread: 
 crashes and freezes Core data constraints Concurrency is hard

Slide 8

Slide 8 text

Objective-C • It’s old, and it shows: the syntax is crummy (but it’s getting better)
 
 [martin willDo:aTalk on:tuesday];
 
 (http://fuckingblocksyntax.com) • But it is quite dynamic (selector, sizzling) • Object model is ok (less complex than C++). • Memory management is ok since ARC

Slide 9

Slide 9 text

How are the APIs? • They date back to 1989: solid, but not that modern. Lots of cruft. “More than one way to do it”. • Lots of C APIs: ABAdressBook, Core graphics (Objc-C method call model has performance impacts)

Slide 10

Slide 10 text

Views layout • It’s a MVC model • Either UI based with Interface Builder or code with absolute positions: No flow engine like in HTML • Text layout is hard: You would be surprised by how much code you need to write to get a label with a red link in a text.

Slide 11

Slide 11 text

- (void)createSoldAttributedString:(NSNumber *)nbDownloads { NSString *soldNumberString = nbDownloads.stringValue; NSString *soldStringPattern = NSLocalizedStringWithDefaultValue(@"accepted.cell.sold.label", nil, [NSBundle mainBundle], @"%@ sold", @"Accepted cell sold text"); NSString *soldString = [NSString stringWithFormat:soldStringPattern, soldNumberString]; self.soldAttributedString = [[NSMutableAttributedString alloc] initWithString:soldString]; [self.soldAttributedString addAttribute:NSFontAttributeName value:textFont range:NSMakeRange(0, [self.soldAttributedString length])]; [self.soldAttributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:135 / 255. green:134 / 255. blue:134 / 255. alpha:1.0] range:NSMakeRange(0, [self.soldAttributedString length])]; [self.soldAttributedString addAttribute:NSFontAttributeName value:textBoldFont range:[soldString rangeOfString:soldNumberString]]; [self.soldAttributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:69 / 255. green:72 / 255. blue:75 / 255. alpha: 1.0] range:[soldString rangeOfString:soldNumberString]]; } is approximatively the equivalent of Sold: 5

Slide 12

Slide 12 text

Backward compatibility? iOS 7 just forced all apps to change their code base to adapt to the new design of the status bar Lots of bugs introduced with iOS7 too.

Slide 13

Slide 13 text

Fighting the system • No long term background activity (battery) unless you’re a VOIP or geo app. • You’re in a sandbox: no general file access, no real inter app communication (no common file system), no customization of the home screen. • Rules for IAPs : 30% to apple for virtual goods.

Slide 14

Slide 14 text

App store review process • From 1 hour to 1 month (Average: 1 week) • No rolling back of buggy versions. • Expedited reviews • Things that were accepted could not be accepted again

Slide 15

Slide 15 text

The doc • Hit or miss quality. No real errors, but the language 
 can be obscure. • Not enough official tutorials • Example code from Apple is of poor quality • Lots of the info is locked in WWDC videos.

Slide 16

Slide 16 text

Other pains • Certificates: you need to sign your apps to launch them on device, to upload them to the app store, to send push notifications, to use IAPs,… • Max 100 devices/account to test • XCode is a UI based programming env.
 Lots of source controle problems with generated
 XML files. • It’s closed source software. Some things are really hard to 
 debug

Slide 17

Slide 17 text

The good parts: • Animations • Text manipulations: unicode, emoji, i18n (date, distances)
 தจ -> zhōng wén (http://nshipster.com/cfstringtransform/) • Photographic manipulation: included filters, face detection, very powerful and efficient (but C). • A new game SDK for 2d games: SpriteKit • Not much fragmentation. • Every user has entered his credit card

Slide 18

Slide 18 text

The good parts (2) • The simulator is fast • XCode is a good IDE (but opinionated) • Tooling: static analysis, profiling and debugger. 
 New: continuous integration • The SDK is getting better by each release (QR Code, Blink, Speech Synthesis, iBeacon, Background fetch in iOS7) • Lots of work available lately.

Slide 19

Slide 19 text

The community • Still rather small (<75 devs in Belgium?). • Not many real indies, most devs are contractors. • Lots of old timers coming from the Mac, which is cool. • No testing culture • Podcast culture • Open source still a bit spotty (e.g. Twitter support as of last June) • Lots of paying tools. • Conferences tend to be expensive (WWDC :-( ).

Slide 20

Slide 20 text

Thanks! @madewulf http://multitasked.net/about.html