Inspecting iOS State Restoration Data

State preservation and restoration allows iOS apps to save state when they’re sent into the background, and restore that state if the app is killed and then relaunched. If you’ve ever implemented state restoration yourself, you may have run into a case where it’d be helpful to see exactly what state iOS was storing.

It turns out that Apple actually provides a tool to help you do just this, but it’s kind of hidden away and documentation is relatively sparse. Fortunately, it’s pretty easy to use. When you run it, it’ll output a structured plist showing all of your encoded objects, their restoration identifiers, and restoration class information. Here’s a step by step guide.

Continue reading “Inspecting iOS State Restoration Data”

WWDC 2016 Developer Tidbits

A collection of some of the smaller Xcode, iOS, and watchOS changes I’ve come across whilst reading Apple’s updated developer documentation during WWDC.

There were some nice announcements from Apple at WWDC yesterday, including a revamped lock screen and notifications for iOS, SiriKit, and a lot of iMessage integration. Whilst scouring the newly-released developer documentation I’ve come across a lot of interesting tidbits that aren’t headline features on their own, so I thought I’d collect them here in case they’re of use to anyone else. In no particular order:

Xcode

  • Some nice improvements to Interface Builder. You can now edit your UI at any zoom level (FINALLY)! The UI for customizing layouts for different device traits has also been revamped, and looks really good.
  • Image and colour literals are now supported in Swift code, including code completion for images that’re in your asset catalog. Simply start typing either color or UIImage.
  • There’s a new monospaced code font in Xcode: SF Mono that seems to match up with the WWDC promo material this year.
  • The simulator features a special version of the Messages app which allows you to see both halves of a conversation between two users. Very useful for testing all the iMessage newness.
  • Xcode 8 supports both Swift 2.3 and Swift 3. If you choose Swift 2.3 for a project, there’s a new build setting that gets set to Yes: “Use Legacy Swift Language Version”.
  • The new memory debugger looks incredible. You can visualize the current object graph, and it can help identify memory leaks / retain cycles.
  • Xcode now highlights the active line when editing.

Foundation

Notifications

  • The User Notifications UI framework lets you customize the appearance of local and remote notifications when they appear on the user’s device.
  • You can also intercept push notifications (through UserNotifications.framework) and handle them before they alert the user. For example, you could download a video and then tell the user it’s ready.
  • Rich notifications are currently only optimized for 3D Touch, and they’ll be providing access to functionality for users of other iPhone models / iPad at a later date.
  • A lot of the existing remote and local notification methods on UIApplication (as well as UILocalNotification itself) are now deprecated in favour of the UserNotifications framework.

UIKit

Core Data

  • NSPersistentContainer looks like it might replace the simple CoreDataStack class I’d add to most new projects. It encapsulates the whole core data stack, and has convenience methods for creating new background contexts and performing background tasks.
  • NSManagedObject gets a few new methods – init(context:), fetchRequest(), entity().
  • Xcode should be able to automatically generate classes for Core Data entities, but I’ve been unable to get this to work so far.
  • NSManagedObjectContext now has an automaticallyMergesChangesFromParent property to do the NSManagedObjectContextDidSaveNotification observation and merging automatically.

Swift Playgrounds

  • On iPad, XCPlayground is replaced by PlaygroundSupport.
  • You can record videos of coding sessions right inside the app (in the Share menu).

watchOS

  • Glances have gone completely in watchOS 3. Your app should now display and update glanceable information when the user has it in their Dock.
  • If the user has your complication on their watch face, your app will be kept in a ready-to-launch state.
  • WKCrownSequencer lets you directly access information about the crown’s state – whether it’s rotating, how fast, and when it’s stopped.
  • SpriteKit and SceneKit on the watch is cray-cray. The State of the Union contains a cool demo where a notification on the watch contains an animated 3D SceneKit scene.
  • You can now access information about the watch’s orientation, crown position, wrist location, etc in WKInterfaceDevice
  • If you’re using a watch app, whenever you lower and raise your wrist, you’ll get taken right back into the app, for up to 8 minutes.

SiriKit

  • SiriKit is limited to only certain domains:
  • Audio or video calling
  • Messaging
  • Sending or receiving payments
  • Searching photos
  • Booking a ride
  • Managing workouts

