Using Camera Continuity Menu in SwiftUI

I've been trying to follow the "Supporting Continuity Camera in Your Mac App" article to implement the "Import from iPhone or iPad" menu for my MacOS app. I've been able to replicate most of the article in a test AppKit application but cannot do the same in my SwiftUI application.

I'm not sure how to get the "NSMenuItemImportFromDeviceIdentifier" identifier into a SwiftUI Menu or create a NSMenu with a NSMenuItem for a SwiftUI app. I'm also not sure how to handle receiving the image in the SwiftUI environment. Any advice you might have is appreciated. Thanks!

Replies

Hi @thedeveloper4 ,

This is shown here: https://developer.apple.com/videos/play/wwdc2021/10018/?time=1031 where Matt adds

.commands {
            ImportFromDevicesCommands()
        }

To the WindowGroup and then demonstrates how this works.

I also recommend trying out the code shown in this thread: https://forums.developer.apple.com/forums/thread/695137?answerId=770127022#770127022

This will show you how to add the command, show it in the menu bar under File and import it into your app.