groue / GRDB.swift

A toolkit for SQLite databases, with a focus on application development
MIT License
6.61k stars 677 forks source link

Build Failure with GRDB.swift in Xcode Framework: 'missing required module 'CSQLite' #1561

Closed dexterleng closed 2 weeks ago

dexterleng commented 2 weeks ago

What did you do?

  1. Create a Xcode Framework
  2. Add GRDB.swift via SPM
  3. import GRDB in one of the files
  4. Build the framework

What did you expect to happen?

Build to succeed.

What happened instead?

I get this error: missing required module 'CSQLite'

I've tried the following:

  1. Sanity checks like resetting package cache and deleting DerivedData.
  2. @_exported import GRDB
  3. Adding CSQlite to Frameworks and Libraries
  4. Commenting out Export.swift and prepending import CSQLite to every Swift file in GRDB/, following this commit (https://github.com/groue/GRDB.swift/commit/6e09c32d2659436ee5febcad99e480a5b0c55ea3)
#!/bin/bash

# Define the text to prepend
read -r -d '' content << 'EOF'
import CSQLite

EOF

# Find all .swift files recursively and prepend the text
find ./GRDB/ -type f -name '*.swift' -exec sh -c 'echo "$1" | cat - "$2" > temp && mv temp "$2"' _ "$content" {} \;

The only thing that did work was setting Building Libraries for Distribution to No but then I can't use my framework in my other projects.

Environment

GRDB flavor(s): (GRDB, SQLCipher, Custom SQLite build?)

GRDB

GRDB version:

master (4b934fd)

Installation method: (CocoaPods, SPM, manual?)

SPM

Xcode version:

Version 15.4 (15F31d)

Swift version:

Swift 5

Platform(s) running GRDB: (iOS, macOS, watchOS?)

macOS

macOS version running Xcode:

macOS 14.5

Demo Project

GRDBFramework.zip

groue commented 2 weeks ago

Thanks for your input, @dexterleng. I close the issue as a duplicate because there already exist issues regarding the CSQLite module. So far, no one was able to come up with something that should be done at the level of this library. There are multiple workarounds, though.

dexterleng commented 2 weeks ago

I wasn't able to get any to work :/

groue commented 2 weeks ago

😬 I'm very sorry, but, as I said above, no one was able to come up with something that should be done at the level of this library. Please report an issue at http://feedbackassistant.apple.com. My own fight with this Xcode problem is described there. The goal here is to share solutions. Complaints should go to Apple.