How to import JSQMessagesViewController in swift?

孤街醉人 提交于 2019-12-12 11:39:34

问题


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.


回答1:


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'



回答2:


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.




回答3:


This should work:

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

Example taken from this Swift repo.




回答4:


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)



来源:https://stackoverflow.com/questions/29692448/how-to-import-jsqmessagesviewcontroller-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!