iosswiftwatchkitapple-watch-complicationwatchos-5

transferCurrentComplicationUserInfo is unavailable for WCSession?


This is as straightforward as is sounds; when I try to use session.transferCurrentComplicationUserInfo(_:), I get the error message written in the title, word for word.

Looking at the documentation (transferCurrentComplicationUserInfo, WCSession) there's no indication that it's been deprecated... plus, if something is deprecated it says so in the error message and will still show up in Xcode's intellisense (albeight with strikethrough). For me, neither is happening.

So why Xcode saying it's unavailable?

This is my barebones code that causes the error message:

let userInfo: [String:Any] = [:]
let _ = session?.transferCurrentComplicationUserInfo(userInfo)

For some background, I'm using Xcode 10.1 and Swift 4.2. My app's deployment target is iOS 9.3 and my watch extension's is watchOS 4.0.


Solution

  • Probably, you are trying to call it from the Watch Extension, where it appears as unavailable.

    The function transferCurrentComplicationUserInfo can only be called from the iOS app.