xcode Cocoapods 框架在另一个 cocoapods 框架中找不到文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30262891/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cocoapods framework cannot find file in another cocoapods framework
提问by hgwhittle
I'm working with a library installed via Cocoapods that depends on AFNetworking as a linked framework. After I installed the library, my project will not compile because imported AFNetworking files can not be found.
我正在使用通过 Cocoapods 安装的库,该库依赖于 AFNetworking 作为链接框架。安装库后,我的项目将无法编译,因为找不到导入的 AFNetworking 文件。
However, it seems that modules are causing the problem because if I change the import from:
但是,似乎是模块导致了问题,因为如果我从以下位置更改导入:
#import "AFHTTPRequestOperationManager.h"
#import "AFHTTPRequestOperationManager.h"
to
到
#import <AFNetworking/AFHTTPRequestOperationManager.h>
#import <AFNetworking/AFHTTPRequestOperationManager.h>
..the error disappears. I'd rather not go about changing code in these linked libraries, so how can I get my library to successfully find the AFNetworking files?
..错误消失了。我不想更改这些链接库中的代码,那么如何让我的库成功找到 AFNetworking 文件?
EDITHere's my podfile:
编辑这是我的 podfile:
# Uncomment this line to define a global platform for your project
# platform :ios, '6.0'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, '8.0'
target 'Motospot' do
pod 'Alamofire', '~> 1.2'
pod 'youtube-ios-player-helper', '~> 0.1.1'
pod 'BDBOAuth1Manager'
end
target 'MotospotTests' do
end
回答by Binoy jose
Please check the profile - AFNetworking version
请检查配置文件 - AFNetworking 版本
Change to
改成
pod 'AFNetworking', '~> 2.5.4'
and use
并使用
#import "AFHTTPRequestOperationManager.h"
回答by Javier Calatrava Llavería
Finally I succeed in configuring AFNetworking with swift. This is the Podfile:
最后,我成功地快速配置了 AFNetworking。这是 Podfile:
Podfile:
播客文件:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'AFNetworking', '~> 2.5'
Bridge_AFNetworking.h
Bridge_AFNetworking.h
#ifndef eShop_Bridge_AFNetworking_h
#define eShop_Bridge_AFNetworking_h
#import <AFNetworking/AFNetworking.h>
#endif
This is some sample code using AFNetworking.
这是一些使用 AFNetworking 的示例代码。
import UIKit
import AFNetworking
class DataManager: NSObject {
static let sharedInstance = DataManager()
let manager:AFHTTPRequestOperationManager = AFHTTPRequestOperationManager()
override init() {
super.init()
}
}
回答by bentzy
For me what worked was:
对我来说有效的是:
- Close Xcode
- Remove the Pods directory from the project ROOT
- In terminal cd to project ROOT and then "pod install --verbose"
- Open xcode from xcworkspace file
- Build
- 关闭 Xcode
- 从项目ROOT中删除Pods目录
- 在终端 cd 中投影 ROOT,然后“pod install --verbose”
- 从 xcworkspace 文件打开 xcode
- 建造
回答by Ethan Marcus
Copy the framework and delete it. If the problem persists, go to framework and library's and drag the file there. That should make the file visible by all other files then go back and try importing
复制框架并删除它。如果问题仍然存在,请转到框架和库并将文件拖到那里。这应该使所有其他文件都可以看到该文件,然后返回并尝试导入