stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.57k stars 1.54k forks source link

Can't Use Previews in Xcode in a Local Package if it requires SQLite.swift #1156

Open Mozahler opened 1 year ago

Mozahler commented 1 year ago

First of all: I don't believe this is an error in SQLite.swift package, but I'm hoping someone has solved this problem.

I'm getting

"missing required module 'SQLiteObjc'"

when I try to use previews. I don't run into this problem in the main module, but when the view is in a local package imported by my app.

I imagine that you (or Stephen) have run into this problem when using previews (I see he makes heavy use of them in his point free episodes), and trust that one of you knows how to make the compiler happy. I have posted this question on StackOverflow, but all I got is downvoted :(

Xcode Previews fail with: "missing required module 'SQLiteObjc'"

An issue was recently fixed for Carthage installs:

https://github.com/stephencelis/SQLite.swift/issues/1150

One suggestion I found was to try adding: ${SRCROOT}/SQLiteObjc to the Swift Compiler Search Paths but that didn't help.

my Package.swift contains:

  .package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.13.2"),

which resolves to 0.13.3

This problem occurs on an M1 MacBookPro running Monterey 12.5.1/Xcode 13.4.1 as well as Monterey 12.6 using (just released) Xcode 14. The app compiles without errors and runs fine. I just can't view previews.

When I compiled this morning, the missing SQLiteObjc message did not appear. Again 🤷🏻

import SwiftUI
import TasksSQLite

struct ContentView: View {
    var body: some View {
        Text("Hello, world!")
            .padding()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Monterey 12.5.1

no such file or directory: '/Users/xxx/Library/Developer/Xcode/DerivedData/Tasklist-abrktmwcewhompgocivntszewxla/Build/Intermediates.noindex/Previews/Tasklist/Products/Debug-iphonesimulator/PackageFrameworks/TasksSQLite_584AE96A3AF58A43_PackageProduct.framework/TasksSQLite_584AE96A3AF58A43_PackageProduct'


LinkDylibError: Failed to build PrimaryPage.swift

Linking failed: no such file or directory: '/Users/xxx/Library/Developer/Xcode/DerivedData/Tasklist-abrktmwcewhompgocivntszewxla/Build/Intermediates.noindex/Previews/Tasklist/Products/Debug-iphonesimulator/PackageFrameworks/TasksSQLite_584AE96A3AF58A43_PackageProduct.framework/TasksSQLite_584AE96A3AF58A43_PackageProduct'

clang: error: no such file or directory: '/Users/xxx/Library/Developer/Xcode/DerivedData/Tasklist-abrktmwcewhompgocivntszewxla/Build/Intermediates.noindex/Previews/Tasklist/Products/Debug-iphonesimulator/PackageFrameworks/TasksSQLite_584AE96A3AF58A43_PackageProduct.framework/TasksSQLite_584AE96A3AF58A43_PackageProduct'

Edit:

I just cleaned the build folder again, and the error came back up:

\:0: error: missing required module 'SQLiteObjc'


missing required module 'SQLiteObjc'


SchemeBuildError: Failed to build the scheme "Tasklist"

missing required module 'SQLiteObjc'

Compile TasklistApp.swift (arm64):

:0: error: missing required module 'SQLiteObjc' Emitting module for Tasklist: :0: error: missing required module 'SQLiteObjc' Compile ContentView.swift (arm64): :0: error: missing required module 'SQLiteObjc' ### Monterey 12.6 missing required module 'SQLiteObjc' ---------------------------------------- SchemeBuildError: Failed to build the scheme "Tasklist" missing required module 'SQLiteObjc' Emitting module for Tasklist: :0: error: missing required module 'SQLiteObjc' Compile ContentView.swift (arm64): :0: error: missing required module 'SQLiteObjc' Compile TasklistApp.swift (arm64): :0: error: missing required module 'SQLiteObjc' Copy Tasklist.abi.json (arm64): error: /Users/xxx/Library/Developer/Xcode/DerivedData/Tasklist-abrktmwcewhompgocivntszewxla/Build/Intermediates.noindex/Previews/Tasklist/Intermediates.noindex/Tasklist.build/Debug-iphonesimulator/Tasklist.build/Objects-normal/arm64/Tasklist.abi.json: No such file or directory (in target 'Tasklist' from project 'Tasklist') Copy Tasklist.swiftdoc (arm64): error: /Users/xxx/Library/Developer/Xcode/DerivedData/Tasklist-abrktmwcewhompgocivntszewxla/Build/Intermediates.noindex/Previews/Tasklist/Intermediates.noindex/Tasklist.build/Debug-iphonesimulator/Tasklist.build/Objects-normal/arm64/Tasklist.swiftdoc: No such file or directory (in target 'Tasklist' from project 'Tasklist') Copy Tasklist.swiftmodule (arm64): error: /Users/xxx/Library/Developer/Xcode/DerivedData/Tasklist-abrktmwcewhompgocivntszewxla/Build/Intermediates.noindex/Previews/Tasklist/Intermediates.noindex/Tasklist.build/Debug-iphonesimulator/Tasklist.build/Objects-normal/arm64/Tasklist.swiftmodule: No such file or directory (in target 'Tasklist' from project 'Tasklist') Copy Tasklist.swiftsourceinfo (arm64): error: /Users/xxx/Library/Developer/Xcode/DerivedData/Tasklist-abrktmwcewhompgocivntszewxla/Build/Intermediates.noindex/Previews/Tasklist/Intermediates.noindex/Tasklist.build/Debug-iphonesimulator/Tasklist.build/Objects-normal/arm64/Tasklist.swiftsourceinfo: No such file or directory (in target 'Tasklist' from project 'Tasklist') Once Again: I don't believe this is an error in SQLite.swift package, but I'm hoping someone has solved this problem.
nathanfallet commented 1 year ago

Can you provide us a project to reproduce the issue? (a zip archive of your project for example) I'm using the package in my apps and I don't have any problem with previews.

Mozahler commented 1 year ago

Thanks for responding. Let me see if I can figure it out then. I appreciate you taking the time. I'll close it with a solution as soon as I can.

Mozahler commented 1 year ago

I was able to create an ultra simple project which demonstrates the problem. Thursday.zip

It just prints out the name of the DB connection in a Text. Runs fine on the simulator, but ContentViewX will not preview from the package.

ErrorOnPreviewBuild