【问题标题】:Importing AFNetworking without pod在没有 pod 的情况下导入 AFNetworking
【发布时间】:2015-08-25 05:58:15
【问题描述】:

我想将不带 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。

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

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

它们都在一个文件和行中。 AFSecurity Policy.m,第 31 行。即:

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

当我注释这行不正确的代码时,项目的其余部分就构建完成了。

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

【问题讨论】:

标签: ios objective-c iphone afnetworking


【解决方案1】:

我在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.

【讨论】:

    【解决方案2】:

    我的解决方案是在 Preprocessor Macros -- Build Settings 中添加“TARGET_OS_IOS=1”

    【讨论】:

      猜你喜欢
      • 2016-06-23
      • 1970-01-01
      • 2018-11-10
      • 1970-01-01
      • 2012-07-09
      • 2017-06-03
      • 1970-01-01
      • 1970-01-01
      • 2019-10-12
      相关资源
      最近更新 更多