John Durand John Durand - 1 year ago 171
Swift Question

Xcode not automatically creating bridging header?

I imported an Obj-C file into my swift project and Xcode automatically prompted me to create a bridging header file as expected. However, I deleted both the files (moved to trash) to make some changes, but when i try to import the Obj-C file once again, the prompt doesn't come up anymore. What is the reason? I even tested this same scenario in another project, It seems once I delete Xcode's auto created bridging header, It won't bring the prompt up again another time. Why is this?

Answer Source

The reason of your issue is, the Xcode build settings still holds the path to auto generated Bridging Header file. You cannot get any build errors because of the header file (ProjectName-Bridging-Header.h) still exist in your project directory.

How to resolve:

Click on your project target, Go to Build Settings tab, search for Bridging Header. You can see the Xcode generated path entry. Select it and click on delete button.

Also, make sure to delete the Xcode auto generated bridging header file (ProjectName-Bridging-Header.h) from your Xcode project.

Now, try to import the Obj-C file once again. You can see the prompt to create a bridging header file as expected.

enter image description here