Ad

Our DNA is written in Swift
Jump

Category Archive for ‘Recipes’ rss

Digging into CocoaPods

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.

Read more

Open In … All Files

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?

Read more

Changing History … Git’s

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.

Read more

First Good Auto-Layout Use-Case

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.

Read more

NSValue for Custom Structs

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.

Read more

Revisited

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.

Read more

The Lion’s Full Screen Mode

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.

Read more

In-House Mac App Distribution with Sparkle

Last Friday I felt the time being ripe – after over a month of intense work – to roll out the first 1.0 version of iCatalog Editor. This Mac app is meant to revolutionize the work flow of creating digital catalog editions at my partner International Color Services. All those people who are are tasked with converting the raw material for paper catalogs into their feature-rich interactive digital counterparts where lacking such a tool for the past two years.

Not any more. Two years ago I had promised that there would be a Mac-based editor, but until now I was lacking the guts to dive into Mac development. I was afraid that my iOS development knowledge would not do me any good and that being an iOS development pro wouldn’t do me any good on the big intimidating Mac platform.

It turned out to be an unfounded fear. There are quite a few pitfalls, but I am pretty sure any experienced iOS developer can put together a good-sized Mac app in about a month or so. That’s what I did.

Development goes on, but from here on forth I will bunch fixes and new features together in releases that I need to push out to the guys and girls using the Editor app. Since it is sharply targeted at the unique needs of ICS I abandoned an earlier thought of putting it on the Mac app store. So how would I go about releasing the updates in a way that is as convenient as the app store, but would allow me to supply only the select group of Catalog Editors?

The answer to this question is: the same way most professional apps had been distributed before there ever was a Mac app store: Sparkle.

Read more

Fusion Drive for Everybody!

… well, almost. Of course you need to have both an SSD drive as well as an HDD drive present in your system. I just bought this Mac in April, 7 months ago. And of course I had gotten the dual drive option with a 256 GB SSD plus a 1TB HDD.

Manually having to manage what to place where is a pain. When I started to run out of space on the SSD I had moved my user folder to the HDD which was mounted at /Volumes/HDD effectively negating any speed benefit I would have gotten for working with my files. Like, for example, building apps since all my project files are located there as well.

Changing the Xcode temp folder wouldn’t net much of a measurable benefit as well, the bottleneck seems to be loading the project files from disk.

My heart jumped when I heard that Apple had invented the FusionDrive technology promising to end these managing pains.

Read more

A Quick Method to Get Launch Images

I was procrastinating creating launch images for a several of my apps until now. Apple recommends that apps should have launch images that look somewhat like the app UI, but empty so that it feels to the user like the app is starting up faster. Because of the very same laziness I put a splash screen on one of my apps.

Splash screens made a little more sense back in the days when launching an app might take around 5 seconds, of if you where using a technique to artificially prolong the display of the launch image and then have it animate away, like DTSplashExtender. In the very rarest of cases you need a splash screen if there is some legal stuff you want to get off your chest before letting the user play with the app.

Of course most professional developers would have the launch image be also created by their designer. I cannot afford such an extravagance, so I came up with the quick method I am describing in this blog post.

Read more