Cursor shows syntax errors in a Swift project

I’m encountering a strange issue in Cursor 0.44.11 while working on a small Xcode Swift project (with only 2 views). Cursor displays syntax errors that don’t actually exist—Xcode shows no errors, and the project builds successfully. I’ve tried re-indexing the codebase and restarting Cursor, but the issue persists.

I have all Swift and Xcode related tools installed in Cursor: swift-format, XcodeGen, SwiftLint, xcbeautify, xcode-build-server, ios-deploy, tuist and SweetPad.

1 Like

I think it’s not a pointer error

Hey, press Cmd + J and go to the Problems tab. Check what’s causing these errors, I suspect it’s an extension. If so, I think you can create exceptions for it.

I browsed the Problems tab, the app shows for example this error:
Cannot find PaymentView in Scope
this error means that the debugger cannot find the struct named: PaymentView
but it actually exists, so Cursor reports false syntax errors, plus the project is very simple and no extensions installed on it.

p.s. I found this issue that looks similar to mine.

Hey, feel free to get help from others here, but just to be clear, this will likely be a configuration issue with whichever extension is powering the syntax highlighting here, and not a Cursor bug!

1 Like

Do you have a buildServer.json file in the project’s root folder? If not, try building it with SweetPad or xcode-build-server and then restart Cursor.

I already have the buildServer.json file in the project’s root folder, built with SweetPad and did a restart for Cursor, but unfortunately, this didn’t resolve the issue.

As a newcomer to VSCode/Cursor, transitioning from an “all-in-one” tool like Xcode, I now understand that the issue may not be with the IDE itself but could be caused by an extension. In my case, it seems that SwiftLint might be the source of the problem. I’ll check their repo to see if this issue has been reported already, and if not, I’ll report it there.

I think I am having this same issue. For me, I create a new project in xcode and open it in Cursor with Swift extension installed. Has a bunch of errors. Seems to originate at the top level. It has to be some environemnt issue, but I have uninstalled and deleted cursor configurations tried uninstalling VSCode extensions. I am not trying to do anything more that code editing but it shows a bunch of errors on the simplest example.

2 Likes

well i guess it’s because swift-vscode extension does not support Xcode project: Get errors for not finding variables in scope (that are found in Xcode · Issue #1221 · swiftlang/vscode-swift · GitHub

frustrated that we still need to encounter numerous cannot find X in scope problems in Cursor (and VSCode).

Hi, have anyone found some solution for this? Gotta say I was pretty hyped for some SwiftUI development with Cursor, but then I encountered these as soon as AI agent created first new file. Like you say, if you open the project in Xcode there is no problem, everything compiles and works. Even weirder, after that errors go away in Cursor as well. And yeah, I’m aware that this may be some problem with extension, not necessarily Cursor itself. It just makes it impossible to work in Agent mode, because it will create a file just fine, see the linter errors and start backtracking because of these right away.