Can’t Make Compound CLKTextProviders with Only Swift

Originator:SlaunchaMan
Number:rdar://22396489 Date Originated:24-Aug-2015 00:19 AM
Status:Open Resolved:
Product:watchOS SDK Product Version:Xcode Version 7.0 beta 5 (7A176x)
Classification:Other Bug Reproducible:Always
 
Summary:
Since Swift 2.0 can’t handle vararg methods from Objective-C, there’s no Swift-only way to call +[CLKTextProvider textProviderWithFormat:].

Steps to Reproduce:
1. Write a complication controller class in Swift.
2. Realize you want to combine time and text.
3. Try to write this code:

let provider1 = …
let provider2 = …

let textProvider = CLKTextProvider.textProviderWithFormat("%@ %@", provider1, provider2)

Expected Results:
textProvider is initialized with the correct text provider.

Actual Results:
The code fails to build with the following error:

'CLKTextProvider.Type' does not have a member named 'textProviderWithFormat'

Version:
Xcode Version 7.0 beta 5 (7A176x)

Notes:
It’s a relatively straightforward workaround to turn this into an Objective-C category: https://gist.github.com/SlaunchaMan/815b3e7214ceb2000e64

I don’t want to have to do that, as I’m writing a Swift-only WatchKit book and this means I need to explain Objective-C and bridging headers.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!