dengApro
dengApro

Reputation: 4008

How to fix the Xcode path error

In the AFNetworking's sample code, I use several folders to classify the source codes. And the Xcode reports:

/Users/.../Framework/AFNetworking.h:19:9: 'AFNetworking/AFURLRequestSerialization.h' file not found

/Users/.../AFNetworking-master/Example/Classes/Networking Extensions/AFAppDotNetAPIClient.h:4:9: While building module 'AFNetworking' imported from /Users/dengjiangzhou/Documents/源码/2_AFNetworking/AFNetworking-master/Example/Classes/Networking Extensions/AFAppDotNetAPIClient.h:4:

/Users/.../AFNetworking-master/Example/:1:9: In file included from :1:

enter image description here

And

enter image description here

Here is the code: In the AFNetworking.h file

#import <Foundation/Foundation.h>

//! Project version number for AFNetworking.
FOUNDATION_EXPORT double AFNetworkingVersionNumber;

//! Project version string for AFNetworking.
FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <AFNetworking/PublicHeader.h>

#import <Availability.h>
#import <TargetConditionals.h>

#ifndef _AFNETWORKING_
#define _AFNETWORKING_

#import <AFNetworking/AFURLRequestSerialization.h>
#import <AFNetworking/AFURLResponseSerialization.h>
#import <AFNetworking/AFSecurityPolicy.h>

#if !TARGET_OS_WATCH
#import <AFNetworking/AFNetworkReachabilityManager.h>
#endif

#import <AFNetworking/AFURLSessionManager.h>
#import <AFNetworking/AFHTTPSessionManager.h>

Error occurs in the last line. And I didn't change any code. I just organized the files to check the functions of each module easily.

Maybe insert a file name in the search path of Xcode build settings, is quite OK. I have not figured it out.

Many Thanks in advance.

Upvotes: 1

Views: 2133

Answers (2)

trungduc
trungduc

Reputation: 12144

  • You should remove AFNetworking/ from import line and use

    #import ""

    instead of

    #import <>

  • Go to Build Phases -> Open Headers section -> Move files from Project to Public.

    enter image description here

Upvotes: 1

kelin
kelin

Reputation: 11974

Try this:

  1. Select AFURLRequestSerialization.m
  2. Go to the right tab in the Xcode. Find Target Membership. Uncheck and check again all the boxes.
  3. Product > Clean
  4. Hold Alt and perform: Product > Clean Build Folder...
  5. Build again.

Upvotes: 1

Related Questions