我正在尝试在 Swift 中创建一个名为 CouchbaseKit
(Xcode 中的新目标)的自定义框架.在我的 CouchbaseKit
中,我需要访问完全用 Obj-C 编写的 CouchBaseLite Framework
.我正在使用 Cocoapods
来管理 CouchBaseLite
和其他几个框架.下面是我的 podfile.
I'm trying to create a custom framework called CouchbaseKit
(a new target in Xcode) in Swift. Inside my CouchbaseKit
, I need to access CouchBaseLite Framework
that's entirely written in Obj-C. I'm using Cocoapods
to manage CouchBaseLite
and a couple of other frameworks. Below is my podfile.
Podfile
# Uncomment this line to define a global platform for your project
link_with ['CouchbaseKit']
# platform :ios, '8.0'
use_frameworks!
target 'CouchbaseDB' do
link_with ['CouchbaseKit']
pod 'couchbase-lite-ios'
pod 'SwiftyJSON', '~> 2.2.0'
pod 'Alamofire', '~> 1.2'
pod 'XCGLogger', '~> 2.0'
end
target 'CouchbaseDBTests' do
end
target 'CouchbaseKit' do
end
target 'CouchbaseKitTests' do
end
项目内的 Pod:
对于我的 TARGETS,我在 Build Phases 中有以下设置.
For my TARGETS I have the following settings in Build Phases.
定义模块是
允许框架模块中的非模块化包含是
问题:当我尝试访问我的 CouchbaseKit(我的自定义框架)中的 CouchbaseLite 框架时,我收到一个错误,没有这样的模块 'CouchbaseLite' 不存在.
Problem: When I try to access the CouchbaseLite framework inside my CouchbaseKit (my custom framework), I get an error, "No such module 'CouchbaseLite' does not exist.
试过了:
由于项目使用 Swift,我创建了一个 Objective-C 文件并点击您想配置一个 Objective-C 桥接头吗?"
即使在所有目标中将框架模块中的允许非模块化包含"设置为是",当我尝试 #import <CouchbaseLite/CouchbaseLite.h>
时仍然会出错在 CouchbaseKit.h
Even though Allow Non-modular Includes in Framework Modules is set to YES in all targets, I still get an error when I try to #import <CouchbaseLite/CouchbaseLite.h>
in CouchbaseKit.h
这是我的自定义框架的构建阶段的样子 CouchbaseKit
Here is what my Build Phases looks like for my custom framework CouchbaseKit
问题:如何在我的自定义 Swift 框架中查看外部 Objective-C 框架 (CouchasebaseLite)?
Question: How can I see an external Objective-C framework (CouchasebaseLite) in my custom Swift framework?
不幸的是 Cocoapods 0.39 存在Transitive Vendor Dynamic Libraries Unsupported" 你会在最新的 couchbase-lite-ios 版本中看到这一点,包括二进制 CouchbaseLite.framework.这个不幸的问题让我很难受,我不得不重构一切以使用 Carthage,并在我的最终项目中手动管理我的框架.
Unfortunately Cocoapods 0.39 suffers from "Transitive Vendor Dynamic Libraries Unsupported" You'll see this with the newest couchbase-lite-ios release including the binary CouchbaseLite.framework. This unfortunately issue bit me so hard I had to refactor everything to use Carthage, and manually manage my frameworks in my final projects.
说到二进制发布的 CouchbaseLite.framework 只是缺少一个模块映射.
Speaking of which the binary released CouchbaseLite.framework is simply missing a module map.
添加一个到:CouchbaseLite.framework/Modules/module.modulemap
Add one to: CouchbaseLite.framework/Modules/module.modulemap
framework module CouchbaseLite {
umbrella header "CouchbaseLite.h"
export *
module * { export * }
}
然后,您将能够将此框架包含到桥接头中,并让您的动态框架正确嵌套.但是您可能需要像我一样切换到构建您的 CouchbaseKit.framework 以使用 Carthage.
You will then be able to include this framework into a bridging header, and have your dynamic framework nest properly. But you might need to switch to building your CouchbaseKit.framework to using Carthage like I did.
这篇关于iOS8:自定义 Swift 框架访问用 Objective-C 编写的外部框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!