Swift 3 Migration issues

This is a post that I'll be updating continuously with all the bumps that I find on the way while developing with Swift 3 and iOS 10.


CloudKit's database fetchAll methods are missing annotations on Swift 3

Swift 3 API design guidelines favor clarity over brevity. To accomplish that, many of the API's that we interact with on a daily basis changed radically.

For instance, this method that we've known for a long time:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)

changed to:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)

These changes are important as help us write more legible code.

On Apple's CloudKit framework, with Swift 2, you could call

func fetchAllRecordZonesWithCompletionHandler(_ completionHandler: ([CKRecordZone]?,
                                                       NSError?) -> Void)

to get all Record Zones for a given database, or call

func fetchAllSubscriptionsWithCompletionHandler(_ completionHandler: ([CKSubscription]?,
                                                         NSError?) -> Void)

to get all Subscriptions.

However, the API changes on Swift 3, now both methods are named almost the same, with the completion handler's parameters types being the only ones that change:

func fetchAll(completionHandler: ([CKRecordZone]?, NSError?) -> Void) // to get Record Zones
func fetchAll(completionHandler: ([CKSubscription]?, NSError?) -> Void) // to get Subscriptions

Trying to use any one of those functions make the compiler choke because it doesn't have enough information to know what you're trying to fetch, unless you type the parameters yourself:

db.fetchAll { (zones: [CKRecordZone]?, error) in
    // ...
}

To me, this is a clear example where the API design guidelines are not being respected, favoring brevity over clarity.

Submitted as rdar://26977470.