Bittoo Bittoo - 1 year ago 113
Swift Question

How to work with Swift file in Objective-C?

I want to use one third party library which is written in Swift but I am working in Objective-C environment. How to do that? Until now what I have done is:

  1. Drag and drop the third party library into my project.

  2. It is asking for the bridging header I clicked on yes.

  3. In Build settings
    defines Modules
    no to
    in both.

  4. Product Module Name showing like
    . I have tried with my project name also.

Now I am getting plenty of errors like below:

pDatePicker.swift:50:9: Consecutive declarations on a line must be separated by ';'


Ambiguous use of 'open'.

I am getting errors around 50 to 60 same as above errors. Where is my mistake? Can anybody help me?

Answer Source

Are you able to see projectName-Swift.h file in your project ?

If yes then, Hope you have imported #import "projectName-Swift.h" in Objectice C .m file ?

#import "projectName-Swift.h"

Then only you would be able to access objective c files in swift code.


  • Check in build setting
  • Objective-C Bridging Header
  • ProjectName-Bridging-Header.h has perfect location.

if there is problem with that path than bridging will not work properly , that why when you compile #import "projectName-Swift.h" is not getting generate.


Download above sample project.

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download