Guziq
(Kuba)
1
Hello,
I'm encountering a challenge while trying to integrate a custom XCFramework into a Swift Package Manager (SPM). I have an XCFramework named MyFramework.xcframework, designed for macOS platform (dylib as arm64/x86_64 written in C). The way I create my xcframework:
xcodebuild -create-xcframework -library ./mylib.dylib -headers includes -output MyFramework.xcframework
After integrating the XCFramework with my SPM, I am unable to successfully import and use it in my project. My Package.swift
import PackageDescription
let package = Package(
name: "TestProject",
platforms: [
.macOS(.v14)
],
products: [
.library(
name: "MyProject",
targets: ["Swift"])
],
targets: [
.binaryTarget(
name: "MyFramework",
path: "MyFramework.xcframework"
),
.target(
name: "Swift",
dependencies: ["MyFramework"]
)
]
)
// test.swift (under Sources/Swift)
import MyFramework // no such module
Here is a snippet of the info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>mylib.dylib</string>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>macos-arm64_x86_64</string>
<key>LibraryPath</key>
<string>mylib.dylib</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>macos</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>
Not sure if I am missing something obvious.
EDIT:
It turned out that I had a typo in my module.modulemap.