I have my RCP project imported as a Swift package using the following structure and the package has been added to the target as a Library in Xcode:

Note since taking this screenshot, I have added a 'Resources' folder to 'Sources', containing a dummy file, and referenced this in the Package manifest, so that Bundle.module works correctly and doesn't throw an inaccessible due to internal protection level error (a SPM quirk apparently)...
Code as follows.
import SwiftUI
import RealityKit
import ARKit
import RealityKitContent
struct ContentView : View {
var body: some View {
ARViewContainer().edgesIgnoringSafeArea(.all)
}
}
struct ARViewContainer: UIViewRepresentable {
typealias UIViewType = ARView
func makeUIView(context: Context) -> ARView {
let arView = ARView(frame: .zero)
let arConfiguration = ARWorldTrackingConfiguration()
arConfiguration.planeDetection = [.horizontal]
arView.session.run(arConfiguration)
// this isn't working, can't find file
let model = try! ModelEntity.loadModel(named: "TestScene.usda", in: realityKitContentBundle)
let anchor = AnchorEntity(.plane(.horizontal, classification: .any, minimumBounds: SIMD2(0.2, 0.2)))
anchor.children.append(model)
arView.scene.anchors.append(anchor)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) {}
}
#Preview {
ContentView()
}
< /code>
Запуск приложения возвращает ошибку, говоря, что оно не может найти testscene.usda. Не уверен, что если я использую правильный метод для этой задачи, я неправильно называю вещи, я не буду что -то связано с тем, как работает Swift Package Manager, или что -то еще. Любая помощь оценена!
Подробнее здесь: https://stackoverflow.com/questions/797 ... ew-for-ios
Мобильная версия