Tag: dev

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

There’s now NSDateInterval for counting the duration of a time interval, checking whether a date exists in a range, and comparing intervals.

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

There’s a load of new animation APIs: “New object-based, fully interactive and interruptible animation support that lets you retain control of your animations and link them with gesture-based interactions.”

The refresh control is now supported in all scroll views and scrollview subclasses thanks to UIRefreshControlHosting.

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.

When writing code, I generally like to use a dark theme in my IDE or text editor. For Xcode, I really like the Tomorrow Night and Seti themes in particular (both of which can be easily installed using the Alcatraz package manager).

In Xcode, however, there’s a slight problem for dark theme fans:

By default the ‘i-beam’ mouse cursor in the editor is really hard to see, particularly on a high resolution monitor. I’d often find myself losing it and having to shake the mouse to activate El Capitan’s mouse zoom feature.

But there’s a solution! I noticed that Terminal.app’s i-beam cursor has a stronger shadow, which makes it easier to see on dark backgrounds. The cursors are just .tiff image files, so it’s trivial to steal Terminal’s cursor and stick it into Xcode.

If you want to do it manually, you’ll need to copy /Applications/Utilities/Terminal.app/Contents/Resources/ShadowedIBeam.tiff over the top of /Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/Versions/A/Resources/DVTIbeamCursor.tiff. Or you can just run this snippet in Terminal, which will do it for you: