ios - 在没有 pod 的情况下导入 AFNetworking

标签 ios objective-c iphone afnetworking

我想将没有 pod 和源代码的 AFNetworking 添加到我的项目中。我首先添加源代码,然后关注库。

imported libraries

然后我添加了前缀文件

#import <Availability.h>

#if __IPHONE_OS_VERSION_MIN_REQUIRED
#ifndef __IPHONE_6_0
#warning "This project uses features only available in iPhone SDK 6.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    #import <SystemConfiguration/SystemConfiguration.h>
    #import <MobileCoreServices/MobileCoreServices.h>
#endif
#else
#ifdef __OBJC__
    #import <Cocoa/Cocoa.h>
    #import <SystemConfiguration/SystemConfiguration.h>
    #import <AssertMacros.h>
    #import <CoreServices/CoreServices.h>
#endif
#endif

并将前缀文件添加到 Build Settings -> Apple LLVM 6.1 - Language -> Prefix Header。

之后我构建了项目,但出现了以下错误:

  • 函数“SecItemExport”的隐式声明在 C99 中无效
  • 使用未声明的标识符 'kSecFormatUnknown' 使用未声明的
  • 标识符“kSecItemPemArmour”

所有这些都在文件和行中。 AFSecurity Policy.m,第 31 行。这是:

__Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out);

当我评论这行不正确的代码时,项目的其余部分已完全构建。

我应该怎么做以及为什么会出现这些错误?

最佳答案

我在github上找到了答案。

如 2.6 的发行说明中所述,如果您手动安装库,则需要在项目的 pch 中定义以下变量:

#ifndef TARGET_OS_IOS
  #define TARGET_OS_IOS TARGET_OS_IPHONE
#endif
#ifndef TARGET_OS_WATCH
  #define TARGET_OS_WATCH 0
#endif

Github Link.

关于ios - 在没有 pod 的情况下导入 AFNetworking,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32196531/

相关文章:

ios - ViewWithTag 导致 UICollectionView 出现问题

ios - 无法使用 GPUImage 在 iOS7 上缩放 UIImage

objective-c - 更新应用程序时如何处理偏好设置?

iphone - 尝试创建 pList 但它没有被创建

ios - 报亭应用程序的 Info.plist 必须包含 UINewsstandApp.error.message=true

ios - ios相机对焦不佳

ios - 如何修复 Swift 中的 "Extra argument in call"错误

objective-c - Obj-C 中的 NSNumber 常量

ios - 如何将结构追加到数组中? swift 4

ios - 奇怪的 EXC_BAD_ACCESS 错误(我认为)