Skip to content

Swift 3

Compare
Choose a tag to compare
@pcantrell pcantrell released this 17 Sep 07:06
· 469 commits to main since this release

Enhancements

This release moves Siesta to Swift 3. The future is here! The flying cars are no doubt imminent.

If your project needs to stick with Swift 2, use the swift-2.2 or swift-2.3 branch.

Breaking Changes

Siesta’s API has been renamed to adhere to the new Swift 3 naming guidelines (mostly, moderated by taste). You’re mostly likely to notice the lowercase enums and slight changes to parameter labels.

Siesta now also takes advantage of new language improvements. Gone is $0.config, which was a hack to work around shortcomings in Swift 2’s inout inference. You can now just use $0 in your configuration closures. Hooray!

For most of the renamings, you’ll see nice friendly deprecations with fixits — or at least helpful error messages. However, there are a few things the compiler will not help you with that you need to be careful of:

  • Three methods of ResourceObserver with default implementations have new names to fit the new naming guidelines. Because they have default implementations, the Swift compiler will not give you any warning if you try to implement them using the old names; they will simply never be called.

    You must search your code yourself for these old methods:

    func resourceRequestProgress(resource: Resource, progress: Double)
    func stoppedObservingResource(resource: Resource)
    func isEquivalentToObserver(other: ResourceObserver) -> Bool
    

    …and replace them with these new ones:

    func resourceRequestProgress(for resource: Resource, progress: Double)
    func stoppedObserving(resource: Resource)
    func isEquivalentTo(observer other: ResourceObserver) -> Bool
    
  • To prevent a name clash, Siesta’s Error is now called RequestError. Most Siesta apps never reference this type directly. However, if yours does, it will now point at Swift’s internal Error instead of Siesta’s, which will cause confusing error messages.

  • Entity is now a generic type, Entity<T>. You can safely change Entity to Entity<Any> to capture the old behavior. That includes your EntityCache implementation.

Known Issues

  • You will get compiler warnings about how “Expression of type 'Request?' is unused.” This is due to a bug in Swift which is apparently already fixed, but the fix is not yet in an official release. If the warnings bother you, you can eliminate them be prefixing the offending statements with _ =; otherwise just wait for the next Swift release.

Since this is the first release for Swift 3, it’s likely that there will be some bumps in the road. Please file issues and send pull requests for any breakages, broken doc links, or outdated sample code you find. And if things are working for you, please tweet to us at @siestaframework and let us know the nifty things you’re building!