- Can the extended code created by Capture Extension call the code of the main project?
- I added the control via Widget Extension and I see the perform method is called in my intent but I am missing the part where this perform method will open the UI to capture the photo.
This is my intent: struct MyAppCaptureIntent: CameraCaptureIntent { static var title: LocalizedStringResource = "MyAppCaptureIntent"
typealias AppContext = MyAppContext
static let description = IntentDescription("Capture photos with MyApp.")
@MainActor
func perform() async throws -> some IntentResult {
let dialog = IntentDialog("Intent result")
do {
if let context = try await MyAppCaptureIntent.appContext {
return .result()
}
} catch {
// Handle error condition.
}
return .result()
}
}
struct MyAppContext: Decodable, Encodable { var data = ContextData() }
struct ContextData: IntentResult, Decodable, Encodable { var value: Never? { nil } } How can I connect this with my LockedCameraCaptureExtension?
- Can you provide a complete demo?
Hello @omo
-
Yes your Capture Extension can include any code from your main project. Add any files you need to both targets in Xcode.
-
All you need to do to your "MyAppCaptureIntent" is add it to all three targets: your app, your capture extension, and your control extension.
You WILL need to make sure your "MyAppCaptureIntent" is added to your control center button!