Hi,
I am puzzled by an error and I am hoping someone here can help. I have some very simple code that splits a PDF document into segments. I am using PDFKit to achieve this, and I have made it into a simple framework. The package for this framework looks like this.
import PackageDescription
let package = Package(
name: "Slice",
platforms: [.iOS(.v14), .macOS(.v10_13)],
products: [
.library(
name: "Slice",
targets: ["Slice"]
),
],
dependencies: [
.package(url: "https://github.com/JohnSundell/Files", .upToNextMinor(from: "4.2.0"))
],
targets: [
.target(
name: "Slice",
dependencies: ["Files"]),
.testTarget(
name: "SliceTests",
dependencies: ["Slice", "Files"],
resources: [
.process("Resources")
]
),
]
)
The framework builds fine and the tests pass. However, I am trying to import that framework into an executable target, so that I can run it from the command line. The package looks like this.
import PackageDescription
let package = Package(
name: "NinjaPDF",
platforms: [.iOS(.v14), .macOS(.v10_13)],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "0.3.0")),
.package(url: "https://github.com/JohnSundell/Files", .upToNextMinor(from: "4.2.0")),
.package(path: "../Slice")
],
targets: [
.target(
name: "NinjaPDF",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "Files", package: "Files"),
.product(name: "Slice", package: "Slice")
])
]
)
When attempting to build I get the following error.
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_PDFDocument", referenced from:
objc-class-ref in Slice.o
"_OBJC_CLASS_$_PDFPage", referenced from:
objc-class-ref in Slice.o
I have no idea how to fix this using SPM. I have managed to eliminate the error with the following steps.
- swift package generate-xcodeproj
- launch Xcode
- select 'NinjaPDF' target
- navigation to general > frameworks
- hit plus button and add 'PDFKit' as dependency
Any help would be very much appreciated.
P.S. This issue does not present itself when importing the slice package into an iOS App.