Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Allow same library for app and extensions. #2737

Merged
merged 2 commits into from Aug 3, 2015

Conversation

bnickel
Copy link
Contributor

@bnickel bnickel commented May 19, 2015

clang will silence availability errors in classes and methods that are also unavailable to the target. The following have been made unavailable to app extensions:

  • AFNetworkActivityIndicatorManager class
  • UIAlertView category methods
  • AFURLConnectionOperation setShouldExecuteAsBackgroundTaskWithExpirationHandler:

Benefits of change:

  • Fixes CocoaPods support for App Extensions.
  • Allows single framework to be used in app.
  • Eliminates the need for AF_APP_EXTENSIONS.

@bnickel
Copy link
Contributor Author

bnickel commented May 19, 2015

For reference, this is meant to resolve the continuing CocoaPods 0.36+ issues mentioned in #2321.

@kcharwood kcharwood added this to the 2.5.5 milestone May 26, 2015
@kcharwood
Copy link
Contributor

Is it time we had an extension to the example project?

@mattt
Copy link
Contributor

mattt commented May 29, 2015

We should go all out. App extension, watch app... The works.

@jervine10
Copy link

Will this add support for native watchOS 2 apps as well?

@bnickel
Copy link
Contributor Author

bnickel commented Jun 11, 2015

WatchOS is a different story. I think it doesn't have UIKit so the iOS library from the project and the iOS cocoa pod would fail unless you just exclude the UIKit subspec. (Assuming cocoapods works in general.) These are just guesses though.

@kcharwood kcharwood modified the milestones: 2.5.5, 2.6.0 Jun 26, 2015
@kcharwood
Copy link
Contributor

Thanks for this @bnickel

Would you want to add a Today Extension to the example project so this behavior can be verified going forward?

@bnickel
Copy link
Contributor Author

bnickel commented Jul 24, 2015

Sure

clang will silence availability errors in classes and methods that are also unavailable to the target.  The following have been made unavailable to app extensions:
- `AFNetworkActivityIndicatorManager` class
- `UIAlertView` category methods
- `AFURLConnectionOperation setShouldExecuteAsBackgroundTaskWithExpirationHandler:`

Benefits of change:
- Fixes CocoaPods support for App Extensions.
- Allows single framework to be used in app.
- Eliminates the need for `AF_APP_EXTENSIONS`.
This demonstrates that APIs not available to an extension can compile successfully if they are marked with NS_EXTENSION_UNAVAILABLE_IOS.
@bnickel
Copy link
Contributor Author

bnickel commented Jul 27, 2015

I've added a Today extension which validates that the code compiles with the annotated methods and classes. I can't get the Travis failure to reproduce locally.

@@ -23,7 +23,7 @@

#import <Availability.h>

#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS)
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you see any reason to not mark this whole class as NS_EXTENSION_UNAVAILABLE_IOS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember. I think I was just following the pattern of UIAlertView.h. If it compiles the other way, I'm sure it's fine.

kcharwood added a commit that referenced this pull request Aug 3, 2015
Allow same library for app and extensions.
@kcharwood kcharwood merged commit c9bbbeb into AFNetworking:master Aug 3, 2015
@kcharwood
Copy link
Contributor

This is actually looks good. Just verified all the tests pass on my local machine.

Thanks for putting this together!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants