jerry_sjtu
jerry_sjtu

Reputation: 5456

How to import JSQMessagesViewController in swift?

I am working with xcode 6.3, swift 1.2 and I install the "JSQMessagesViewController" library with cocoapods. Here is my pod file:

pod 'JSQMessagesViewController'

and my bridge file:

#import <JSQMessagesViewController/JSQMessages.h>

then I get the error:

'JSQMessagesViewController/JSQMessages.h' file not found with <angled> include; use "quotes" instead

I don't know why it goes wrong. When I update the bridge file with

 #import "JSQMessagesViewController/JSQMessages.h"

I get the error

JSQMessagesViewController/JSQSystemSoundPlayer+JSQMessages.h:19:9: 'JSQSystemSoundPlayer/JSQSystemSoundPlayer.h' file not found with <angled> include; use "quotes" instead

This really gets me confused because the error is in the source code of JSQMessagesViewController which I cannot modify. I have googled for one day and get no methods to fix it. Since the JSQMessagesViewController library is so popular in githup, I believe the there must be someone know how to fix it.

Upvotes: 4

Views: 6689

Answers (4)

Andre Simon
Andre Simon

Reputation: 692

For me it worked using this Podfile:

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
pod 'JSQMessagesViewController'

And creating the bridge header.

(iOS 9, xCode 7, cocoapods 0.39.0)

Upvotes: -1

bolnad
bolnad

Reputation: 4583

I ran into this issue and I was using Xcode7, swift 2, iOS 9, using cocoapods version 0.38.2 and what solved it for me was removing the declaration of #import <JSQMessagesViewController/JSQMessages.h> from the Bridging-Header.h file.

Then import it to the class you want to use it in.

 import UIKit
 import JSQMessagesViewController

 class MessageViewController: JSQMessagesViewController {

 }

As of Cocoapods 0.36 if you put use use_frameworks! into the Podfile (like Eric D said, then cocoapods will create a framework of any Pod that you include.

Upvotes: 4

Edwin Vermeer
Edwin Vermeer

Reputation: 13127

You used the notation for a framework. Are you using cocoapods 0.36 or later? Then you could make a framework from JSQMessagesViewController by putting this in your pod file:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'JSQMessagesViewController'

Upvotes: 5

Eric Aya
Eric Aya

Reputation: 70094

This should work:

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

Example taken from this Swift repo.

Upvotes: 3

Related Questions