user83039
user83039

Reputation: 3167

Using Obj-C that relies on other Obj-C in Swift?

First I want to note, I've read this and have used it before and my question is different:
How to call Objective-C code from Swift

I'm trying to use this library in Swift.

This library uses OCMock and when I try to compile, I get 'OCMock/OCMock.h' file not found at the line #import <OCMock/OCMock.h>. Here's how I normally fix it, but this time, it's not working.

Just like every other Obj-C library in Swift, I added it to my bridge header, which I already had made and am using for others:

#import "JSQMessages.h"
#import "JSQMessageData.h"

I then added $(PROJECT_DIR) to my Header Search Paths.

Here is the file structure.

enter image description here

From the project directory, it should look for OCMock/OCMock.h, and it is there, as seen in screenshot. So why isn't it working?

Upvotes: 1

Views: 459

Answers (1)

Shuo
Shuo

Reputation: 8937

I just created a fresh swift iOS project, add JSQMessage using CocoaPod(http://cocoapods.org). No error. try following:

1. Create a new project

2. Create a podfile and add 

    pod 'JSQMessagesViewController'

3. Create a bridge header and add

     #import <JSQMessagesViewController/JSQMessages.h>    // import all the things

3. Run

    pod install

4. Open project.xcworkspace and build it

Upvotes: 1

Related Questions