JanGorman / Agrume

🍋 A lemony fresh iOS image viewer written in Swift.
MIT License
790 stars 121 forks source link

Live Text interactions that present system controller (like Add Sticker or Share) fail #356

Closed nemecek-filip closed 9 months ago

nemecek-filip commented 9 months ago

Hello,

I am not sure if this is something that Agrume can fix or if it is an issue on Apple's side. I wanted to try creating stickers in my app by enabling the Live Text integration in my Agrume integration.

However when I select subject and pick either "Add Sticker" or "Share" in the popup menu, nothing happens and Xcode shows this error:

Attempt to present <_UIStickerPickerViewController: 0x105c21150> on <GameWidgets.MainTabBarViewController: 0x10480f200> (from <GameWidgets.MainTabBarViewController: 0x10480f200>) which is already presenting <Agrume.Agrume: 0x106048600>.

Maybe it needs this implementation? https://developer.apple.com/documentation/visionkit/imageanalysisinteractiondelegate/3974501-presentingviewcontroller

But I am not sure, haven't been able to google anything similar.

Happy to try to fix this with a PR.

nemecek-filip commented 9 months ago

Just to be clear, this is the "popup menu" I am referring to:

Screenshot 2023-10-31 at 21 09 48

JanGorman commented 9 months ago

Hey, thanks for opening the issue. I think I understand the error message – to be sure, could you share the code that you're currently using to present the sticker controller and how it interacts with Agrume. Thanks!

nemecek-filip commented 9 months ago

Sorry, I probably haven't made it obvious. The UIStickerPickerViewController is some private system one and is managed by the Live Text interaction. Same goes for the popup menu from the screenshots, that is also done automatically.

It seems the system picks the root view controller from window and tries to present the sticker picker or share sheet (UIActivityViewController) from that

JanGorman commented 9 months ago

@nemecek-filip Thanks for the insight. Not super familiar with that API. Could you try on this branch https://github.com/JanGorman/Agrume/tree/image-analysis-interaction and if that fixes your issue? 🙏

nemecek-filip commented 9 months ago

Works great! Thanks 🙌

https://github.com/JanGorman/Agrume/assets/49204469/031c6e7d-e8c3-4eef-9ca0-bbbdd5b49085

JanGorman commented 9 months ago

Happy to hear that! I'll merge it right away and publish a new release. Thanks