Umair Afzal Umair Afzal - 5 months ago 22x
Swift Question

Unable to Import Objective-C Files into Swift project using bridging header

I created an objective-C project for socket programming and its working fine now i want to import it into my Swift project where i am using JSQmessageViewController for chating. I copied "AsyncSocket.h" and "AsyncSocket.m" into my swift proejct and imported them in bridging header as well but when i try to use them in my "ViewController.swift" it gives me error
My bridging Header is working fine because i can use JSQmessageViewController in my "ViewController.swift" without any issues. This is my bridging header

enter image description here

Build Settings seems fine to me

enter image description here

But still getting this error

enter image description here


No. You don't import your Objective-C file directly to your swift file. Write something like

let asyncSocketInstance:AsyncSocket = AsyncSocket()

. Make sure AsyncSocket appears under Compile Sources of Build Phases and its header file is imported in the bridging header file.