Swift / Objective C interoperability

I am working on an app in Objective C. I added the the StoreKit framework with the logic using swift. everything worked as planned except for when I wanted to access properties and methods from my ObjC ViewController in the swift code. I did everything as is directed in the apple developer documentation, except it didn't work. I kept receiving the following errors;

  1. failed to emit precompiled bridging header
  2. ViewController.h file not found ( for the import code in the bridging header)

I spent a whole day perusing the internet for a solution. Unfortunately, nothing worked. I thought I should try to import other classes from the ObjC into the bridging header. When I imported 3 files the 3rd one took after commenting out the 2 above it. Then I imported the ViewController again and the build was successful. I deleted every imported file above the file that I need to make visible to the swift compiler leaving the empty lines above it. Apparently, I was getting the errors because my import code was on line 4 instead of line 9, although the file is completely empty except for the comments created by Xcode when the file was automatically created.

I am not sure why the placement of the line of code holds that much weight when the file is empty?

**Can anyone explain to me any technicality that would lead to this issue? **

After that issue was fixed I ran into the issue again sporadically alternating with another error

Cycle inside MyApp; building could produce unreliable results.

As I read from other similar issues that were encountered; it's a bug in Xcode 15.

So you build successfully but every now and then you get the failed to emit precompiled header error and sometimes the cycle error.

One of the solutions was to move the embedded Pods Frameworks above the compile Sources.

Swift / Objective C interoperability
 
 
Q