harp
harp

Reputation: 185

Swift Package Manager - binaryTarget with .zip file fails to validate

I tried different approaches to add a binaryTarget to a Swift package - 2 of them worked out fine (Target1 and Target2 in the example), but third approach (Target3) that should also work according to documentation does not validate: unsupported extension for binary target 'Target3'; valid extensions are: xcframework

For not bloating the repo too much with every binary release I would prefer the zip approach here... - Anyone got it working with a binaryTarget and a .zip file in path: added to the Package repository, or any hints what I'm doing wrong here? (Xcode 12.4, t3.zip containing only the .xcframework at root level)

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

import PackageDescription

let package = Package(
    name: "StackoverflowExamplePackage",
    platforms: [
        .iOS(.v9)
    ],
    products: [
        .library(
            name: "Lib1",
            targets: ["Target1"]),
        .library(
            name: "Lib2",
            targets: ["Target2", "Target3"]),
    ],
    dependencies: [
        // .package(url: /* package url */, from: "1.0.0"),
    ],
    targets: [
        .binaryTarget(
            name: "Target1",
            url: "https://myurl.example.com/t1-xcframework.zip",
            checksum: "777ddd6381e2201b7eb778b72f373f77e1190fd9dc9503f703e37c86d3b89674"
        ),
        .binaryTarget(name: "Target2", path: "./Binaries/t2.xcframework"),
        .binaryTarget(name: "Target3", path: "./Binaries/t3.zip"),
    ]
)

Package Example Apple Documentation

Upvotes: 3

Views: 2036

Answers (1)

Dmytro Hutsuliak
Dmytro Hutsuliak

Reputation: 1751

Zip archive support for local binary targets in SPM was merged last year in October and has been finally released along with Xcode 13.3.

Upvotes: 1

Related Questions