How to I archive macros into a static library as xcframework?

I'm trying to make an xcframework from my static library (SPM btw) with macros. My script doesn't work properly

My SPM declaration of macros:

// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import CompilerPluginSupport
import PackageDescription

let package = Package(
    name: "SomeMacr",
    platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .macCatalyst(.v13)],
    products: [
        .library(
            name: "SomeMacr",
            targets: ["SomeMacr"]
        ),
        .executable(
            name: "SomeMacrClient",
            targets: ["SomeMacrClient"]
        )
    ],
    dependencies: [
        .package(url: "https://github.com/apple/swift-syntax.git", from: "509.0.0")
    ],
    targets: [
        .macro(
            name: "SomeMacrMacros",
            dependencies: [
                .product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
                .product(name: "SwiftCompilerPlugin", package: "swift-syntax")
            ]
        ),

        .target(name: "SomeMacr", dependencies: ["SomeMacrMacros"]),

        .executableTarget(name: "SomeMacrClient", dependencies: ["SomeMacr"]),
 
        .testTarget(
            name: "SomeMacrTests",
            dependencies: [
                "SomeMacrMacros",
                .product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax")
            ]
        )
    ]
)

My .sh script:

  xcodebuild archive \
    -scheme $1 \
    -sdk iphoneos \
    -archivePath "Products/archives/ios_devices.xcarchive" \
    SKIP_INSTALL=NO \
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES

  xcodebuild archive \
    -scheme $1 \
    -sdk iphonesimulator \
    -archivePath "Products/archives/ios_simulators.xcarchive" \
    SKIP_INSTALL=NO \
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES

  xcodebuild archive \
    -scheme $1 \
    -sdk macosx \
    -archivePath "Products/archives/macos.xcarchive" \
    SKIP_INSTALL=NO \
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES

  xcodebuild -create-xcframework \
    -library Products/archives/ios_devices.xcarchive/Products/Library/Frameworks/lib$1.a \ 
    -library Products/archives/ios_simulators.xcarchive/Products/Library/Frameworks/lib$1.a \
    -library Products/archives/macos.xcarchive/Products/Library/Frameworks/lib$1.a \
    -output Products/xc/$1.xcframework

It requires destination (But in other tutorials, authors clearly shows, that after this script I will get an xcframework)

xcodebuild: error: Building a Swift package requires that a destination is provided using the "-destination" option. The "-showdestinations" option can be used to list the available destinations

But when I setup the destination it was compiled to exec file, which I don't mind how to include to another SPM package / or xcframework

What am I doing wrong?

I'm trying to make an xcframework from my static library (SPM btw) with macros

xcodebuild archive -scheme $1

What is the scheme here? Is that the name of an Xcode target, or one from your package manifest?

In general, you can't build an XCFramework from a Swift Package, the xcodebuild command needs to use an Xcode target (which than then depend on a package).

It requires destination (But in other tutorials, authors clearly shows, that after this script I will get an xcframework)

-sdk macOS

You should avoid using the -sdk argument entirely. Always use -destination instead. This is mentioned in the documentation as a common mistake.

— Ed Ford,  DTS Engineer

In general, you can't build an XCFramework from a Swift Package

Is there a way how to build macros spm package as an xcframework?

What is the scheme here?

Scheme is name of my macros's target

Is there a way how to build macros spm package as an xcframework?

XCFrameworks are built starting from an Xcode target.

Scheme is name of my macros's target

Is that target in a Swift Package, or an Xcode target?

—Ed Ford,  DTS Engineer

How to I archive macros into a static library as xcframework?
 
 
Q