Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swift build fails on Ventura #1212

Open
alandsidel opened this issue Jun 1, 2023 · 4 comments
Open

swift build fails on Ventura #1212

alandsidel opened this issue Jun 1, 2023 · 4 comments

Comments

@alandsidel
Copy link

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.

@alandsidel
Copy link
Author

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:

  1. touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
  2. softwareupdate --verbose --install 'Command Line Tools for Xcode... after using sudo softwareupdate --list | grep 'Command Line' to get the complete package name.
  3. 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?

@alandsidel
Copy link
Author

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.

@alandsidel
Copy link
Author

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.

@rtgoodwin
Copy link

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants