Symbol not found: _$s6SQLite10ConnectionC8LocationO8inMemoryyA2EmFWC

35 views Asked by At

In my project, there're 2 framework in which stephencelis's oss:SQLite is used. Here is the repository:https://github.com/stephencelis/SQLite.swift

And in my app, I need to import this oss as dynamic lirabray because it is used in more than one frmaework. When I use cocoapods to do it, everything works fine. But I was aksed to use SPM(Swift Package Manager) to import. As I know, SPM can only import static library unless you edit the Package.swift. So I edit the Package.swift and add type:.dynamic in the product. After I do that and run the app again, I got runtime crush listed below:

dyld[697]: Symbol not found: _$s6SQLite10ConnectionC8LocationO8inMemoryyA2EmFWC
  Referenced from: <4B8F1B6D-C959-38BE-84E4-B93DF2BF0DDC> /private/var/containers/Bundle/Application/81E9CF1A-9A0E-4FCC-8FD2-3E05F17F62AE/MPTDKSampleApp.app/Frameworks/DeviceAgentLogs.framework/DeviceAgentLogs
  Expected in:     <6439E3B1-5F0E-3B00-8846-DB8CD30EAE8F> /private/var/containers/Bundle/Application/81E9CF1A-9A0E-4FCC-8FD2-3E05F17F62AE/MPTDKSampleApp.app/Frameworks/SQLite.framework/SQLite

I have checked MPTDKSampleApp.app/Frameworks/SQLite.framework/SQLite and it is actually existed. I also have tried a lot of ways but cannot find the solution.

I also edited other third-party-library's Package.swift like ZipArchive and RxSwift and both of them works fine. No build error, no runtime crush.

Can anyone help me with this porblem?

Here is the Package.swift I edited:

// swift-tools-version:5.1

import PackageDescription

let buildTests = false

extension Product {
  static func allTests() -> [Product] {
    if buildTests {
      return [.executable(name: "AllTestz", targets: ["AllTestz"])]
    } else {
      return []
    }
  }
}

extension Target {
  static func rxCocoa() -> [Target] {
    #if os(Linux)
      return [.target(name: "RxCocoa", dependencies: ["RxSwift", "RxRelay"])]
    #else
      return [.target(name: "RxCocoa", dependencies: ["RxSwift", "RxRelay", "RxCocoaRuntime"])]
    #endif
  }

  static func rxCocoaRuntime() -> [Target] {
    #if os(Linux)
      return []
    #else
      return [.target(name: "RxCocoaRuntime", dependencies: ["RxSwift"])]
    #endif
  }

  static func allTests() -> [Target] {
    if buildTests {
      return [.target(name: "AllTestz", dependencies: ["RxSwift", "RxCocoa", "RxBlocking", "RxTest"])]
    } else {
      return []
    }
  }
}

let package = Package(
  name: "RxSwift",
  platforms: [.iOS(.v9), .macOS(.v10_10), .watchOS(.v3), .tvOS(.v9)],
  products: ([
    [
      .library(name: "RxSwift", type: .dynamic, targets: ["RxSwift"]),
      .library(name: "RxCocoa", targets: ["RxCocoa"]),
      .library(name: "RxRelay", targets: ["RxRelay"]),
      .library(name: "RxBlocking", targets: ["RxBlocking"]),
      .library(name: "RxTest", targets: ["RxTest"]),
      .library(name: "RxCocoa-Dynamic", type: .dynamic, targets: ["RxCocoa"]),
      .library(name: "RxRelay-Dynamic", type: .dynamic, targets: ["RxRelay"]),
      .library(name: "RxBlocking-Dynamic", type: .dynamic, targets: ["RxBlocking"]),
      .library(name: "RxTest-Dynamic", type: .dynamic, targets: ["RxTest"]),
    ],
    Product.allTests()
  ] as [[Product]]).flatMap { $0 },
  targets: ([
    [
      .target(name: "RxSwift", dependencies: []),
    ], 
    Target.rxCocoa(),
    Target.rxCocoaRuntime(),
    [
      .target(name: "RxRelay", dependencies: ["RxSwift"]),
      .target(name: "RxBlocking", dependencies: ["RxSwift"]),
      .target(name: "RxTest", dependencies: ["RxSwift"]),
    ],
    Target.allTests()
  ] as [[Target]]).flatMap { $0 },
  swiftLanguageVersions: [.v5]
)
0

There are 0 answers