2

In a project that I have added AFNetworking to I keep getting the build errors as in the image below.

I have tried the usual deleting the build/ folder and restarting xcode, removing and re-adding the framework, cleaning and building. I also tried adding the following code to my Project-Prefix.pch file:

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
//START - ADDING IMPORT FOR ALL TARGETS DUE TO AFNETWORKING
#import <Cocoa/Cocoa.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <MobileCoreServices/MobileCoreServices.h>
//END
#endif

But that doesn't seem to fix the issue either. I then tried removing AFNetworking from the project but it still gets this Lexical error when I try to build.

lexical or preprocessor issue errors

I've seen these compile errors before in XCode 4 and it was usually fixed by quitting xcode and deleting the build/ folder and then re-building the project. But this time it does not work.

I do not understand what the error refers to or how to fix it. It may not be caused by AFNetworking.

Can somebody help me figure this out?

motionpotion
  • 2,656
  • 6
  • 42
  • 60

2 Answers2

1

Linker failed messages typically mean that you are missing some frameworks that your code references but that you have not added to the frameworks list.

You can add these frameworks in Xcode 5 by going to the File Navigator > Project > Build Phases > Link Binary with Libraries (then type in the missing library).

rene
  • 41,474
  • 78
  • 114
  • 152
Tommie C.
  • 12,895
  • 5
  • 82
  • 100
0

To fix this I had to edit the .pch file and add the following lines:

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

There's no referenced to this in the error message that was displayed so it was confusing and took ages to figure out. Hope it helps point somebody else with similar issue in the correct direction to solve their issue.

motionpotion
  • 2,656
  • 6
  • 42
  • 60