Misc

  • If you’ve indexed content for your app with Core Spotlight, you can now search it programmatically in-app using CSSearchQuery. A user can also continue a Spotlight search inside your app.
  • Speech recognition is now possible, through the Speech framework and SFSpeechRecognizer.
  • You can set an expiry or exclusions for pasteboard data for the new universal clipboard.
  • iOS 10 drops support for the iPhone 4S, iPad Mini, iPads 2 and 3, and the 5th generation iPod touch.

Calculating App Store Spend

I like buying apps. Perhaps it comes from being an app developer myself, but I like to pay for apps that I enjoy and that I get value from. Designing and building an app takes a huge amount of work, and I hope that paying for an app means that it’s more likely to receive updates in the future.

I’ve recently had a couple of conversations with people who have never paid for an app, which made me curious about just how much I’ve spent over the years. Unfortunately Apple provides no easy way to see this information. but they do send out regular receipt emails when you make a purchase. I’ve always archived these emails in my Gmail account, so I put together a small script to parse them and produce some figures. I mentioned it on Twitter and a number of people showed interest in it, so I thought I’d reproduce it here.

The steps below outline how I retrieved my own emails and ran the numbers; of course, everybody’s setup is different but hopefully you’ll be able to adapt them to your needs. I use Gmail as my email provider and OS X as my operating system, so all of the instructions are specific to that setup.

  1. First of all, you’ll need to tag all of your iTunes receipts with a unique tag. I have a filter set up for the following search, which tags all matching emails with iTunesReceipts:

    from:(itunes store) subject:(your receipt no.*)

  2. Next, download all of your iTunes receipts as .eml files. I used Gmvault to download mine. Grab the tool and extract it. I used the following command to fetch the relevant emails:

    gmvault sync --type custom --gmail-req "in:iTunesReceipts" your_email_address@gmail.com --no-compression

    By default, Gmvault will download the emails into a directory named gmvault-db/db in your home directory.

  3. Nowcd into the Gmvault db directory. You can then either manually download my parser script from the [Github Gist] and run it, or download and run automatically in a single command:

ruby -e "$(curl -fsSL https://gist.githubusercontent.com/frosty/b6d1615dab5544fc22b0/raw/e4e3b48b032079e188c8d3f246b2609b83995558/parser.rb)"
  1. The script will first ask for the currency symbol your emails will use; it defaults to ‘£’ if you just press enter. It should then output a count and combined spend for iOS apps and in-app purchases. It’ll also create a tab-separated file named Apps.tsv, which will contain a list of all of your purchases. You can open this in a text editor or a spreadsheet app like Numbers if you want to.

Notes

  • The script could probably be much neater, but I don’t work with Ruby very often and I just threw it together in an evening!
  • I make no guarantees that this script catches everything or that it doesn’t pick up any false positives. The iTunes receipt format is quite awkward and inconsistent and has changed quite a lot throughout the years. Based on my own receipts, however, this seems to do a pretty good job.
  • If you have a suggestion for ways to improve the script, feel free to fork it on Github!

So how much have I spent on apps? Turns out, it’s rather a lot. But when I average my spend out over the life of the App Store, and consider the amount of value and enjoyment I get from the various apps and games I’ve bought over the years… I think it’s a pretty good deal.

Ascension: Chronicle of the Godslayer

Ascension: Chronicle of the Godslayer is a card game that has some similarities to the popular Magic: The Gathering collectable card game. My first introduction to Ascension was through its well-received iOS version, which I liked so much that I went straight out and bought a copy of the physical game too1. This is primarily a review of the iOS version, but both versions play exactly the same and are equally enjoyable.

Ascension is a deckbuilding game designed by a former Magic Pro Tour champion. I’ve played a small amount of Magic in the past but was put off by the amount of pre-game preparation that is necessary and the sheer number of cards that are available (although I realise that it’s exactly these elements that draw many people to the game).2 I think Ascension struck a chord with me because it’s reminiscent of Magic but (in my opinion) improves upon it in a number of ways.

Continue reading “Ascension: Chronicle of the Godslayer”

