Hi!
I'm trying to distribute XCFramework with third-party dependencies via SPM but faced the is implemented in both
issue.
I have the following Package.swift:
// swift-tools-version: 5.4
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Foo",
platforms: [.iOS(.v12)],
products: [
.library(
name: "Foo",
targets: ["FooSDKTargets"]
),
],
dependencies: [
.package(
name: "Apollo",
url: "https://github.com/apollographql/apollo-ios",
.exact("0.49.1")
)
],
targets: [
.binaryTarget(
name: "FooSDK",
path: "FooSDK.xcframework"
),
.target(
name: "FooSDKTargets",
dependencies: [
.target(name: "FooSDK"),
.product(name: "Apollo", package: "Apollo"),
.product(name: "ApolloWebSocket", package: "Apollo"),
],
path: "Sources"
)
]
)
If I try to import that package to a project I get loads of:
Class X is implemented in both /private/var/containers/Bundle/Application/2EA1C678-D421-4775-BEAB-09FCD45F5795/Test.app/Frameworks/FooSDK.framework/FooSDK (0x103f9b998) and /private/var/containers/Bundle/Application/2EA1C678-D421-4775-BEAB-09FCD45F5795/Test.app/Test (0x102faf478). One of the two will be used. Which one is undefined.
Additional information:
- All of my external dependency imports are marked with
@_implementationOnly
- I was able to distribute the same binary with cocoapods without any issue (probably thanks to
use_framworks!
and dynamic libraries)
Pod::Spec.new do |spec|
spec.name = "Foo"
spec.platform = :ios, "12.0"
spec.swift_version = "5.3"
spec.cocoapods_version = '>= 1.10.0'
spec.vendored_frameworks = 'FooSDK.xcframework'
spec.framework = "UIKit"
spec.pod_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' }
spec.dependency "Apollo", "~> 0.49.1"
spec.dependency "Apollo/WebSocket", "~> 0.49.1"
end
Podfile:
platform :ios, '12.0'
target 'Test' do
use_frameworks!
# Pods for BinaryTest
pod 'Foo'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
if ["Apollo", "Apollo/WebSocket"].include? target.name
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
end
Is there anything we can do about it? Did I miss something?
I would appreciate any help
Thanks