I’ve library that may be a SPM package deal. It has one dependency.
// swift-tools-version: 5.9
// The swift-tools-version declares the minimal model of Swift required to construct this package deal.
import PackageDescription
let package deal = Package deal(
title: "ExampleLibrary",
platforms: [
.macOS(.v10_15), .iOS(.v13), .tvOS(.v13)
],
merchandise: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "ExampleLibrary",
type: .dynamic,
targets: ["ExampleLibrary"]),
],
dependencies: [
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMajor(from: "1.8.1")),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "ExampleLibrary",
dependencies: ["CryptoSwift"]),
.testTarget(
title: "ExampleLibraryTests",
dependencies: ["ExampleLibrary"]),
]
)
This library is then construct an exported to binary XCFramework and distributed as one other SPM package deal
// swift-tools-version: 5.9
import PackageDescription
let package deal = Package deal(
title: "ExampleMobileSDK",
platforms: [
.iOS(.v13),
.macOS(.v10_15),
],
merchandise: [
.library(
name: "ExampleMobileSDK",
targets: ["ExampleLibraryFramework", "ExampleMobileSDK"]),
],
targets: [
.binaryTarget(name: "ExampleLibraryFramework", path: "ExampleLibrary.xcframework")
]
)
after I import this package deal to an app for utilization and use
import ExampleLibrary
I’ve on this line error Lacking required module 'CryptoSwift'
Once I import CryptoSwift
within the app as one other package deal dependency I’ve an error:
objc[5702]: Class _TtC11CryptoSwift15XChaCha20Worker is applied in each [...]/ExampleLibrary (0x1016edcf0) and [...]/instance.app/instance (0x100611908). One of many two might be used. Which one is undefined.
Additionally after I add to my XCFramework Package deal CryptoSwift
dependency it additionally stops exhibiting the error however the duplicate import is similar.
// swift-tools-version: 5.9
import PackageDescription
let package deal = Package deal(
title: "ExampleMobileSDK",
platforms: [
.iOS(.v13),
.macOS(.v10_15),
],
merchandise: [
.library(
name: "ExampleMobileSDK",
targets: ["ExampleLibraryFramework", "ExampleMobileSDK"]),
],
dependencies: [
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMajor(from: "1.8.1")),
],
targets: [
.target(name: "ExampleMobileSDK", dependencies: ["CryptoSwift"]),
.binaryTarget(title: "ExampleLibraryFramework", path: "ExampleLibrary.xcframework")
]
)
- How can I disable exposing
CryptoSwift
from my library so it may be imported within the app with out duplicates? I’ve tried utilizing@_implementationOnly import CryptoSwift
inside my library but it surely didn’t stopped exposing it after I import one other CryptoSwift in app. - Methods to make the app undertaking see that this dependency is embedded contained in the XCFramework. That is how XCFramework appears to be like like inside: