I've put together a Swift Package which has a binary dependency. The xcframework contained within depends on another xcframework which is in another package. I can't get the first Swift Package to bring in the second Swift Package as a dependency beyond the .testTarget.
In the WWDC 2020 video Distribute binary frameworks as Swift packages it shows code that looks like this:
The presenter says,
"If you want to use that same library as a package dependency, it also works the same way you are used to. In the package manifest, you can an entry to the dependencies array, which points to the repository the package is using, and define the version restrictions that you chose for this dependency."
That statement isn't working for me, because I don't have a .target but a .binaryTarget. My package then looks like this:
Xcode complains:
Here is my actual "first" Swift Package:
It works in general, but my clients are required to manually add KochavaCore as a package dependency in my app in addition to KochavaTracker. Is there something I can do to bring in KochavaCore automatically like .testTarget does?
In the WWDC 2020 video Distribute binary frameworks as Swift packages it shows code that looks like this:
Code Block // swift-tools-version:5.3 import PackageDescription let package = Package( name: "Emoji", products: [ .library( name: "package", targets: ["Emoji"]), ], dependencies: [ .package(url: "https://github.com/JohnnyAppleSeed2020/BinaryEmoji", from: "1.0.0"), ], targets: [ .target( name: "package", dependencies: ["Emoji"]), ] )
The presenter says,
"If you want to use that same library as a package dependency, it also works the same way you are used to. In the package manifest, you can an entry to the dependencies array, which points to the repository the package is using, and define the version restrictions that you chose for this dependency."
That statement isn't working for me, because I don't have a .target but a .binaryTarget. My package then looks like this:
Code Block // swift-tools-version:5.3 import PackageDescription let package = Package( name: "Emoji", products: [ .library( name: "package", targets: ["Emoji"]), ], dependencies: [ .package(url: "https://github.com/JohnnyAppleSeed2020/BinaryEmoji", from: "1.0.0"), ], targets: [ .binaryTarget( name: "package", path: "KochavaTracker.xcframework", dependencies: ["Emoji"]), ] )
Xcode complains:
So it would seem that this same support only works for .target and not .binaryTarget. Why not?Extra argument 'dependencies' in call
Here is my actual "first" Swift Package:
Code Block // 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: "KochavaTracker", products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "KochavaTracker", targets: [ "KochavaTracker" ] ), ], dependencies: [ // Dependencies declare other packages that this package depends on. // .package(name: "KochavaCore", path: "./../Apple-SwiftPackage-KochavaCore"), .package(name: "KochavaCore", url: "https://github.com/Kochava/Apple-SwiftPackage-KochavaCore", from: "4.0.0-alpha.1"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages this package depends on. .binaryTarget( name: "KochavaTracker", path: "KochavaTracker.xcframework" ), .testTarget( name: "KochavaTrackerTests", dependencies: [ "KochavaCore", "KochavaTracker" ] ), ] )
It works in general, but my clients are required to manually add KochavaCore as a package dependency in my app in addition to KochavaTracker. Is there something I can do to bring in KochavaCore automatically like .testTarget does?