When I try to run CharacterDetail target from the example code of EmojiRangers - Game Status Final from Widgets Code-Along of WWDC20, encountered the following error.
I have been trying to replicate a similar behavior of creating a WidgetBundle in my own SwiftUI 2 app, but faced a similar issues.
I am not an expert in Swift or SwiftUI, but I'm a public beta user nonetheless and have created a handful of apps using the SwiftUI.
My understanding of this problem is, when creating bundle and assigning @main, as per the error messages, Xcode gets confused on which widget to show on the Simulator.
i.e., EmojiRangers app contains EmojiRangerBundle inside LeaderboardWidget.swift. This bundle contains calls to two different widgets: EmojiRangerWidget()
LeaderboardWidget()
I speculate that Xcode is not able to understand which Widget to preview when run on the Simulator.
I hope @apple figures out the solution.
Following is the error message:
SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'com.example.apple-samplecode.Emoji-Rangers.Intermediate' error: Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=2 "Please specify the widget kind in the scheme's Environment Variables using the key '_XCWidgetKind' to be one of: 'EmojiRangerWidget', 'LeaderboardWidget'" UserInfo={NSLocalizedDescription=Please specify the widget kind in the scheme's Environment Variables using the key '_XCWidgetKind' to be one of: 'EmojiRangerWidget', 'LeaderboardWidget'}." UserInfo={NSLocalizedDescription=Failed to show Widget 'com.example.apple-samplecode.Emoji-Rangers.Intermediate' error: Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=2 "Please specify the widget kind in the scheme's Environment Variables using the key '_XCWidgetKind' to be one of: 'EmojiRangerWidget', 'LeaderboardWidget'" UserInfo={NSLocalizedDescription=Please specify the widget kind in the scheme's Environment Variables using the key '_XCWidgetKind' to be one of: 'EmojiRangerWidget', 'LeaderboardWidget'}., NSUnderlyingError=0x7fda3f064360 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=2 "Please specify the widget kind in the scheme's Environment Variables using the key '_XCWidgetKind' to be one of: 'EmojiRangerWidget', 'LeaderboardWidget'" UserInfo={NSLocalizedDescription=Please specify the widget kind in the scheme's Environment Variables using the key '_XCWidgetKind' to be one of: 'EmojiRangerWidget', 'LeaderboardWidget'}}}