使用 cocoapods 时出错 "use_frameworks!" SWIFT

error using cocoapods "use_frameworks!" SWIFT

我有一个干净的 swift 项目,使用了一些 cocoapods:Parse、AFNetworking 和 RESideMenu。 我需要使用 STZPopupView pod,所以我将 cocoapods 更新为最新版本:

gem install cocoapods

然后我为我的项目重新启动它:

pod install

因为这个错误:

[!] Pods written in Swift can only be integrated as frameworks; this feature is still in beta. Add `use_frameworks!` to your Podfile or target to opt into using it.

我更新了我的 podfile 添加 "use_frameworks!"

我的播客文件现在是:

# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
use_frameworks!

source 'https://github.com/CocoaPods/Specs.git'

target 'isam' do
pod 'RESideMenu', '~> 4.0.7'
pod 'AFNetworking', '~> 2.5'
pod 'Parse', '~> 1.6'
pod 'STZPopupView', '~> 1.0'
end

target 'isamTests' do

end

因为,我在构建时遇到了 2 个错误:

我没有更改项目中的任何其他内容。

我的Swift-Bridging-Header.h没有改变:

#ifndef isam_Swift_Bridging_Header_h
#define isam_Swift_Bridging_Header_h

#import <Parse/Parse.h>
#import <RESideMenu.h>

#endif

在我的构建设置中,我有:

我认为这是因为我的 podfile 中有 "use_frameworks!",但我不知道如何使用我所有的 pods 来正确构建我的应用程序。

编辑:

准确的错误是:

/path_of_my_project/Swift-Bridging-Header.h:12:9: error: 'RESideMenu.h' file not found
#import <RESideMenu.h>
        ^
<unknown>:0: error: failed to import bridging header '/path_of_my_project/Swift-Bridging-Header.h'

尝试从 Objective-C 桥接 Header 中删除 isam/ 并且只有 Swift-Bridging-Header.h

根据个人经验,CocoaPods 在结合swift 和Objective C 框架时仍然存在一些问题。您可以使用 Alamofire,它几乎等同于 swift 的 AFNetworking。

希望这对您有所帮助。

编辑: 还有为什么在可以直接使用 swift 库的情况下在 swift 中使用 Objectice-C 解析。

其实我也遇到了同样的问题。你可以试试这个:http://www.innerexception.com/2015/05/cocoapods-useframeworks-means-bridging.html

使用时use_frameworks!在 CocoaPods 中,所有 pods 都将用作框架,而不仅仅是 swift pods。所以你不需要桥接头。只需将您的 pods 导入您需要的所有 swift 文件。 在您的示例中,您必须编写: 导入 RESideMenu

我遇到了同样的问题。例如,我将所有导入从 #import "RESideMenu.h" 更改为 #import <RESideMenu/RESideMenu.h>