【问题标题】:How to import JSQMessagesViewController in swift?如何快速导入 JSQMessagesViewController?
【发布时间】:2016-01-30 00:55:20
【问题描述】:

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

pod 'JSQMessagesViewController'

还有我的桥接文件:

#import <JSQMessagesViewController/JSQMessages.h>

然后我得到错误:

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

我不知道为什么会出错。当我使用

更新桥接文件时
 #import "JSQMessagesViewController/JSQMessages.h"

我得到了错误

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

这真的让我很困惑,因为错误在 JSQMessagesViewController 的源代码中,我无法修改。我用谷歌搜索了一天,没有找到修复它的方法。 由于 JSQMessagesViewController 库在 githup 中非常流行,我相信一定有人知道如何修复它。

【问题讨论】:

  • @jessesquires 你能帮我解释一下吗?非常感谢!
  • 这里也一样,暂时没有解决方案:(

标签: ios xcode swift cocoapods jsqmessagesviewcontroller


【解决方案1】:

您使用了框架的表示法。您使用的是 cocoapods 0.36 或更高版本吗?然后,您可以通过将 JSQMessagesViewController 放入您的 pod 文件中来创建一个框架:

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

【讨论】:

    【解决方案2】:

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

    然后将其导入到您要使用的类中。

     import UIKit
     import JSQMessagesViewController
    
     class MessageViewController: JSQMessagesViewController {
    
     }
    

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

    【讨论】:

    • 这对我有用!我的桥接头不再需要 #import
    【解决方案3】:

    这应该可行:

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

    示例取自 this Swift repo

    【讨论】:

    • 我仍然收到错误:/Pods/Headers/Private/JSQMessagesViewController/JSQSystemSoundPlayer+JSQMessages.h:19:9: 'JSQSystemSoundPlayer/JSQSystemSoundPlayer.h' 文件未找到 包含;改用“引号”
    • 您是否也将sound player 与 CocoaPods 一起安装?您的安装中似乎缺少它。
    • 或者导入语法也必须改变,就像其他的一样:#import "JSQSystemSoundPlayer.h"
    • CocoaPods 会自动安装 JSQSystemSoundPlayer。添加 #import "JSQSystemSoundPlayer.h" 不能解决问题。 @ericd
    【解决方案4】:

    对我来说,它使用这个 Podfile 工作:

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

    并创建桥头。

    (iOS 9,xCode 7,cocoapods 0.39.0)

    【讨论】:

      猜你喜欢
      • 2021-05-06
      • 2015-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-27
      • 1970-01-01
      • 2014-02-25
      • 1970-01-01
      相关资源
      最近更新 更多