Use of unresolved identifier 'WKExtension'

2019-09-10 08:58发布

问题:

i want to make a phone call from Apple Watch too. I imported WatchKit. Then i put this code in my method:

if let telURL=NSURL(string:"tel:5553478") {
       let wkExtension=WKExtension.sharedExtension()
       wkExtension.openSystemURL(telURL)
}

It shows me an error: Use of unresolved identifier 'WKExtension' in line 2. I don't know what I am doing wrong :/

回答1:

WKExtension is only available on WatchOS 2.0, as you can see from Apple's prerelease reference. So I'm guessing you're either not using Xcode 7 or you're working on a v1.0 watch extension.

Create a new target and choose watch OS > Application.