Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Podspec is not adding the SystemConfiguration framework #614

Closed
gabrielrinaldi opened this Issue · 19 comments
@gabrielrinaldi

The Podfile for 1.0RC3 adds the SystemConfiguration framework to the Pods project. The new one does not.

@Keithbsmiley

I am also experiencing this issue.

@gabrielrinaldi

@mattt is that working for you?

@esetnik

Just wanted to comment that I am also having the same issue. My Pods-prefix.pch file looks like:

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

#import <Availability.h>
#if __IPHONE_OS_VERSION_MIN_REQUIRED
  #import <SystemConfiguration/SystemConfiguration.h>
  #import <MobileCoreServices/MobileCoreServices.h>
#else
  #import <SystemConfiguration/SystemConfiguration.h>
  #import <CoreServices/CoreServices.h>
#endif

but I still get the warnings.

Adding the required imports to my project's .pch suppresses the warnings:

//  Project.pch
#import <SystemConfiguration/SystemConfiguration.h>
#import <MobileCoreServices/MobileCoreServices.h>

Is this an issue with CocoaPods or with AFNetworking? There doesn't seem to be anything wrong with the CocoaPods generated .pch file.

@mattt
Owner

Just confirmed this in the most recent version.

From what I can tell, this change in behavior is caused by changing:

s.frameworks = 'MobileCoreServices', 'SystemConfiguration'

to:

s.ios.frameworks = 'MobileCoreServices', 'SystemConfiguration'
s.osx.frameworks = 'CoreServices', 'SystemConfiguration'

Apparently the latter version (current), does not have the same behavior of linking the frameworks to the library build target. /cc @alloy

@gabrielrinaldi

It seems that it is working, Xcode is just showing the warning ignoring the if/else statement. May be we should remove the #warning statement because it will be displayed no matter it is working or not?

@mattt
Owner

The warning actually works as intended. If you're getting that warning, you should not be able to use the features it's warning about. For instance, if I comment out #import <SystemConfiguration/SystemConfiguration.h> in the example Prefix.pch, I get the warning again.

Is this not the case?

@gabrielrinaldi

Interesting, I get the warnings, but I can use the featured. Here is my setup:
1. Pods projects does not have the SystemConfiguration and MobileCoreServices frameworks, this happened in the latest versions of the Podfile. PCH file has the #import for both frameworks.
2. My Project has both frameworks, and I can use the features on it.

May be it is some cache problem, but I tried deleting my Pods folder and doing a clean build and I got the same results.

@Keithbsmiley

Temporary fix described here works the same way for OS X. With the appropriate frameworks.

@lukef

Anyone got any updates on this one? I've been stuck for a while on this. I've tried adding the frameworks directly to both projects and tried adding the imports to both projects also. Crazy.

@Keithbsmiley

Make sure you add the correct import statements

for OS X:

#import <SystemConfiguration/SystemConfiguration.h>
#import <CoreServices/CoreServices.h>

or for iOS:

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

to your projects .pch file. (If you're using CocoaPods not the Pods Project's pch file but your main project's pch)

@pablasso

@lukef i.e for iOS in my project.pch:

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>

    // importing them myself because cocoapods didn't do it for the AFNetworking spec.
    #import <SystemConfiguration/SystemConfiguration.h>
    #import <MobileCoreServices/MobileCoreServices.h>
#endif
@mattt
Owner

It appears that the CocoaPods original bug reported in this issue has been resolved, despite the fact that the framework dependency experience in general leaves a lot to be desired. Closing this issue now.

@mattt mattt closed this
@christophercotton

Do you have the version of cocoapods that fixes this @mattt ? I just installed cocoapods (0.16.2) and AFNetworking (1.1.0) and got this exact error. Or do you have a link to the cocoapod issue? Or maybe I'm just doing it wrong?

@alloy

@christophercotton He was talking about the OP’s issue. You probably need to follow @Keithbsmiley’s advice a few comments up: #614 (comment).

@christophercotton

@alloy Thanks! I will reread it.

@fabiopelosin

Regarding the warning I think that it should be disabled with CocoaPods.

With CocoaPods AFNetworking is compiled (in the Pods library) with SystemConfiguration as specified by the Podspec. The fact that the users imports or not SystemConfiguration and CoreServices before importing AFHTTPClient.h should not affect in any way the functionality provided by AFNetworking (because the user project already links agains to those frameworks as instructed by the Pods.xcconfig). Thus requiring to modify the prefix header of the client target appears like a suboptimal solution to me.

Unfortunately I can't think of a clean solution, the alternative that I've come up are:

  • Remove the conditionals in AFHTTPClient.h.
  • Use a post-install hook to inject the contents which now are in the prefix header in the top of AFHTTPClient.h
  • Move the warning to AFHTTPClient.m

The last one could work, according to the ideas that the warning should be presented in the build of the target compiling AFNetworking.

@blakewatters

@irrationalfab Its not quite true to say that because AFN was built with System Configuration / Core Services it will not affect the functionality. AFN uses conditional compilation around the System Configure / Core Services header definitions to control exposure of the optional functionality (see https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking/AFHTTPClient.h#L136-L138).

If the user does not modify the PCH file, what happens is that you get AFN compiled with SystemConfiguration support by CocoaPods, but you cannot use the networkReachabilityStatus property because it is masked by the header import. So you have reachability support, but attempts to use it result in build failures.

You really have to modify the PCH file and import the dependencies during the Pod build to get a fully working system. I really do not see a better solution than allowing for injection of dependencies into the target PCH to cover this. The only other thing I can think of is using pre-compiler flags to define the necessary options and fake out the conditional compilation (i.e. define _SYSTEMCONFIGURATION_H).

@ToQoz ToQoz referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@krzyzanowskim

Can I reopen this one?

$ pod --version
0.28.0

Pods-MyApp-AFNetworking-prefix.pch file looks like this:

#if __IPHONE_OS_VERSION_MIN_REQUIRED
  #import <SystemConfiguration/SystemConfiguration.h>
  #import <MobileCoreServices/MobileCoreServices.h>
  #import <Security/Security.h>
#else
  #import <SystemConfiguration/SystemConfiguration.h>
  #import <CoreServices/CoreServices.h>
  #import <Security/Security.h>
#endif

in podspec there is

 s.frameworks = 'Foundation', 'CoreFoundation', 'CoreLocation', 'SystemConfiguration', 'MobileCoreServices', 'UIKit'

And I'm getting warning that SystemConfiguration or MobileCoreServices is not found or not included.

Using AFNetworking (1.3.3). Can you please tell me step by step how to setup this stuff ?

@fabiopelosin

@krzak System configuration is added. The warning is caused by importing the header in your target, which doesn't uses that prefix header. The issue has been solved with AFNetworking 2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.