I've created an app for visionOS that uses a custom package that includes RealityKitContent as well (as a sub-package). I now want to turn this app into a multi-platform app that also supports iOS.
When I try to compile the app for this platform, I get this error message:
Building for 'iphoneos', but realitytool only supports [xros, xrsimulator]
Thus, I want to exclude the RealityKitContent from my package for iOS, but I don't really know how. The Apple docs are pretty complicated, and ChatGPT did only give me solutions that did not work at all.
So I am trying my luck with the real guys instead
Here's my Package.swift file:
// swift-tools-version: 5.10
import PackageDescription
let package = Package(
name: "Overlays",
platforms: [
.iOS(.v17), .visionOS(.v1)
],
products: [
.library(
name: "Overlays",
targets: ["Overlays"]),
],
dependencies: [
.package(
path: "../BackendServices"
),
.package(
path: "../MeteorDDP"
),
.package(
path: "Packages/OverlaysRealityKitContent"
),
],
targets: [
.target(
name: "Overlays",
dependencies: ["BackendServices", "MeteorDDP", "OverlaysRealityKitContent"]
),
.testTarget(
name: "OverlaysTests",
dependencies: ["Overlays"]),
]
)
I don't really see what's complicated about the Apple docs?
Off the top of my head:
.target(
name: "Overlays",
dependencies: [
"BackendServices", "MeteorDDP",
.product(name: "OverlaysRealityKitContent", condition: .when(platforms: [.visionOS]))
]
),
1 Like
Thanks. Unfortunately, it does not work. It expects an additional "package" string. I tried to set this to "OverlaysRealityKitContent", but this won't compile either.
As a side-note: Any combination I tried before where this was still included
dependencies: [
...
.package(
path: "Packages/OverlaysRealityKitContent"
),
],
lead to the error message
Building for 'iphoneos', but realitytool only supports [xros, xrsimulator]
Not sure if patching the targets alone will fix this.
(Regarding the Apple docs in general: I really don't think they are comprehensible. Way too scarce, and almost always without concrete usage examples. I struggled with this a lot when I started learning Swift (and especially SwiftUI for visionOS). I have a decent development background as a full stack web dev with a lot of different frameworks, plus C# and Unity, and I think Apple's docs are by far the worst I've seen so far. Even worse than Unity's, actually.)
For the package
argument, you can try explicitly specifying the package name of your dependency.
dependencies: [
...
.package(
name: "OverlaysRealityKitContent",
path: "Packages/OverlaysRealityKitContent"),
]
I don't know of a way to prevent Xcode (or SwiftPM) from trying to compile an unused dependency. I haven't played with realitytool
either so I don't think I can help you on that side.
As for Apple docs, I now understand what you meant and certainly agree! They're barely useful, usually sparse and lack pretty much all of the critical information one might need. Sorry I have a lot of frustration with them.. I usually need to check the Cocoa documentation archive (or man
pages!).
1 Like
Thanks, this resolves the package resolution, but I still get the error message about the realitytool
.