Still not working in XCode 12.5 :(
Post
Replies
Boosts
Views
Activity
In the Package.swift in target declare:
let package = Package(
name: "Library",
defaultLocalization: "en",
platforms: [
.iOS(.v11)
],
products: [
.library(
name: "Library",
targets: ["Library"]
),
],
dependencies: [],
targets: [
.target(
name: "Library",
dependencies: [],
path: "Sources",
swiftSettings: [
.define("SPM")
]
),
]
)
the important part is the definition of SPM, then we create the following extension
#if !SPM
extension Bundle {
static var module:Bundle { Bundle(identifier: "com.library.example")! }
}
#endif
this way we always have Bundle.module
available
The problem in Xcode 12.4 still persists, I understand that the Swift.package, if it is not declared if it supports tvOS or another platform it assumes a default value, but having an iPhone emulator selected, it fails because it is not able to compile on tvOS doesn't make sense when the target doesn't support it.
I'm testing with Xcode 12.5 beta to see if it works.
This solution not work: https://developer.apple.com/forums/thread/652558?answerId=618201022#618201022
In the SupportedPlatform - https://developer.apple.com/documentation/swift_packages/supportedplatform documentation explain:
By default, Xcode assigns a predefined minimum deployment version for each supported platforms unless you configure supported platforms using the platforms API. This predefined deployment version is the oldest deployment target version that the installed SDK supports for a given platform
I only have iOS, version 12 defined:
// swift-tools-version:5.3
platforms: [
.iOS(.v12)
]
But when compiling for the designables compiles tvOS.
The module contains xibs that already fail directly when compiling for tvOS. I am using XCode 12 beta