Codify

I love the iPad. It’s casual, immediate, and more intimate than a laptop ever will be. There are wonderful apps available for most activities you could want to do on an iPad: reading, writing, drawing, listening, watching, playing; the list goes on. Much of the time when I want to perform some task (or just relax), I will now reach for my iPad instead of my laptop if possible. However, until now I have been unable to use the iPad for one of my favourite pasttimes: programming1.

Enter Codify. Codify is a new iPad app that lets you create simple games, prototypes and simulations directly on an iPad. You write code in the Lua language using a fantastic code editor (more on that later), with an API that’s very similar to Processing. You can then run that code straight away; play your game, experiment with your prototype, tweak your simulation. It’s fast, easy, impressive, and fun.

Codify project selection screen

Continue reading “Codify”

Helsing’s Fire: Quick iPhone Game Review

Helsing’s Fire is a fun, brilliantly presented, innovative puzzle / arcade game for iOS.

Helsing's Fire screenshots

You play as Van Helsing, on a mission to destroy the foul Count Dracula. To do this, you progress through 90 levels across 3 worlds, all filled with a hordes of monsters. The monsters in each level stand stationary, and are coloured red, blue, or green. To defeat them, you must move your flaming torch, casting rays of light around and between objects scattered across the level. Once your light falls upon the monsters you want to vanquish, you tap one of a selection of coloured potions to match the colour of the monster. This gets tricker as you progress through the game, as you must avoid monsters of a different colour to the potion you’re using. Different types of monster also present other challenges: bats fly around the level once you’ve attacked them, werewolves turn into innocent maidens who you must avoid with your potions, and ghosts turn invisible in your torch’s glare, so you have to remember their locations. The mechanic of casting light and shadows works really well and looks great.

The game is nicely presented, with a good little story, fun characters with humorous dialogue, and catchy gothic tunes to accompany your adventure (I really recommend you play this one with the sound on – or at least the introduction). I especially like the little touches such as the way Van Helsing and his assistant bump fists or high five one another when you finish a level.

The game starts off pretty easy, but there’s a Mario-style difficulty curve where new gameplay elements are regularly introduced, spicing things up a bit.

There are 90 levels in the main campaign mode, including some more arcade-style bosses that fly around the screen and require you to keep your torch on the move to avoid their attacks. Each ‘world’ also has an unlimited, randomly generated survival mode. A recent updated added a new campaign with 30 more levels, some new enemies, and another survival mode arena. I found it to be quite an addictive ‘just one more go’ pick-up-and-play game.

Very good value for 59p – they really should be charging more for this. Highly recommended.

App Store Developer’s website

iPhone Games

I play quite a lot of games on my iPhone. I thought I’d write a quick post to highlight some of the games that I’ve really enjoyed and I keep coming back to. There’s a lot of good stuff out there, but there’s also a lot of rubbish to wade through (either games that are just plain bad, or fun for five minutes and then you’ll never play it again); so here are the ones that have stood the test of time with me. Continue reading “iPhone Games”

iPad Initial Impressions

