-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[SR-15876] Unhelpful error: Could not build Objective-C module ‘ModuleName’ #5925
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
Comments
Getting the same issue here from Neovim using it's built-in lsp client |
Still experiencing this issue in VSCode with multiple different packages. |
Do you have a package that deterministically reproduces the issue? If yes, that would really help us to track down the the problem. |
Not deterministically, but I wonder if there's a way to force SourceKit-LSP to output more detailed logging messages? If that was possible, next time this happens, we could check what caused the build error. |
This tends to happen where you have a package with a dependency and the dependency hasn't been built. |
My package I reproduced this with did have a dependency, but the error showed up for a module within the package I was editing, not within the dependency. |
I am running into this with https://github.com/open-imcore/barcelona-mautrix/tree/889f5bf53ce08da97110720f369938b39ba8131c, maybe it'll repro for you? |
I can confirm that this issue goes away for me after a successful build |
@ahoppen I have a reproducible scenario that seems to give the same error for me with command line builds on macOS, maybe it helps.
To reproduce:
After step 3, the code should look like:
|
I get his error from the command line swift package build. |
@hassila Thanks for the reproducer instructions. I just tried following them and it doesn’t reproduce for me. Could it be that this issue only existed in a previous commit of your project? This is what I did$ git clone https://github.com/ordo-one/package-benchmark
Cloning into 'package-benchmark'...
remote: Enumerating objects: 310, done.
remote: Counting objects: 100% (299/299), done.
remote: Compressing objects: 100% (204/204), done.
remote: Total 310 (delta 146), reused 180 (delta 74), pack-reused 11
Receiving objects: 100% (310/310), 120.45 KiB | 1.34 MiB/s, done.
Resolving deltas: 100% (146/146), done.
$ vim Tests/BenchmarkTests/BenchmarkTests.swift # and replace contents with what you provided in the last step
$ /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-11-19-a.xctoolchain/usr/bin/swift test
Fetching https://github.com/apple/swift-argument-parser from cache
Fetching https://github.com/swift-extras/swift-extras-json from cache
Fetching https://github.com/apple/swift-numerics from cache
Fetched https://github.com/swift-extras/swift-extras-json (0.58s)
Fetching https://github.com/ordo-one/package-jemalloc from cache
Fetched https://github.com/apple/swift-numerics (0.60s)
Fetching https://github.com/ordo-one/TextTable from cache
Fetched https://github.com/apple/swift-argument-parser (0.71s)
Fetching https://github.com/apple/swift-system from cache
Fetched https://github.com/ordo-one/package-jemalloc (0.40s)
Fetched https://github.com/ordo-one/TextTable (0.38s)
Fetched https://github.com/apple/swift-system (0.38s)
Computing version for https://github.com/ordo-one/package-jemalloc
Computed https://github.com/ordo-one/package-jemalloc at 1.0.0 (0.72s)
Computing version for https://github.com/ordo-one/TextTable
Computed https://github.com/ordo-one/TextTable at 0.0.1 (0.73s)
Computing version for https://github.com/swift-extras/swift-extras-json
Computed https://github.com/swift-extras/swift-extras-json at 0.6.0 (0.74s)
Computing version for https://github.com/apple/swift-numerics
Computed https://github.com/apple/swift-numerics at 1.0.2 (0.75s)
Computing version for https://github.com/apple/swift-argument-parser
Computed https://github.com/apple/swift-argument-parser at 1.1.4 (0.81s)
Computing version for https://github.com/apple/swift-system
Computed https://github.com/apple/swift-system at 1.2.1 (0.74s)
Creating working copy for https://github.com/swift-extras/swift-extras-json
Working copy of https://github.com/swift-extras/swift-extras-json resolved at 0.6.0
Creating working copy for https://github.com/apple/swift-numerics
Working copy of https://github.com/apple/swift-numerics resolved at 1.0.2
Creating working copy for https://github.com/ordo-one/TextTable
Working copy of https://github.com/ordo-one/TextTable resolved at 0.0.1
Creating working copy for https://github.com/apple/swift-argument-parser
Working copy of https://github.com/apple/swift-argument-parser resolved at 1.1.4
Creating working copy for https://github.com/ordo-one/package-jemalloc
Working copy of https://github.com/ordo-one/package-jemalloc resolved at 1.0.0
Creating working copy for https://github.com/apple/swift-system
Working copy of https://github.com/apple/swift-system resolved at 1.2.1
Building for debugging...
[157/157] Linking BenchmarkPackageTests
Build complete! (65.99s)
|
Hi, just add
|
(you need to add the one import line to the file Tests/BenchmarkTests/BenchmarkTests.swift according to the instructions above though) EDIT: Just saw you did that, I missed it in the output - just checkout the tag |
@ahoppen let me know if that helps you repro, I can try with your toolchain otherwise if you can't. |
Thanks a lot. I was able to reproduce the problem now. Since this reproducer doesn’t involve SourceKit-LSP, I’m moving it over to SwiftPM. This script reproduces the issue locally for me cd /tmp
rm -rf package-benchmark
set -x
git clone https://github.com/ordo-one/package-benchmark
cd package-benchmark
git checkout 0.3.2
echo "import BenchmarkSupport" > Tests/BenchmarkTests/BenchmarkTests.swift
/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-11-19-a.xctoolchain/usr/bin/swift test Output
|
Running
In this case the error is a missing dependency - we've found out that missing dependencies often gives these errors of 'missing required module xxx' which perhaps could be improved (the error isn't really "could not build Objective-C module", but should be something like "Can't import a module we have no dependency for" or something). Adding the dependency fixes the error:
@ahoppen - maybe my reproducer was not valid for the original issue with sourcekit-lsp and a bit of a red herring for the original issue - even if it would be nice with a better diagnostic for my case too. |
If you are using M1, it seems like the launch task is not correct, so the module is build wrongly. Can check the folder |
I have a similar error
Which caused by adding swift file to objc Framework |
Any guidance on finding out what issue could be causing this error message? |
The issue will almost always be an unexpressed dependency, potentially using |
How is that warning (at least a warning, please!) not on by default?? |
cc @artemcm |
Should be fixed by #7103 because the compiler should not be picking up random modules anymore. |
Additional Detail from JIRA
md5: 9ddcee184f7c88e97c4a2a1e791ed8aa
Issue Description:
From https://forums.swift.org/t/unhelpful-error-could-not-build-objective-c-module-modulename/55381
Sometimes when loading a package into the VSCode extension the SourceKit-LSP server will return the error
where ModuleName is the name of some module being imported. This error appears on modules regardless of whether they include any Objective-C or not. Unfortunately I haven't found a consistent way to replicate this error. It appears to disappear if you build the project and restart VSCode. If it is related to the relevant module not being built it is not a very helpful message.
In what situations is this error message meant to appear.
The text was updated successfully, but these errors were encountered: