swift build fails on Ventura
Build Information
OSX v13.3.1 Xcode 14.3 Build version 14E222b Swift 5.8 Integrated via swift package manager according to example in documentation
General guidelines
A simple two line program with import SQLite and db = try Connection(.....) , initially generated via swift package init --type executable, fails to build with swift build resulting in the following output:
warning: dependency 'sqlite.swift' is not used by any target
Building for debugging...
error: emit-module command failed with exit code 1 (use -v to see invocation)
/Users/one/testproject/.build/x86_64-apple-macosx/debug/SQLite.build/module.modulemap:2:12: error: header '/Users/one/testproject/.build/x86_64-apple-macosx/debug/SQLite.build/SQLite-Swift.h' not found
header "/Users/one/testproject/.build/x86_64-apple-macosx/debug/SQLite.build/SQLite-Swift.h"
^
/Users/one/testproject/Sources/main.swift:1:8: error: could not build Objective-C module 'SQLite'
import SQLite
^
/Users/one/testproject/.build/x86_64-apple-macosx/debug/SQLite.build/module.modulemap:2:12: error: header '/Users/one/testproject/.build/x86_64-apple-macosx/debug/SQLite.build/SQLite-Swift.h' not found
header "/Users/one/testproject/.build/x86_64-apple-macosx/debug/SQLite.build/SQLite-Swift.h"
^
/Users/one/testproject/Sources/main.swift:1:8: error: could not build Objective-C module 'SQLite'
import SQLite
Disclaimer
I am an experienced developer in general, and a long time user of *nix operating systems, but an absolute newbie when using OSX and I've never touched Swift before.
I've found some other historical bug reports and discussions with this issue, but so far none of them have not turned up any solutions that have worked in my case. It may be (probably is?) relevant for me to mention now that I'm thinking about it, that I installed the command line software dev tools through the command line, not the GUI, via the following process:
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progresssoftwareupdate --verbose --install 'Command Line Tools for Xcode...after usingsudo softwareupdate --list | grep 'Command Line'to get the complete package name.- sudo rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
This was done prior to XCode itself being installed. I am working on this machine remotely and don't have physical access to it. Repeatedly asking the on-prem person to add/remove/update different packages is a somewhat annoying and slow process, so I've tried to do what I can to install things from the command line. XCode itself was installed yesterday via physical in-person access as I could not find a way to do that on the command line.
One thing I wanted to mention is that the file in the error above, SQLite-Swift.h doesn't seem to exist anywhere on the system; I've searched for it via sudo find / -type f -name 'SQLite-Swift.h' which did not produce any results. Maybe this file is automatically created by the failing build process, but if not, maybe I'm missing some prerequisite?
Have reinstalled both Xcode and the command line utilities via the GUI installer and issue remains. I went so far as to delete my .build directory as well as the .swiftpm directory under my home dir, without any change.
Figured out the issue by looking at the Tests/SPM directory.
Contrary to the documentation, you need to do more than just add the .package path to your dependency list -- you also need to add (or create) a dependencies item in targets such as dependencies: [.product(name: "SQLite", package: "SQLite.swift")]. This must be placed before the Sources key, if it exists.
Leaving this open in the hopes it's seen and the documentation updated.
FWIW I've even written some Swift stuff, but all in Xcode, and this tripped me up with a CLI :) +1 to putting it in the README as a "can't hurt".