I have a framework that is distributed through cocoaPods and now I want to support SPM
I created a package in xCode, as Source code I only have a dummy swift file because my framework is an already compiled XCFramework
My Package.Swift has the following format
let package = Package(
name: "MyLibrary",
platforms: [
.iOS(.v12)
],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "MyLibrary",
targets: ["MyLibraryWrapper"]),
],
dependencies: [
.package(name: "Sentry", url: "https://github.com/getsentry/sentry-cocoa", .exact("8.32.0")),
.package(name: "Lottie", url: "https://github.com/airbnb/lottie-spm", .exact("4.3.4")),
... other packages ...
],
targets: [
.binaryTarget(
name: "MyLibrary",
url: "MyLibraryURL",
checksum: "709e8beedce6029b439e7d4bb59e1830060b642b96791586c65a6520ca5ba908"
),
.target(
name: "MyLibraryWrapper",
dependencies: [
.target(name: "MyLibrary"),
.product(name: "Sentry", package: "Sentry"),
.product(name: "Lottie", package: "Lottie"),
... other packages ...
],
path: "Sources",
sources: ["dummy.swift"]
)
],
swiftLanguageVersions: [.v5]
)
when I import this with SPM into the project everything looks ok and all MyLibrary dependencies are loaded.
but when I run the app I have the following error
dyld[4233]: Symbol not found: _OBJC_CLASS_$_SentryClient
Referenced from: /private/var/containers/Bundle/Application/373D3B20-3FF1-4C21-8D83-613FBFE37BB3/Sample App.app/Frameworks/MyLibrary.framework/MyLibrary
Expected in: /private/var/containers/Bundle/Application/373D3B20-3FF1-4C21-8D83-613FBFE37BB3/Sample App.app/Frameworks/Sentry.framework/Sentry
Message from debugger: killed
Before Sentry I had the same problems with Lottie but then I just had to change the repo
from:
https://github.com/airbnb/lottie-ios.git
to:
https://github.com/airbnb/lottie-spm
I searched and didn’t find anything about this in the issues reported in Sentry’s git.
I also tried to import Sentry directly as a targetBinary but without success.
I tried to change the name to sentry-cocoa as reported in this link but it didn’t work.
Swift package product not found when added via Package.swift dependency
And try with different Sentry versions and always have this issue