How to Use RealityKitContent Package for App Targets Lower Than iOS 18.0

I am trying to display a 3D model in iOS app using RealityView. The same 3D model is displayed successfully in the visionOS app. Everything works perfectly only when I set my project’s minimum deployment target to iOS 18.0.

However, my app’s minimum deployment target is iOS 15.0. When I use the RealityKitContent package to load the 3D model, it fails to compile and gives me the following error:

Compiling for iOS 15.0, but module 'RealityKitContent' has a minimum deployment target of iOS 18.0: /Users/Library/Developer/Xcode/DerivedData/RealityViewForiOS-cbfkgimsqngtuegqwvezusvscllf/Index.noindex/Build/Products/Debug-iphonesimulator/RealityKitContent.swiftmodule/arm64-apple-ios-simulator.swiftmodule

I have made the RealityKitContent package optional and tried importing using the following condition:

#if canImport(RealityKitContent)
import RealityKitContent
#endif

Despite this, it still fails to compile and produces the same error. I have not found a workaround for using the RealityKitContent package with app targets lower than iOS 18.0.

Here is my package definition:

let package = Package(
    name: "RealityKitContent",
    platforms: [
        .visionOS(.v1),
        .macOS(.v15),
        .iOS(.v18)
    ],
    products: [
        .library(
            name: "RealityKitContent",
            targets: ["RealityKitContent"]),
    ],
    dependencies: [],
    targets: [
        .target(
            name: "RealityKitContent",
            dependencies: []),
    ]
)

Here is the code I am using to load the 3D model with RealityView using the RealityKitContent package:

import SwiftUI
import RealityKit
#if canImport(RealityKitContent)
import RealityKitContent
#endif

struct ContentView: View {
    var body: some View {
        VStack {
            if #available(iOS 18.0, *) {
                RealityView { content in
                    if let scene = try? await Entity(named: "Scene", in: realityKitContentBundle) {
                        content.add(scene)
                    }
                } update: { content in
                    if let scene = content.entities.first {
                        let uniformScale: Float = 3.0
                        scene.transform.scale = [uniformScale, uniformScale, uniformScale]
                    }
                }
            } else {
                // Fallback for earlier versions
            }
        }
    }
}

#Preview {
    ContentView()
}

Any help or guidance on how to use the RealityKitContent package for app targets lower than iOS 18.0 would be greatly appreciated.