swiftxcode

OK to say 'No' to 'Would you like to configure an Objective-C bridging header?' when first adding an existing Swift file?


On the first attempt to add an existing Swift file to a Swift only Xcode project it states that adding this file will 'create a mixed Objective-C and Swift project' and asks 'Would you like to configure an Objective-C bridging header?'

But it isn't a mixed Objective C project. It was created from scratch as Swift only and has no Objective C code (well, none that I added anyway). And even if it does have some Objective-C (I guess the initial view controller that Xcode creates as a template inherits from an Objective-C class) then that means it was always a mixed project and adding another Swift file does not change that.

So, is it correct to say 'No' to this question?


Solution

  • It's perfectly fine to say No to this question. If you did want to use any Obj-C libraries (which is likely) then a bridging header is necessary and it does no harm to have one, you shouldn't see the prompt again.

    It's unusual that the prompt is displaying at all, if there is no Obj-C in your code then it may be a bug. More likely if you're using a beta.