Код: Выделить всё
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "ExampleLibrary",
platforms: [
.macOS(.v10_15), .iOS(.v13), .tvOS(.v13)
],
products: [
// 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(
name: "ExampleLibraryTests",
dependencies: ["ExampleLibrary"]),
]
)
Код: Выделить всё
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "ExampleSDK",
platforms: [
.iOS(.v13),
.macOS(.v10_15),
],
products: [
.library(
name: "ExampleSDK",
targets: ["ExampleLibraryFramework"]),
],
targets: [
.binaryTarget(name: "ExampleLibraryFramework", path: "ExampleLibrary.xcframework")
]
)
Код: Выделить всё
import ExampleLibrary
Когда я импортирую CryptoSwift в приложение как другая зависимость пакета. У меня ошибка:
Код: Выделить всё
objc[5702]: Class _TtC11CryptoSwift15XChaCha20Worker is implemented in both [...]/ExampleLibrary (0x1016edcf0) and [...]/example.app/example (0x100611908). One of the two will be used. Which one is undefined. Код: Выделить всё
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "ExampleSDK",
platforms: [
.iOS(.v13),
.macOS(.v10_15),
],
products: [
.library(
name: "ExampleSDK",
targets: ["ExampleLibraryFramework", "ExampleSDK"]),
],
dependencies: [
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMajor(from: "1.8.1")),
],
targets: [
.target(name: "ExampleSDK", dependencies: ["CryptoSwift"]),
.binaryTarget(name: "ExampleLibraryFramework", path: "ExampleLibrary.xcframework")
]
)
- Как отключить предоставление CryptoSwift из моей библиотеки, чтобы его можно было импортировать в приложение без дубликатов? Я пробовал использовать @_implementationOnly import CryptoSwift внутри моей библиотеки, но он не прекратил раскрывать его, когда я импортировал другой CryptoSwift в приложение.
- Как сделать так, чтобы проект приложения увидел это эта зависимость встроена в XCFramework. Вот как XCFramework выглядит внутри:
Подробнее здесь: https://stackoverflow.com/questions/781 ... ts-used-in