aakpro
aakpro

Reputation: 1578

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:

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?

Upvotes: 3

Views: 1950

Answers (2)

Varun Naharia
Varun Naharia

Reputation: 5428

My solution is to add "TARGET_OS_IOS=1" at Preprocessor Macros -- Build Settings

Upvotes: 7

aakpro
aakpro

Reputation: 1578

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.

Upvotes: 7

Related Questions