A QUICK TAKE ON SWIFT, AND HOW IT PLAYS WITH THE SINCH SDK
Here at Sinch we are of course as thrilled as the rest of the Apple community with the announcement of Swift. Apple has put a lot of effort in making the new Swift programming language and runtime compatible with Objective-C, which will be very important for the adoption of Swift at large. So how would Swift play out with our SDK as it looks today? To find out we compiled our code with Xcode 6 beta 1 and created a brand new shining Swift app.
Apple’s made it very easy to consume Objective-C code from Swift. Because the Sinch SDK is already packaged as a framework bundle (Sinch.framework), it’s as simple as dragging the Sinch.framework into your Xcode project and adding what’s called a bridging header in which the Sinch Objective-C headers are imported.
Initially we discovered some issues with the beta version of Xcode 6. For example we consistently got a bad execution address error internally in the Sinch SDK when run inside our Swift sample app. It was very specifically tied to how we used the Objective-C method -[NSObject methodSignatureForSelector:] and the crash we got looked very much like an issue in the new Swift/Objective-C runtime. This is something we expect Apple to fix in upcoming releases of Xcode.
But until the final release of Xcode 6 and more stable version of the Swift runtime expected later this year from Apple, we’ve released a new version of the Sinch SDK that is even fully compatible with current state of Swift. It’s available in the Sinch iOS SDK 3.1.1 (available via CocoaPods).
So what we have tried so far is using the current Objective-C Sinch SDK from a Swift app using Apple’s recommended approaches for mixing and consuming Objective-C libraries and frameworks in Swift. Looking ahead, we want to provide a pure Swift Sinch SDK where our public APIs and interfaces would be adopted even more to the Swift language in terms of naming conventions and other language constructs.
Our Developer Evangelist Christian has given his take on Swift which you can read about here.