So, last night I got to play with an iPad for a couple of hours (thanks @davea!) and thought I’d post some of my initial impressions. Obviously these are my thoughts, your mileage may vary.

  • It’s smaller than you probably think it is
  • It’s exactly as big as you thought it was if you were sad enough to make an actual-size cardboard model of it months ago
  • The screen is gorgeous. Really bright, the colours just jump out at you, and the viewing angles are unreal. Photos look brilliant on it, but you see a slight lack of resolution in text when you’re zoomed some way out of a web page.
  • That said, because the screen is a piece of glass, it seemed as though glare could definitely be an issue depending on where you’re sat. I was trying to read Winnie-the-Pooh, and I could just see my face reflected in the screen because I was in the wrong position.
  • It feels really nice in your hand. It’s a good weight (although lighter would be nicer) and it feels reassuringly solid.
  • It’s fast. I’d read all the reviews saying how quick it was, but I didn’t expect it to be quite that quick. Everything just feels so slick and fluid, and I think this is a very big part of why I found it so nice to use.
  • Web browsing and Google maps are just brilliant. Again, there was a lot of hyperbole about how browsing the web on this thing is a totally new experience and you have to try it to understand it – and whilst that’s a little OTT, I kind of get where they’re coming from. It feels very different (in a good way) from anything I’ve used before. For casual web surfing, lay back on the sofa or in a comfy chair, and for actually reading web pages, I think it’ll be brilliant.
  • The Instapaper app was probably the nicest reading experience I came across while trying out the iPad. With the default font settings, it’s totally gorgeous. I could spend hours and hours working my way through my Instapaper reading list on this thing.
  • Reading PDFs is also a pretty great experience. It’s so nice to be able to flick through a PDF, and hold it like a book. A vastly better experience than reading them on a laptop or on my Sony Reader (which is far too slow for PDFs, and they don’t work well with that screen size).
  • Photos look great, and the slideshows work really well. The iPad would make a brilliant digital photo frame whilst not in use.
  • The keyboard surprised me by being much more usable than I was expecting. Portrait mode’s a little cramped, but landscape seems nearly full size. Straight away, I was typing very quickly with very few mistakes. I could see myself inputting a lot of text without the need for an external keyboard. NaNoWriMo 2010, perhaps?
  • It seems a very social device. Sure, we were all interested in trying it out and so it got passed around a lot – but it’s just so easy to spin it round or hold it up to show other people something cool. Or to load up an app and hand it over to someone to play with. It’s very unlike a laptop in that respect.
  • The ‘just a big iPod Touch’ comment that people have made is total crap. iPhone OS on a device this size is a very different experience. The extra screen space adds a lot. Web browsing in particular feels completely different to browsing on an iPhone.
  • My iPhone now seems very small, cramped, and slow.

I liked it, and can’t wait to get one. I think my primary use would be reading – Instapaper, websites, feeds, and PDFs. And I think I would use it a lot for all of those things. In fact, other than coding and managing my photos, I could see it replacing my laptop for a lot of things I do with my computer – namely, using the web, email, etc. And for me, that’d be a good thing – I hate being stuck behind a laptop when all I want to do is read. It’d be a nice distinction, because laptop would be for getting something done (coding, etc), and iPad would be for leisure. The iPad would also come in very hand whilst coding, for reference books, etc.

Momento

I just wanted to share an iPhone app I came across the other day which I’ve totally fallen in love with. It’s called Momento.

Momento is a diary/journaling app, which I guess is fairly self explanatory – you can add text to days in the form of ‘moments’. You can also attach photos to days, as well as tags for people, events, and geolocation information if you wish. Momento also has the ability to passcode your journal, to hide it from prying eyes (the main reason I want an electronic journal rather than a paper one). It’s super-simple to use, which is part of its charm; it gets out of your way and makes journaling easy (low barrier to entry: check!).

You can browse through your entries in a sweet calendar view or flick through individual days. Take a look at the screenshots on the Momento website – this thing is gorgeous. It’s a joy to use, both for writing and reading, and feels pretty damn close to using a paper journal. It brings to mind Tweetie 2 in terms of its visual polish – in fact, it even has that cute little arrow that slides along the tab bar at the bottom of the screen when you change modes, just like Tweetie.

In addition to its kickass-as-it-is journaling functionality, Momento can pull in ‘social moments’ from Twitter, Facebook, Last.fm, and Flickr. Fill in your account details for any of these services, and it’ll show your Flickr uploads, Twitter updates, etc, alongside your handwritten journal entries. In fact, it even grabs this data from the past, so you instantly have a very rough historical journal without having to write anything yourself.

My only real criticism of the app as it is is that there’s no easy / automatic way to export / import data. As it stands, you can email yourself an XML file of your journal entries from within the app, but there’s no way to re-import that data and the export is a manual process. Some kind of sync might be nice. It’s mainly for security purposes, just so I don’t lose my entries – I’m not interested in sharing them with anybody (I have a blog for that!). That said, paper journals don’t have a backup system!

I’ve been using Momento every day for the past week, and it’s brilliant. I’ve been wanting to keep a journal for a long time now, but I’ve never really given it a proper go. I’m intending to carry on with this now I’ve found a great way to do it – I’m going to try and write every day for a month, and then hopefully just keep on writing.