Skip to content

@main and ContentView Problem #1556

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

Open
hxphieno opened this issue May 13, 2025 · 5 comments
Open

@main and ContentView Problem #1556

hxphieno opened this issue May 13, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@hxphieno
Copy link

I created a new project with my Xcode and planned to write subsequent code in VScode, but at this time I found that @main and ContentView are always in an error state. How can I solve this problem?

Image Image
@hxphieno
Copy link
Author

I have tried adding .vscode/setting.json and .buildServer.json but all failed. I can basically determine that the code problem should be related to the computer environment. This happens on my m3 air regardless of vscode or trae, but it does not happen on my m2 pro. @main does not prompt an error and ContentView is indexed normally. But I still can't find a solution successfully.

@hxphieno
Copy link
Author

But in my Xcode everything works fine

@plemarquand
Copy link
Contributor

Unfortunately the VS Code extension only supports Package.swift based projects, not .xcodeproj based projects.

@hxphieno
Copy link
Author

Unfortunately the VS Code extension only supports Package.swift based projects, not .xcodeproj based projects.

Hmmm……However, I did install the same configuration on other computers with the same xcodeproj based project, but there was no such error. I don't think the type of project is important. I would like to know the really reason and some methods that only change configuration without changing the code for this problem.

@plemarquand
Copy link
Contributor

In order to determine symbol information the extension needs to know what and where your dependencies are, and it uses SwiftPM and sourcekit-lsp to determine that, both of which work with Package.swift based projects. If you load a .xcodeproj based project in the VS Code Swift extension it cannot determine what your dependencies are and so you'll get missing symbols like what you're seeing.

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
Development

No branches or pull requests

2 participants