Issue with Xcode 16 - Errors When Splitting Code for Widgets

I’m encountering an issue since I started using Xcode 16. I have a widget in my app, and I'm trying to organize the code by splitting it into different files for better structure.

However, when I do this, I get an error:

error: Unexpected input file: /Users/******/Desktop/TestApp/TestAppWidget/Provider.Swift (in target 'TestAppWidgetExtension' from project 'TestApp')

I want to emphasize that if I keep all the code in one file, everything works fine.

I've checked the Target Membership, and it's set up correctly.

but I don't understand why this is happening only in Xcode 16.

Has anyone else experienced a similar issue or has any ideas on why this is occurring? I would appreciate any help!

Is the error due to Swift suffix instead of swift ?

Try to rename

TestAppWidget/Provider.Swift

to

TestAppWidget/Provider.swift

See more explanation here: https://www.reddit.com/r/Xcode/comments/1cyg5hr/sure_hope_this_helps_someone/

Don't forget to close the thread by marking the correct answer if it is solved. Otherwise, please provide more information if possible.

Have you checked your build phases as well to make sure there are no issues?

Also perhaps deleting the file reference in Xcode and re-adding it may help.

I want to clarify that this issue only occurs in Xcode 16. Everything worked fine in version 15. The problem happens both in my existing project and even if I create a new, completely clean project.

Issue with Xcode 16 - Errors When Splitting Code for Widgets
 
 
Q