Xcode无法看到通过Cocoapods添加的对象 [英] Xcode can't see objects added via Cocoapods

查看:153
本文介绍了Xcode无法看到通过Cocoapods添加的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下pod定义了 podfile

 平台:ios,'8.0'
use_frameworks!

目标'LifeStream'做
pod'SSKeychain'
pod'LiveSDK'
pod'Alamofire',:git => 'https://github.com/Alamofire/Alamofire.git',: branch => 'swift-2.0'
结束

我安装了pod并打开了我的工作区。我发现Alamofire的任何使用都可以正常工作,因为它将Swift 2版本作为框架导入项目。



当我尝试使用SSKeychain类时,我收到了


使用未解析的标识符'SSKeychain`


同样适用于我尝试在LiveSDK中使用的任何类。



我的项目根目录中有一个桥头,项目配置为使用它。

  #ifndef Header_h 
#define Header_h

#importSSKeychain / SSKeychain.h
#importLiveSDK / LiveConnectClient.h

#endif / * Header_h * /

如果我从

更改 #import

  #importSSKeychain / SSKeychain.h

to

  #importSSKeychain.h

Xcode无法编译,因为它无法找到该文件。所以我假设桥接头正在工作,因为我的桥接头现在构建的方式不会因为找不到头而导致任何编译器错误。



Bridge Header





框架搜索路径



我还添加了我的项目根目录到框架搜索路径。





链接框架



最后,我已将所有框架链接到项目还有。





我的设置错过了什么?我已经有一周没能让Cocoapods在我的项目上工作了。我甚至创建了一个全新的项目,认为我的搞砸了;这没有改变一件事。我不知道该怎么办才能解决这个问题。



编辑



做了一些事后另外的研究,我,它开始听起来像是Cocoapods的限制。根据我的理解,你不能在项目中同时使用库和框架。

解决方案

一旦你使用您的Podfile中的 use_frameworks!,像SSKeychain这样的Objective-C Pod也可以构建为框架。



实际问题是使用框架时,只有模块导入在桥接头中工作。此外,您可能希望完全摆脱桥接头,因为在使用框架时它是不必要的,它们可以直接在Swift中导入。


I have a podfile defined with the following pods.

platform :ios, '8.0'
use_frameworks!

target 'LifeStream' do
pod 'SSKeychain'
pod 'LiveSDK'
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'swift-2.0'
end

I installed the pods and opened up my workspace. I have found that any usage of Alamofire works fine, due to the Swift 2 version of it importing the project as a framework.

When I try to use SSKeychain classes however, I receive a

Use of unresolved identifier 'SSKeychain`

Same applies with any class I try to use in the LiveSDK.

I have a bridge header in my projects root directory, and the project is configured to use it.

#ifndef Header_h
#define Header_h

#import "SSKeychain/SSKeychain.h"
#import "LiveSDK/LiveConnectClient.h"

#endif /* Header_h */

if I change the #import from

#import "SSKeychain/SSKeychain.h"

to

#import "SSKeychain.h"

Xcode fails to compile because it can't find the file. So I assume that the bridge header is working, as the way my bridge header is built now does not generate any compiler errors caused by not finding the headers.

Bridge Header

Framework Search Paths

I have also added my project root directory to the framework search path.

Linked Frameworks

Lastly I have linked all of the frameworks to the project as well.

Am I missing something with my setup? I have not been able to get Cocoapods to work on my project for nearly a week now. I even created a brand new project thinking that mine was just messed up; which didn't change a thing. I don't know what to do from here in order to resolve this.

Edit

After doing some additional research, I found a blog post showing that you have to include your Pods directory in the User Header Search

A commenter also mentioned that if you are using the newer Cocoapods Frameworks support for Swift, then it will need to include the Frameworks/** search path. I've included both Pods/** and Frameworks/** but still have the same issue.

After some further reading, it's beginning to sound like this is a limitation of Cocoapods. From what I understand, you can't use libraries and frameworks together at the same time in a project.

解决方案

Once you use use_frameworks! in your Podfile, Objective-C Pods like SSKeychain also get build as frameworks.

The actual problem is that only module imports work in the bridging header when using frameworks. Also, you might want to get rid of the bridging header entirely, as it is unnecessary when using frameworks, they can be imported directly in Swift.

这篇关于Xcode无法看到通过Cocoapods添加的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