When I trying to import third party library shifting from cocoapods to SPM, Symbol not found Error occurs.
I check the binary file and found the enum class in third party library(SQLite.swift) is not listed in symbol-list.
In the case of cocoapods it not happens.
Xcode: 15.0
Library structure:
The Framework-A import SQLite and use the API of it.
App imports both of Framework-A and SQLite as dynamic libraries via SPM.(I add .dynamic in Package.swift of SQLite)
Third party Library(version-0.13.3):
https://github.com/stephencelis/SQLite.swift
The link of library seems no problem(otherwise it will give [library no loaded error]) but the some symbol is missing.
In my case, the case in enum class:Connection/location/inMemory is not listed in symbol table.
Does anyone know the reason? Is this the bug of SPM?
The Package.swift of SQLite is here:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "SQLite.swift",
platforms: [
.iOS(.v9),
.macOS(.v10_10),
.watchOS(.v3),
.tvOS(.v9)
],
products: [
.library(
name: "SQLite",
type: .dynamic,
targets: ["SQLite"]
)
],
targets: [
.target(
name: "SQLite",
dependencies: ["SQLiteObjc"],
exclude: [
"Info.plist"
]
),
.target(
name: "SQLiteObjc",
dependencies: [],
exclude: [
"fts3_tokenizer.h"
]
),
.testTarget(
name: "SQLiteTests",
dependencies: [
"SQLite"
],
path: "Tests/SQLiteTests",
exclude: [
"Info.plist"
],
resources: [
.copy("fixtures/encrypted-3.x.sqlite"),
.copy("fixtures/encrypted-4.x.sqlite")
]
)
]
)
#if os(Linux)
package.dependencies = [.package(url: "https://github.com/stephencelis/CSQLite.git", from: "0.0.3")]
package.targets = [
.target(
name: "SQLite",
dependencies: [.product(name: "CSQLite", package: "CSQLite")],
exclude: ["Extensions/FTS4.swift", "Extensions/FTS5.swift"]
),
.testTarget(name: "SQLiteTests", dependencies: ["SQLite"], path: "Tests/SQLiteTests", exclude: [
"FTSIntegrationTests.swift",
"FTS4Tests.swift",
"FTS5Tests.swift"
])
]
#endif
The runtime error is here:
dyld[2003]: Symbol not found: _$s6SQLite10ConnectionC8LocationO8inMemoryyA2EmFWC
Referenced from: <4B8F1B6D-C959-38BE-84E4-B93DF2BF0DDC> /private/var/containers/Bundle/Application/E6C1C0C2-AC80-4562-AA80-05373206ED9E/MPTDKSampleApp.app/Frameworks/Framework-A.framework/Framework-A
Expected in: /private/var/containers/Bundle/Application/E6C1C0C2-AC80-4562-AA80-05373206ED9E/MPTDKSampleApp.app/Frameworks/SQLite.framework/SQLite
The enum class in SQLite is here:
enter image description here