Swift Objective-C header is not found when archiving the app

1k views Asked by At

I am trying to add Swift class in one objective-c file for which I had to add *-Swift.h file in my objc file. While the project works fine in debug mode but when I try to archive my app it's throwing error saying that particularly that *-Swift.h file is not found. I tried many solutions but none of them worked. Then I got this question on apple website which is exactly the same problem but his solution which was to set precompile prefix header to YES also did not work for me. (https://forums.developer.apple.com/thread/7512).

I do understand that this header is generated in derived data and build process for debug and archive is different but nothing is working in my case.

I have one framework inside which my app target is located. I am adding the header in my objc as #import "My_Project-Swift.h"

I am using XCode 10.

1

There are 1 answers

0
pconor On

Here is what worked for me:

  1. In Xcode: Product -> Clean (Shift+Cmd+K)
  2. Delete Derived Data
  3. Change Precompiled Prefix Header to YES in the target build settings
  4. Close Xcode
  5. Open Xcode
  6. Archive