Xcode not automatically creating bridging header?

John Durand picture John Durand · Jul 30, 2015 · Viewed 99.5k times · Source

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

Shamsudheen TK picture Shamsudheen TK · Jul 30, 2015

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 (choose all instead of basic), 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 directory.

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