Here are three small pieces that I discovered while working on my second major Mac app. It’s for internal use by a client, so I cannot tell you about it, but it is a great place for me to learn more about the various oddities you find when developing for the Mac platform.
If you use CoreData then you will probably face the problem of database migration sooner or later. Automatic migration is turned on easily, but how can you be reasonably sure that your fresh app update will still be able to open databases using the old schema? Like when people were using the app and are now installing your update that needs more entities.
We were beginning to face this scenario in multiple apps, so we started unit testing CoreData automatic migrations like I’m going to show in this article.
There are a few trailblazing developers out there who intentionally set their app’s deployment target to iOS 6. When dealing with open source libraries like DTCoreText this might give you a fair share of deprecation warnings. But there is also another problem caused by this that library vendors need to address.
The SDK used should always be the Latest iOS, but the Deployment Target setting tells the compiler and linker at what level of fanciness it can enable the turbo features.
There once was a developer who figured that it would make sense to not reinvent the wheel, or at least not all 4 that he needed for his app/car. He had previously learned how to contribute to open source projects on github and wrapped his head around git submodules. As long as you stay in the git ecosystem all is bliss, submodules contain Xcode projects which are easily added as sub-projects.
The big advantage of sub-projects is that you can debug into these and if you fix something you can easily push that back to the master repository. But this convenience brings with it a drawback: since you have to keep a copy of each sub-module in each project structure that needs them you risk ending up with many different versions of many different components all over your file system.
Let’s say you are building an app that does some sort of file handling where you want to be able to open any and all file types in your app. When your app then launches it would do something with the file, like upload it to a server.
I was not quite certain how to achieve this effect myself, so I turned to Dropbox who are doing exactly that. If you have the Dropbox iOS app install you can open any file in Dropbox. Then you can choose where to put it in your online storage.
How did they do that? Did they register for a truckload of file types? Or is there a shortcut that I didn’t know about yet?
I had my PDF experiments inside DTFoundation. Those included a rather large (compared to the other source code) PDF file I was using for testing and the Demo. The problem with this was that I’m using DTFoundation almost everywhere now, being the central repository for all my generally reusable code.
Because of this file every cloning of the repository would take forever. So I decided to split the PDF stuff into its own repository and I deleted the file. However – since git keeps all history forever – the clones would still take long.
While developing away on my iCatalog Editor I found what I believe to be the first instance in my career as developer where Auto-Layout actually saves me a lot of work.
Before Auto-Layout you would have to calculate view frames and apply them, usually in a layoutSubviews on iOS. The problem being that it usually takes lots of experimentation to get all the cases right.
In my use case I wanted to create a panel for my Mac app that would dynamically adjust to an optional icon on the left side and an optional cancel button on the right, with a progress bar in between. Auto-Layout (after some initial non-understanding on my part) made this a sinch.
While I am exploring constraints for a Mac app, the exact same methods also apply for iOS development.
Apple provides extensions for NSValue to store most CoreAnimation-related structs in there: CGAffineTransform, UIEdgeInsets, CGPoint, CGSize, CGRect, UIOffset. And of course the inverse methods for getting the structs back out.
This is quite useful if you need to store these structs in an Objective-C container object, like a dictionary. On Mac I found these methods missing, even though I needed to put an affine transform into a object property.
Fortunately NSValue can easily be extended to handle any kind of custom struct.
The last update for SpeakerClock came out in March 2012, about time that I had a look at a few issues that users have reported and maybe add some fancy new stuff.
With every old app of mine I am looking at I find that I was still using the old paradigm for creating a window and root view controller. Though ever since iOS 6 and the iPhone 5 this has become outmoded.
In this blog post I will have a look at some old code and how it can be properly modernized. Maybe I can give you a slight nudge with it to do the same on some of your own old projects.
Native Mac apps can and should support full screen mode. Apple calls it providing users “with a more immersive, cinematic experience”. While there a a few apps that would not reap any benefit for the user taking over the entire monitor, there are some apps that can benefit from it greatly. In my case a productivity app like iCatalog Editor.