Post

Replies

Boosts

Views

Activity

How to depend on a non-macOS external package in macros
Hello everyone, I am trying to create a macro that depends on an external package to abstract some of the packages logic. The point is that the dependency does not support macOS which results in a build failure when trying to build the macro. Since macOS 10.15 is required for creating macros, any thing can be done to get it to work? Here is a sample to what I'm trying to do import PackageDescription import CompilerPluginSupport let package = Package( name: "Stringify", platforms: [ .macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .macCatalyst(.v13) ], products: [ .library( name: "Stringify", targets: ["Stringify"] ), .executable( name: "StringifyClient", targets: ["StringifyClient"] ), ], dependencies: [ .package(url: "https://github.com/apple/swift-syntax.git", from: "509.0.0"), .package(url: "https://github.com/MyDependency", from: "1.0.0"), ], targets: [ .target( name: "Stringify", dependencies: ["StringifyMacros"] ), .executableTarget( name: "StringifyClient", dependencies: ["Stringify"] ), .macro( name: "StringifyMacros", dependencies: [ .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), .product(name: "MyDependency", package: "MyDependency"), ], swiftSettings: [ .define("IOS_ONLY") ] ), ], swiftLanguageVersions: [.v5] )
1
0
248
Jul ’24