I'm also seeing this issue. If anyone from the dev team is reading this, the issue appears to stem from some naming inconsistencies when translating the new async/await syntax to obj-c.
Since a Swift function with a completion block is now automatically generating two versions of the function, one with a completion block and one with the async/await syntax, it appears that Xcode is generating two method signatures that are functionally equivalent, but are using slightly different strings for the parameter names. So, I think the string matching logic is treating these as unique, but the compiler sees them as duplicates.
The generated Swift code:
@objc(handleOpenReader:completion:)
func handle(intent: OpenReaderIntent, completion: @escaping (OpenReaderIntentResponse) -> Swift.Void)
@available(iOS 15.0, macOS 12.0, watchOS 8.0, *)
@objc(handleOpenReader:completion:)
func handle(intent: OpenReaderIntent) async -> OpenReaderIntentResponse
The translated Obj-c code:
- (void)handleOpenReader:(OpenReaderIntent * _Nonnull)intent completion:(void (^ _Nonnull)(OpenReaderIntentResponse * _Nonnull))completion;
- (void)handleOpenReader:(OpenReaderIntent * _Nonnull)intent completion:(void (^ _Nonnull)(OpenReaderIntentResponse * _Nonnull))completionHandler SWIFT_AVAILABILITY(watchos,introduced=8.0) SWIFT_AVAILABILITY(macos,introduced=12.0) SWIFT_AVAILABILITY(ios,introduced=15.0);
In the objc code you can see that the two methods use different naming for the completion block. One names it completion and the other names it completionHandler. I suspect this is breaking a script somewhere in the process.
Post
Replies
Boosts
Views
Activity
We actually do have the value WKApplication: true set in the watch target's Info.plist.
In addition, the application installs and works on iOS 16.1, iPad OS 16.1, and iPad OS 15.7, but it fails on iPad OS 14.8 and that's when we get this error reported.
Here's a snippet from our main app target Info.plist:
<key>CFBundleIdentifier</key>
<string>com.ourcompany.ent.projectname</string>
<key>MinimumOSVersion</key>
<string>14.0</string>
and from the watch target:
<key>WKApplication</key>
<true/>
<key>CFBundleIdentifier</key>
<string>com.ourcompany.ent.projectname.watchkitapp</string>
<key>WKCompanionAppBundleIdentifier</key>
<string>com.ourcompany.ent.projectname</string>
<key>MinimumOSVersion</key>
<string>7.0</string>
We have been shipping a watch extension for the past two years, but it's only once we migrated to Xcode 14, turned off bitcode, and created a new single WatchKit 2.0 target (replacing the old WatchKit 1.0 extension) that this error arose.
I'll add my two cents here since I was also hitting this.
It was giving me this error (which I think was a false positive) simply because I wasn't encoding the data correctly.
I was trying to encode using a JSONEncoder when I should have been using a PropertyListEncoder.
Here is a working code snippet:
let encoder = PropertyListEncoder()
let data = try encoder.encode(self.gameData)
let savedGame = try await player.saveGameData(data, withName: "game.data")