After releasing Discovr Music for OSX a few weeks ago we were pretty impressed with how it went. So for the first time with Discovr Movies we developed the iOS and OS X versions simultaneously.
Here are few tips and tricks we picked up along the way.
1. Use Open Source
There are heaps of open source libraries that are already cross platform, don’t reinvent the wheel and use them!
Here are some of our favs:
- AFNetworking – Block based networking library with NSOperation scheduling.
- JSONKit – Crazy fast and simple to use JSON library.
2. Make Separate Projects For Each OS
You may be tempted to make build both in the same project with different targets. We found it much better to separate into different projects to remove clutter and keep out of each other’s way.
3. Use Source Control
We are big fans of Git and Github, but any source control is better than none.
4. Share Code and Resources
A lot of code and resources (e.g. images) can be shared between each project, so make sure there are separated into different repositories. Some repositories you might have could include ‘Networking’, ‘Resources’, ‘CoreData’ etc.
5. Use Dependency Management
Anyone starting up on the project should be able to get all dependencies with one command. Some good options are:
6. Compile Time Switches
Although it’s not the nicest hack, it’s sometimes a necessary evil:
#if TARGET_OS_IPHONE
// iOS specific code
#else
// Mac specific code
#endif
This also allows you to make your own types for similar classes e.g.
#if TARGET_OS_IPHONE
#define FSImageScalingType UIViewContentMode
#define FSImage UIImage
#else
#define FSImageScalingType NSImageScaling
#define FSImage NSImage
#endif
7. OS X Y Co-Ordinates Are Flipped
By default Y co-ordinates are measured from the bottom in OS X and from the top in iOS. So rely heavily on isFlipped on NSView to make things more consistant:
isFlipped Returns YES if the receiver uses flipped drawing
coordinates or NO if it uses native coordinates.
- (BOOL)isFlipped
Discussion The default implementation returns NO; subclasses
that use flipped coordinates should override this method to
return YES.
8. OpenGL - Same Same, But Different
iOS uses OpenGL ES, which is a subset of the full OpenGL standard used for embedded systems / mobile devices. Our best advice is to work to the lowest denominator (OpenGL ES) and then things should go pretty smoothly on OpenGL.
9 - Redesign the UI / UX For Each OS
Although it's nice to try and keep the UI consistant for your app, it's also really important to build to the advantages of each OS and the way users interact with them. Using a mouse / trackpad is much different to using fingers on a touch screen. You also have to deal with non-fixed resolution on OS X.
Pay attention to the UI guidelines for each OS, make sure you make tap areas big enough on iOS (>44px) etc.
10. Test, Test, Test and then Test some more
Things aren't going to work as you expect when sharing code across platforms, so make sure you test really well. That includes unit tests, beta testing and even continuos integration.
Stuart is the Founder CTO of Discovr



