Search code examples
iosobjective-ciphoneafnetworking

Importing AFNetworking without pod


I want to add AFNetworking without pod and source code to my project. I started by adding source code and then following libraries.

imported libraries

Then I added prefix file

#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

And add prefix file to Build Settings -> Apple LLVM 6.1 - Language -> Prefix Header.

After that I built project and I got following errors:

  • Implicit declaration of function 'SecItemExport' is invalid in C99
  • Use of undeclared identifier 'kSecFormatUnknown' Use of undeclared
  • identifier 'kSecItemPemArmour'

Which all are in a file and line. AFSecurity Policy.m, line 31. Which is:

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

When I comment this line of code, which is not correct, the rest of project is built completely.

What should I do and why those errors happened?


Solution

  • I found the answer on github.

    As mentioned in the release notes for 2.6, if you are installing the library manually you will need to define the following variables in your project's 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.