cannot find type in scope xcode 13

I had many swift compiler errors of this type : "Cannot find type 'className' in scope" after passing from Xcode 12.5 to Xcode 13. And the error is always referred to Objective-C classes. The project is for an iOS 11 app for iPad.

The bridging-header is correctly set and the project with the same build-settings has never given this error before Xcode 13.

I'll try to clean the derived data folder without success. the strange thing is project compile successfully and I can run on simulator as well but after few second from a successful compilation on any swift files that use objective-c class is fired the swift compiler error.

Any idea? thanks

Answered by mrcdev in 696443022

I finally solved the problem removing all #import in bridging header of files contained in my pods libraries

Could you post the code where you get the error message, as well as the needed context ?

I add sample code and screen of the error, i hope is useful, PersonalEditorContentPageVC and QWidget are Objective-c classes.

class ContactViewController:PersonalEditorContentPageVC {
    var activeWidget:QWidget?
    var prevActiveWidget:QWidget?

I've got the same issue. In Xcode 13 only, I get "Cannot find X in scope" errors for all the objective-c stuff that i'm using in Swift, but the project still builds and runs successfully.

I've got the same issue. Is there any way to solve this issue?

@YShaw, the same error declaration would help very little solving your issue. You should better start your own thread with including enough info.

Same issue after upgrading to Xcode 13, Any fix ?

Go to build settings and build after setting Precompile Bridging Header YES -> NO. You can show no errors. But codes defined by objec aren't recognized. It is not able to jump to definition.

Accepted Answer

I finally solved the problem removing all #import in bridging header of files contained in my pods libraries

I finally solved the problem with Product -> Clean Build Folder

I am seeing complier error on WKMediaCaptureType and WKPermissionDecision. I made sure WebKit is imported in WebViewDelegationHandler.swift file. Cannot find type 'WKMediaCaptureType' in scope. Cannot find type 'WKPermissionDecision' in scope. Any clue why it is happening. Thanks in advance!

In my case, everything works but Xcode reports errors anyway. In this case, moving around the order of imports in the bridging header helped.

So it's not a real problem but you can solve it anyway.

cannot find type in scope xcode 13
 
 
Q