Search code examples
iosswifttvos

Cannot find protocol declaration for *** in my 'MyApp-Swift.h'


I am working on a project that up to now, despite the mess, it was working ok. Today, believe it or not, I have been updating it to Swift 5.

The project has iOS and tvOS targets as well as frameworks, tests, and top selves extensions. The project also was started using Objective-C and over the years has become 90% Swift.

I am not sure at what point something went wrong but, when compiling, I get the following error for all my top self extensions (mostly all tvOS Targets).

enter image description here

I have found similar questions but I can't understand whats going on.

Any ideas?


Solution

  • First, I have to thank Rob for his tips. I wish he could get the points!

    After troubleshooting with the tips provided:

    • Add StoreKit to your linked frameworks list. -> Didn't work
    • @import StoreKit; before #import <...-Swift.h> -> Showed error use of @import when modules are disabled

    I also saw that "...-Swift.h" was only declared in the Build settings of my "...Topself" targets. Still quite unsure why as I would have thought the whole project still have ObjC dependencies... Still quite new to this challenge.

    Furthermore, If I unfold the error I could see that there was some kind of error trying to find "...-Swift.h" file.

    At this point, I remembered that I am using cocoapods (I don't like you, you don't like me relationship) and I hated to see the warning "...Overrides Enable modules (C - Objective-C)" so I set it to default for the whole project.

    Turns out that that for all "...TopSelf" targets, the default value is NO.

    By Overriding Enable modules (C - Objective-C) to YES, clean, and build, everything started working again.