I'm getting compiler warnings with AFNetworking, but shouldn't be. How do I fix it? I'm getting compiler warnings with AFNetworking, but shouldn't be. How do I fix it? xcode xcode

I'm getting compiler warnings with AFNetworking, but shouldn't be. How do I fix it?


I'm not sure if you're using CocoaPods or not but this is a known issue being tracked on the AFNetworking Github page.

I was able to fix this by adding the correct import statements directly to my `PROJECTNAME-Prefix.pch there I changed it to this.

#ifdef __OBJC__  #import <UIKit/UIKit.h>  #import <SystemConfiguration/SystemConfiguration.h>  #import <MobileCoreServices/MobileCoreServices.h>#endif

If you have something else in there don't delete it. Just add the imports for SystemConfiguration and MobileCoreServices.

For OS X:

#ifdef __OBJC__    #import <Cocoa/Cocoa.h>    #import <SystemConfiguration/SystemConfiguration.h>    #import <CoreServices/CoreServices.h>#endif


If you're using swift: Xcode compiles Swift code before the Prefix.pch file is compiled, so you'll get these warnings even if the correct imports are in your .pch file. The best solution I've found is to add them to the project's Bridging-Header.h file before importing AFNetworking:

#import <SystemConfiguration/SystemConfiguration.h>#import <MobileCoreServices/MobileCoreServices.h>#import "AFNetworking.h"


This has already been answered, but still, if you're developing a command line tool potentially to be compiled for both OS X and iOS (not App Store for sure), you can add this:

#ifdef __OBJC__    #import <Foundation/Foundation.h>    #import <SystemConfiguration/SystemConfiguration.h>    #if TARGET_OS_IPHONE        #import <MobileCoreServices/MobileCoreServices.h>    #elif TARGET_OS_MAC        #import <CoreServices/CoreServices.h>    #endif#endif

By evaluating the target you're compiling to, it will include the proper files.