I am struggling with setting up a Swift Package that supports multiple platforms (iOS and tvOS in my case) and also depends on a platform-specific library (iOS in my case).
Despite adding a
condition property to the platform-specific dependency, I can only build my library for the platform supported by the dependency.
Package.swift looks like this:
// swift-tools-version:5.4 import PackageDescription let package = Package( name: "Demo", platforms: [ .iOS(.v14), .tvOS(.v14), ], products: [ .library( name: "Demo", targets: ["Demo"] ), ], dependencies: [ .package( name: "Firebase", url: "https://github.com/firebase/firebase-ios-sdk.git", .exact("8.1.1") ), ], targets: [ .target( name: "Demo", dependencies: [ .product( name: "FirebaseAnalytics", package: "Firebase", condition: .when(platforms: [.iOS]) ), ] ), .testTarget( name: "DemoTests", dependencies: [ .target(name: "Demo") ] ), ] )
FirebaseAnalytics only supports iOS platform, but not tvOS.
My "Demo" library builds fine for iOS, but when trying to build it for tvOS, I am getting the following error:
[...]/FirebaseAnalytics.xcframework:1:1: While building for tvOS Simulator, no library for this platform was found in '[...]/FirebaseAnalytics.xcframework'.
Not sure if such configuration is not supported, or I am doing something wrong here.
I've created an example project that demonstrates the issue:
I am using Apple Swift version 5.4 (swiftlang-118.104.22.168 clang-122.214.171.124) that comes with Xcode 12.5 (12E262).
All feedback and suggestions will be appreciated!