Contents

Creating a Reality Composer Pro package in your app

Discover how to add a new or existing Reality Composer Pro project as a package to your app in Xcode.

Overview

If you’re building an app for visionOS or using assets in RealityKit, Xcode provides a tool called Reality Composer Pro to help you create and design 3D content. With Reality Composer Pro, you can store your assets in a dedicated Swift package for a more efficient format.

Reality Composer Pro packages can include assets like images, 3D models, audio, and video files. Assets that you add to your Reality Composer Project are stored in the realitykitcontent.rkassets bundle, whereas the project’s source code resides in the Sources directory. The package also includes a file called Package.realitycomposerpro that contains the Reality Composer Pro project.

Create a visionOS project in Xcode

When you create a visionOS project in Xcode, the editor automatically creates a default Reality Composer Pro project named RealityKitContent.

To create a visionOS project in Xcode, choose either App or Immersive Environmental App under the visionOS template tab.

Then fill in the appropriate options for your new project, as shown in the screenshot below:

[Image]

The new Xcode project contains two folders in the nagivator area: one with the same name as your app and another called Packages containing the Reality Composer Pro package. The RealityKitContent package contains a file called Package.realitycomposerpro that you can select to view a 3D visualization of the project in Xcode’s editor area.

[Image]

You can launch Reality Composer Pro by double-clicking the Package.realitycomposerpro file in the navigator. Alternatively, if you have the file selected in the navigator, you can click the Open in Reality Composer Pro button located in the top right corner of the editor area. Double-clicking on any existing .realitycomposerpro files launches Reality Composer Pro and opens the selected project.

Create a new Reality Composer Pro package in an existing Xcode project

To add a Reality Composer Pro package to an existing Xcode project, you can create a new package with the editor by selecting Xcode > Open Developer Tool > Reality Composer Pro in the menu bar.

[Image]

In the welcome window for Reality Composer Pro, choose Create New Project.

[Image]

Then choose a folder location and name for your Reality Composer Pro project. The project window opens to a new empty scene.

You need to add the package to your Xcode project to use it in your app. In Xcode’s navigation area, Control-click either the Xcode project at the top or a folder underneath it. Choose “Add Files to” in the contextual menu.

[Image]

Locate the Reality Composer Pro project folder in the pop-up window. Choose the project folder containing the Sources folder, Swift file, and Reality Composer Pro file, and click Add.

[Image]

You can then either choose to Copy, Move, or Reference the files in place.

The Xcode project’s navigation area now contains the Reality Composer Pro project package and you can use it in your app.

[Image]

By default, the code in the ContentView loads the 3D Scene from the Reality Composer Pro project into a RealityView within the SwiftUI view.

To learn how to load and view a scene from the Reality Composer Pro bundle in your app, see Building and running Reality Composer Pro scenes in your app.

See Also

Essentials