Porting an existing iOS app with widgets to visionOS

In the process of getting my apps ready for running on visionOS, I seemed to be running into a real problem getting them to run as ‘proper’ visionOS apps because they have widgets.

As you may know, widgets get embedded into the iOS app, so they will become part of the binary and that is the problem. Luckily, I had posted this on Mastodon and got a quick response from the very knowledgeable Steve Troughton-Smith. You can see the fix here. I’m very grateful, as I’m sure I wouldn’t have found this out on my own.

If you can’t see the image or the post goes away, here’s basically what you need to do.

  1. Add the visionOS destination to your app target
  2. Go to the Build Phases section
  3. Go to Embed App Extensions (it may be called Embed Foundation Extensions instead)
  4. In the entry for the widget, click on the filter column. By default, it will probably say all platforms.
  5. Untick all platforms and ensure all the platforms you want apart from visionOS are ticked.
  6. Compile your app into a visionOS app
  7. Optionally remove all references in your targets to ‘designed for visionOS’ from your targets. In particular, you may find your widget will have this target, as it is pointless now.

And that’s it, you can now have the look of visionOS for your app and take advantage of the new features.