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?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Using if let syntax in switch statement
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
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.
There are different way of creating Bridging Header in xcode as mention/suggested above. Here I would give you the best and easiest way of creating Bridge.
if you want to keep your header inside one group then use New Group and drag&drop your file in that group.
Never create any folder, or else you will get error due to that.
File -> New File -> Header File
Save it as a YourApp-Bridging-Header
Than go to Build Settings, find "Objective-C Bridging Header" (as previously guys told) and pass way to your Bridging Header as: YourApp/YourApp-Bridging-Header.h Where 'YourApp/' is a name of app. It could contain white space, for example 'Your App/'.
In my case in xCode 7.3.1 it works
If you want to configure it manually simply go to Build Settings and change the selection to ALL from Basic (Default) or customized.
Because empty fields are hidden to make things easier for the average end user, if you miss the prompt to add the bridging-header you may have difficulty finding it manually. Also the search option will not include hidden fields.
Change to All and the Swift Compiler - General section should appear with a child setting of "Objective-C Bridging Header"
Bridge file only prompt once in a project.
If you delete the file by accident, you have to build a new bridge file. It's the same.
Go to
File->New File->Header File
, and the name should beYourProjectName-Bridging-Header
, or else It can't be recognised.have a look under your project settings -> build settings, scroll down to the
User-Defined
section, see if it has a key calledSWIFT_OBJC_BRIDGING_HEADER
and if it has a value. if its there it probably thinks you have one already, in that case just recreate the file with the same name.