skip to Main Content

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


  1. 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:

    1. Click on the root of your project in the project navigator.
    2. Go to your target.
    3. Go to the "Frameworks, Libraries, and Embedded Content".
    4. On the "RealityKitContent" row, click on the filters icon next to "Always Used", uncheck "All Platforms" and check only "visionOS".

    See the screenshot for reference.

    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

    import RealityKitContent
    

    to

    #if os(visionOS)
    import RealityKitContent
    #endif
    
    Login or Signup to reply.
  2. @benb suggestion makes totally sense, but it seems there’re are still some bugs here. According to this thread, this block:

    import SwiftUI
    #if os(visionOS)
    import RealityKit
    import RealityKitContent
    #endif
    

    May be incorrectly parsed, and apparently adding an extra line break might help:

    import SwiftUI
    
    #if os(visionOS)
    import RealityKit
    import RealityKitContent
    #endif
    

    But even with the extra line break, I needed to create a separate target for iOS (the #if directive is still needed, though).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search