Transcript
Page 1: Building & Maintaining a Family of Applications

Building & Maintaining a Family of Applications

Code Reuse on a Platform that SupportsOne Binary per Application

Page 2: Building & Maintaining a Family of Applications

Jessica KahnTapulous

Page 3: Building & Maintaining a Family of Applications

Why is code reuse important?

Page 4: Building & Maintaining a Family of Applications
Page 5: Building & Maintaining a Family of Applications

14 apps – soon to be 17.Five client engineers.Two server engineers.

Page 6: Building & Maintaining a Family of Applications

I Know What You’re Thinking…

Page 7: Building & Maintaining a Family of Applications

“I don’t have 14 apps in the App Store.”

Page 8: Building & Maintaining a Family of Applications

“My couple of apps aren’t really like one

another at all.”

Page 9: Building & Maintaining a Family of Applications

Oh, so you don’t…

• Use categories or subclasses to extend classes like NSString, UIViewController, or UIWebView?

• Collect analytical data?

• Display advertisements?

• Use Facebook Connect or another third-party library?

Page 10: Building & Maintaining a Family of Applications

Of course you do!What’s the basic methodology you need to apply?

Page 11: Building & Maintaining a Family of Applications

Use a framework…

Page 12: Building & Maintaining a Family of Applications

Psych!

Page 13: Building & Maintaining a Family of Applications

Embed a loadable bundle…

Page 14: Building & Maintaining a Family of Applications

j/k!

Page 15: Building & Maintaining a Family of Applications

Tap Tap Revenge 2 Born by Emergency C-Section

You can’t hide “a baby” inside of an application. We learned this the hard way.

Page 16: Building & Maintaining a Family of Applications

Static library it is.

Page 17: Building & Maintaining a Family of Applications

Drawbacks

• Code size contributed to each product

• No self-containment of resources

• Must update every app to take advantage of a new version of your library

• If you don’t have the source, you have to trust its source

Page 18: Building & Maintaining a Family of Applications

Plusses

• Supported on the iPhone

Page 19: Building & Maintaining a Family of Applications

The Basics

• Create a static library project

• Embed this project into your application project

• Include the library’s resources in your application’s Copy Resources phase

• Set up the proper dependencies and linkages

Page 20: Building & Maintaining a Family of Applications

Demo

Page 21: Building & Maintaining a Family of Applications

One Size Fits MostWhat to do when apps require slightly different

versions of your static libraries.

Page 22: Building & Maintaining a Family of Applications

Why is this needed?

Page 23: Building & Maintaining a Family of Applications

Cosmetic Reasons

Page 24: Building & Maintaining a Family of Applications

Cosmetic Reasons

Page 25: Building & Maintaining a Family of Applications

Different Feature Sets

Page 26: Building & Maintaining a Family of Applications

Different Feature Sets

Page 27: Building & Maintaining a Family of Applications

Modified Behavior

Page 28: Building & Maintaining a Family of Applications

Modified Behavior

Page 29: Building & Maintaining a Family of Applications

• Look up values in the app’s plist(s) and/or strings file(s) at runtime

• Override library methods with app-supplied subclasses or categories

• Override library resources in the app project

• Compile the library in an app- specific way

Tactics for Customization

Page 30: Building & Maintaining a Family of Applications

Demo

Page 31: Building & Maintaining a Family of Applications

Gotchas & Hints

• Remove the default version of a resource from your project, to be sure to override with an app-specific one.

• Add all_load in OTHER_LDFLAGS for your application target, to ensure static library categories are loaded and linked properly.

• Use Xcode project templates.

Page 32: Building & Maintaining a Family of Applications

Demo

Page 33: Building & Maintaining a Family of Applications

Source ControlUsing Subversion to maintain a stable base for

some projects, while developing on the bleeding edge for others.

Page 34: Building & Maintaining a Family of Applications

• svn:externals let you place your application adjacent to all its dependencies, no matter where they really live in the repository

• Trunk is the oft-unstable bleeding edge

• Tags are untouchable

• Branches lie somewhere in between

Page 35: Building & Maintaining a Family of Applications

Demo

Page 36: Building & Maintaining a Family of Applications

Bonus Points!Build and Unit Test Automation

Page 37: Building & Maintaining a Family of Applications

Builds

• Script your own, or…

• Use a continuous integration package:

• BuildBot, Cruise Control & Hudson

• Both require knowledge of xcodebuild

Page 38: Building & Maintaining a Family of Applications

Unit Tests

• ocunit built into the OS X & iPhone developer tools, supported on the Simulator since SDK 2.2

• http://developer.apple.com/tools/unittest.html

• Combine with continuous integration

Page 39: Building & Maintaining a Family of Applications

In Summary…

Page 40: Building & Maintaining a Family of Applications

• Most developers with more than one project can do more to reuse their code

• Spending some time up front saves time in the long run; teach Xcode, svn, and other tools to do the heavy lifting for you

• Development, support, and maintenance costs lowered through “economies of scale” and bug compatibility

Page 41: Building & Maintaining a Family of Applications

Q & A


Recommended