Swift can't use ObjectiveC classes

| | August 5, 2015

I want use JSQMessagesViewController in my project(using swift), I didn’t use pods since I would modify some of the ObjectiveC code, so I just pull the Project into my own iOS project. And I include the OC project file in my Project-Bridging-Header.h file, it builds successfully. However, when I use the objectiveC classes, the complier cannot recognize it.

Is there some configuration that I missed, or if I did it in a completely wrong way?

With Regards.

One Response to “Swift can't use ObjectiveC classes”

  1. Try the solution given below. It worked for me.

    Go to Project traget -> Build Settings -> Objective-C Bridging Header

    Set this as your Projectfolder/projectname-Bridging-Header.h

    Add you “sample.h” and “sample.m” file in the project folder and add import the sample.h in the “projectname-Bridging-Header.h” file as given below:

    #import "sample.h"

    save it and check if you get access to the function of Objective-C functions in your swift code.

Leave a Reply