我想将没有 pod 和源代码的 AFNetworking 添加到我的项目中。我首先添加源代码,然后关注库。
然后我添加了前缀文件
#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。
之后,我构建了项目,但出现以下错误:
所有这些都在一个文件和一行中。 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/