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

Build swift package attempts to build only for MacOs error :no such module 'UIKit' #1361

Closed
MikePendo opened this issue Feb 6, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@MikePendo
Copy link

Describe the bug
I have fetched an iOS package. attempt to run swift build
and had the following error:
error :no such module 'UIKit'
As far as I can see it builds only for Mac so the error makes sense
so I tried some works arounds like:
swift build --arch arm64 -Xswiftc -sdk -Xswiftc /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.1.sdk -Xswiftc -target -Xswiftc arm64-apple-ios18.0
but that has some other errors

To Reproduce
Steps to reproduce the behavior:

  1. clone for instance the following https://github.com/openreplay/ios-tracker I guess it can be any other package
  2. run swift build

Expected behavior
Run swift build successfully to use jump to code in VS code

Environment

  • OS: Sonoma 14.7.2
  • Swift version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
  • Visual Studio Code version: 1.96.4
  • vscode-swift version: 1.11.4

Thanks

@plemarquand
Copy link
Contributor

Hi, this issue doesn't seem to be related to the VS Code Extension for Swift, but instead looks like a build configuration error. The swift build command is provided by the swift binaries included in your Swift Toolchain; If you still think this is an issue you could create an issue in the swift-package-manager repository with detailed reproduction steps or a sample project.

@rbenegal
Copy link
Contributor

rbenegal commented Feb 6, 2025

Hi @MikePendo thanks for reporting this. Just to add to what Paul mentioned, I think what's happening here is that by default the toolchain is set to macOS. In the latest version of the extension (version 2.0.0 onwards, which should be released shortly), you will able to do a Cmd+Shift+P, then Swift: Select target platform and select the iOS toolchain. This should pass in the right flags.

#1335 will also have to be fixed, but until then you'll have to set the Swift.SDK setting to arm64-apple-ios. This should allow you to use features like 'Go to definition' in the code without having to do a swift build.

@MikePendo
Copy link
Author

Hi
Thanks of quick response @plemarquand , @rbenegal,
in your documentation you specify how to build it, and swift build will not build any iOS package as far as I can see (discussion ), so how do we suppose to use this extension in that case?
I mean if your extension is heavily dependent of swift build which doesnt support iOS it basically means that your extension will not work for any iOS package? in that case maybe its worth to mention that this extension for macOS only?
Are there any work around you can recommend for now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants