DrustZ
DrustZ

Reputation: 352

When I import OBJ-C classes in swift, Xcode doesn't prompt me to add a Bridging-header.h

When I first import an OBJ-C class into a swift project, Xcode doesn't prompt me to add a bridging-header file.

so I fixed in the same way as in Swift Bridging Header and visibility of Obj-C class

But when I want to import another Obj-C class, if I do the same thing again, the file's url will be mixed so that Xcode can't distinguish them.

I tried to make a bridging-header file by myself , but didn't work either. Help please.

Upvotes: 2

Views: 1487

Answers (2)

DrustZ
DrustZ

Reputation: 352

ok,NOW I fixed this problem and in addition I figured out how "bridging header"file works.

Actually I followed the method of the question I mentioned above, but what I need to drag is exactly the "bridging-header" file, rather than other implicit header file (because you can only import one header file there.)

So I created a header file called "myproject-bridging-header.h" (actually the name doesn't matter) and dragged it to the item, and in the header file I imported other header files

Bingo! It works smoothly~

Upvotes: 0

mustafa
mustafa

Reputation: 15464

To make bridging header manually first create header file. Name it whatever you want. Then Click your project's target and open Build Settings tab and search "Bridging". You will see "Objective-C Bridging Header" option. Double click it and write your bridging header name like this format TargetName/BrdgingFile.h

enter image description here

Upvotes: 8

Related Questions