cannot find type 'ConfigurationIntent' in scope

In the OC project, iOS14 WidgetKit target was added, but consistent error
  1. Cannot find type "ConfigurationIntent" in scope,

  2. type 'Provider' does not conform to protocol 'IntentTimelineProvider'

What is strange is that after adding a new OC project, the compilation is successful,

Tool: Xcode12-beta & Simulator

How to get access to old projects?
Up vote post of zhangkk Down vote post of zhangkk
Post marked as solved 1.1k views

15 Replies

I'm running into the same problem. I nailed it down to my bridging header and the references Objective-C class file, which is also included to the project. If I remove the bridging header, and the Objective-C file, the compile is successful, and the errors are gone.

Any more ideas are highly welcome, because converting this Objective-C class to Swift would be a nightmare.

Project prefix: ABC
Intents file: MyIntents.intentdefinition
Custom Intent: DynamicMySelection

put this line to bridge header:
Code Block
#import "ABCDynamicMySelectionIntent.h"

Here is example of your provider:
Code Block
struct Provider: IntentTimelineProvider {   
  typealias Intent = ABCDynamicMySelectionIntent
func getSnapshot(for configuration: ABCDynamicMySelectionIntent, in context: Context, completion: @escaping (SimpleEntry) -> Void) {...}
func getTimeline(for configuration: ABCDynamicMySelectionIntent, in context: Context, completion: @escaping (Timeline<SimpleEntry>) -> Void) {...}
struct MyWidget: Widget {
  let kind: String = "MyWidget"
  var body: some WidgetConfiguration {
    IntentConfiguration(kind: kind, intent: ABCDynamicMySelectionIntent.self, provider: Provider()) { entry in

I ran into this same issue and solved it – @iceleaf is correct. To elaborate...

Manually create a bridging header file in the widget target. Go into the the target settings for the widget, select build settings, and under "Swift Compiler - General" make sure that "Objective-C Bridging Header" has the correct path (ie, "<widget-target-name>/<project-name>-Bridging-Header.h").

Navigate to the bridging header file and add #import "ConfigurationIntent.h"

Everything should once again compile.
If your project set class prefix 'ABC', add it to demo code. 'ConfigurationIntent' -> 'ABCConfigurationIntent'
if your project class prefix is 'ABC', just change the sample code 'ConfigurationIntent' to 'ABCConfigurationIntent'
I'm still facing this issue, cannot build widget target on an objective-c based project
I tried @iceleaf solution but that was too technical for me, needs more explanation :)
Also I tried to set Intent Generation to Objective-C in build settings as per @developer555 but that didn't help.
I was able to get it working by switching Intent generation to Objective-C in my WidgetKit target. Hopefully this will get fixed shortly.
How do you add the intent to the bridging header? "ConfigurationIntent.h" can't be found and "ConfigurationIntent.intentdefinition" throws a bunch of errors. Hopefully @iceleaf or @zhangkk are still around to answer :)

I didn’t get a practical solution for the last exchange. I tried to add widget without using Intent, and found that this error disappeared.

Fortunately, this question answered. Thanks, @ iceleaf 

Well,I solved this problem, after asked the engineer of Apple.
There are some tips:
1、add Header Bridge file to Widgets extention
2、add ConfigurationIntent class reference to the bridge head file.

Last but not least,if you set Class Prefix in Project setting,your ConfigurationIntent class may be named like
Thank u @zhangkk!If Apple technicians can fix this issue soon, please tell us, we all eager to know!

@mgoemmel Hi, Markus, If I create a new OC project, and then i create a new widgetKit in it, the project will run nicely, widgetKit will run nicely too, thats very strange.
Year, For now, it has not been solved.

My problem is slightly different from your description. I am dating widgetKit in the OC project and reported an error before the OC file was referenced. Your problem will be the next one I face.

Fortunately, we will talk with Apple technicians about this issue soon, and we will update the conclusion here

Well, there is not much to elaborate. WidgetKit is Swift only, so using Objective-C sources needs a bridge header file. When I'm using a bridge header file and add an Objective-C source to my WidgetKit project, then the error you are asking for appears. If I remove both, the error file is gone. This explains why a new project does not show this error, but an existing project does.

Unfortunately I do not have a solution to this problem, so I'm hoping that Apple will fix this issue in one of the next Xcode beta versions. Or some new background about the problem will be revealed.

Unfortunately this thread is marked as solved now, which it definitely isn't :-(

@mgoemmel Can you elaborate?
Tool: Xcode12-beta2 & Simulator

The same problem I met!!!!

How to get access to old projects?