I wrote an app for visionOS and I decided I want to add iOS and iPadOS support for the app. I added iPad and iPhone for supported destinations, but when I try to build it via the iPhone or iPad simulator, I get error:
Building for ‘iphonesimulator’, but realitytool only supports [xros, xrsimulator]
Nothing in my code is specific to visionOS and I can’t see anything mentioning realitytool. I’ve tried messing around with build architecture settings, but nothing seems to work.
2
Answers
I faced the same issue when trying to port a visionOS-only app to iPhone and iPad. This is because you need to modify the build phases of your target so that it only loads RealityKitContent when on visionOS, not on iOS. Here’s how to fix it:
Next, you’ll likely have different build errors, like "No such module ‘RealityKitContent’". To fix this, you’ll want to replace the import statement from
to
@benb suggestion makes totally sense, but it seems there’re are still some bugs here. According to this thread, this block:
May be incorrectly parsed, and apparently adding an extra line break might help:
But even with the extra line break, I needed to create a separate target for
iOS
(the#if
directive is still needed, though).