xcode 如何快速导入 JSQMessagesViewController?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29692448/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:01:14  来源:igfitidea点击:

How to import JSQMessagesViewController in swift?

iosxcodeswiftcocoapodsjsqmessagesviewcontroller

提问by jerry_sjtu

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

我正在使用 xcode 6.3、swift 1.2,并使用 cocoapods 安装“JSQMessagesViewController”库。这是我的 pod 文件:

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.

这真的让我感到困惑,因为错误出在 JSQMessagesViewController 的源代码中,我无法修改。我已经用谷歌搜索了一天,但没有任何方法可以解决它。由于 JSQMessagesViewController 库在 gitup 中如此流行,我相信一定有人知道如何修复它。

回答by Edwin Vermeer

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:

您使用了框架的符号。您使用的是 cocoapods 0.36 或更高版本吗?然后你可以通过将它放在你的 pod 文件中来从 JSQMessagesViewController 创建一个框架:

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

回答by bolnad

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.hfile.

我遇到了这个问题,我使用 Xcode7、swift 2、iOS 9,使用 cocoapods 0.38.2 版,为我解决的是#import <JSQMessagesViewController/JSQMessages.h>Bridging-Header.h文件中删除的声明。

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.

从 Cocoapods 0.36 开始,如果你使用 use_frameworks!进入 Podfile(就像 Eric D 说的那样,然后 cocoapods 将创建一个包含您包含的任何 Pod 的框架。

回答by Eric Aya

This should work:

这应该有效:

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

Example taken from this Swift repo.

取自这个 Swift repo 的示例。

回答by Andre Simon

For me it worked using this Podfile:

对我来说,它使用这个 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)

(iOS 9, xCode 7, cocoapods 0.39.0)