Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

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

I'm using the most excellent AFNetworking library in a project that I'm currently upgrading to iOS 6. I'm in the middle of the upgrade, whittling down the bunch of warnings that I get when compiling against the iOS 6 SDK.

AFNetworking gives me two warnings in all targets:

SystemConfiguration framework not found in project, or not included in
precompiled header. Network reachability functionality will not be available.

and

MobileCoreServices framework not found in project, or not included in
precompiled header. Automatic MIME type detection when uploading files
in multipart requests will not be available.

Here's the thing, though: those two libraries are added in all my targets. I'd like to get rid of those warnings the proper way; I won't modify the AFNetworking files. I suspect it's Xcode being silly. It's admittedly a small thing, but leaving warnings around is bad practice.

How can I remove those warnings?

I've tried restarting Xcode and cleaning. Both don't work.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...