Reputation: 717
I am building a remote package for home screen Widget. One of the things I needed to do is to add .intentdefinition
file to the package. Because it seems like its not really what Apple expects you to do, I had to trigger and generate code for it manually with help of xcrun intentbuilderc generate ...
This is the setup I ended up with:
It builds and works pretty well. This is how it look like in code:
public struct ViewSizeWidget: Widget {
let kind: String = "ViewSizeWidget"
public init() { }
public var body: some WidgetConfiguration {
IntentConfiguration(
kind: kind,
intent: WorkoutIntent.self,
provider: ViewSizeTimelineProvider(),
content: { entry in
ViewSizeWidgetView(entry: entry)
})
.configurationDisplayName("View Size Widget")
.description("This is a demo widget.")
.supportedFamilies([
.systemSmall,
.systemMedium
])
}
}
So far so good. The problem starts, when I add the remote package to the main app, add widget to the bundle and try to run the target:
@main
struct WidgetsBundle: WidgetBundle {
var body: some Widget {
ViewSizeWidget()
}
}
WidgetsExtension[1342:248473] Unable to initialize 'WorkoutIntent'. Please make sure that your intent definition file is valid.
WidgetsExtension[1342:248473] [widget] No intent in timeline(for:with:completion:)
WidgetsExtension[1342:248473] [widget] No intent in timeline(for:with:completion:)
I noticed other people had same issues before when doing same thing but with CocoaPods framework. They solved it by coping the intent file to the main app and widget targets as a build step. Here is what I found: here and here
I am not sure if its even possible to copy the intent file from the remote package...
Upvotes: 1
Views: 283