2

这里是新开发人员,我目前正在快速构建一个应用程序。我们正在使用 cocoapods,但是在运行 pod install 之后,我们在 Objective-c 桥接头中收到一个错误,指出该文件无法找到,但对于我们桥接头中的所有文件都找不到。例如,我们使用 DateTools。我们 pod 安装它,在我们放置的桥接头中: #import <DateTools/DateTools.h> 但是,在运行时,它会出错,说'Datetools/Datetools.h' file not found. 我已经浏览了许多其他类似的帖子(例如thisthisthis),但没有一个解决了这个问题。任何帮助将不胜感激!

4

1 回答 1

4

使用时use_frameworks!Cocoapods 中的指令,在 Swift 中导入 Objective-C pod 不需要桥接头。

只需将所需的 pod 设置到 podfile 中:

#Uncomment this line to define a global platform for your project
platform :ios, '9.0'
#Uncomment this line if you're using Swift
use_frameworks!

target 'YourProject' do

#Swift Pods
pod 'Alamofire'
pod 'ActiveLabel'

#ObjC Pods
pod 'IDMPhotoBrowser'
pod 'Firebase'

#This stuff is to set the SWIFT_VERSION
post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '2.3'
        end
    end
end
end

运行pod install。运行pod update(应该不是必需的,但由于某种原因,我几乎每次都得到更新,即使在全新安装之后也是如此)。关闭 Xcode 并使用白色xcworkspace文件重新打开。

在此处输入图像描述

import Alamofire
import ActiveLabel 
import IDMPhotoBrowser
import Firebase

完毕。

于 2016-10-16T00:30:02.167 回答