Category Archives: iOS

Saving a PSD file with a .PNG extension 😫

I’ve been working on an update to one of our apps for iOS. Unfortunately as I was updating the launch screens, I inadvertently saved a version for the iPhone 5 as a PSD file, but using the .PNG extension.   I did this by clicking on the old PNG file in the file selector to make sure it was named correctly, but them omitted to clicking on the Save Type drop down list and selecting PNG.

Now, the Mac figured it out, and would display the image in Finder and XCode was happy to load and preview it.  Even the iOS emulator didn’t mind using a PSD file in this way.  However, the actual iPhone was less than happy.

I wasted 3 hours trying to figure out the problem before I spotted my mistake. Surely something on the Mac side should have flagged the file as having a problem – the iPhone can’t load PSD files, why the hell should the emulator!

Yes, I know I saved the file incorrectly, but if it was incorrect, then it should have spewed out some kind of error.  Hopefully I’ll not make this mistake again!

Time to expand my horizons!

I’m going to check out http://www.cocos2d-x.org/ as a cross platform language for some utility work that needs to be deployed on both Android & iOS.  I’d prefer to use Unity, but the client I’m talking with doesn’t want to spring for a full Unity license (turns out you can’t just buy the monthly sub for 4 months, release a product and then cancel…).

Can’t wait – especially given how much I love Javascript </sarcasm>.

 

Apple WatchKit 2.2 – NATIVE apps what are they good for?

We have a workout app that supports the Apple Watch, and it was something that I’d hacked into the original project when the watch first shipped.  It’s a Unity3D based project and back then, adding the Watch target was a real pain, but I managed to get it done and even got it working as best as I could.

One of the major complaints was that the watch didn’t always notify users when a workout ended and a new one would start.  With the original WatchKit there was no way to access the haptic feedback system or even make the watch go ‘bing’. I’d used local notifications to make this happen as best as possible, but iOS decides if it’s going to forward a notification to the watch or not, and there was no way to ensure such forwarding – very haphazard…

Enter WatchKit 2 and NATIVE watch apps.  I was quite excited about this, I’d be able to update the code and fix the biggest complaint the app received from our users.  I’d be able to make the watch buzz and bing on command!

I started this update a few weeks back, and migrated the code to the new WatchKit2 system and had the code run on the watch.  In the simulator, things were working really well, however I was having difficulties in getting the app to actually run on my watch.  Turns out all was not well with my XCode project and the watch wouldn’t validate the binary and run it.  Of course, there was no error popups or feedback to XCode, just silence.

After numerous reboots of everything involved, a pairing of the watch to another test phone, I decided to try a new XCode project just to see where the problem actually was.  That new project built & ran just fine, and when I copied my code & storyboards across from the old project (one file at a time) that also worked as expected.  Huzzah, I had my code running on my watch.  I retired the old XCode project and continued with the new one.

At this point, I was able to run my code on an actual watch.  This was after a frustrating few days of trying everything else to resolve the problems.  So my frustration level was then enhanced when I discovered that an App running on the actual watch is suspended when the watch sleeps, or the user taps the crown to return to the clock display.  This didn’t happen on the simulator!  Some simulation!

It turns out all my previous work was pretty useless.  The App I’d moved to run independently of the attached iPhone does not work as expected.  If I setup an NSTimer to alert the user when it’s time to switch an activity, unless the user keeps the watch alive by tapping the screen, that NSTimer is suspended when the watch sleeps.  The timer never expires, the user is never alerted, and the App fails.

Even if I put all the code back on the iPhone, I can’t even make the watch vibrate and bing when the NSTimer expires, unless the watch happens to be awake when that happens and the user happens to have my App in the foreground.  So I’m back to the unreliable notification system with all the same problems as before.  There really is no point in building an update at this point.

I was pretty excited by WatchKit2, I really thought it would solve the issues I had with the original WatchKit, but it seems that once again, Apple have dropped the ball and not provided a cure.  I know the battery drain is the biggest concern, but seriously, couldn’t you spare enough juice to run one special background timer and let us notify the user when it expires…

Grrrrr.

XCode and the App Store!

While getting ready to update an old App, I realized I needed to update XCode to build to the latest iOS release I’d installed on my phone…

After lots of waiting, watching, clicking and hair pulling, I’ve decided to never ever never update XCode via the App Store again…

Just go to https://developer.apple.com/downloads/ and download it from there – much better and pretty straight forward.  Trust me, you’ll be a lot happier for it.

Ok – FAIR WARNING – XCode 7.3 requires OSX 10.11 or higher (El Capitan), that’s a real bummer for me as I’d been holding off upgrading my Mac – guess I’ve no option now 😡😡😡.

Re-sizing iOS screenshots

While not a perfect solution, grabbing screens at iPhone 6 Plus resolution and then down-scaling for iPhone 6 & iPhone 5 screen sizes is a lot quicker.

To do this I use the mogrify command from the amazingly useful ImageMagick toolset.  However, as the aspect ratio for the iPhone 5 is slightly different to the iPhone 6 Plus, you need to add a ! to the end of the resize options as follows:

mogrify -resize 1136×640! *.png

This will resize the images exactly to the iPhone 5 landscape size, ignoring any aspect ratio, otherwise you get 1136×639, which just won’t do.

For iPhone 6 landscape size I use:

mogrify -resize 1334×750! *.png

Note that mogrify will overwrite the source file, so I make a directory for each size I want and copy the iPhone 6Plus sized files in.

Just as a FYI, the iPhone 6Plus sized images are 2208×1242 (landscaped)