Bladeren bron

[Issue #2346] Revert commits related to __has_feature(attribute_availability_app_extension)

Mattt Thompson 11 jaren geleden
bovenliggende
commit
290fe60fde

+ 5 - 1
AFNetworking/AFURLConnectionOperation.h

@@ -65,6 +65,10 @@
  SSL with certificate pinning is strongly recommended for any application that transmits sensitive information to an external webservice.
 
  Connections will be validated on all matching certificates with a `.cer` extension in the bundle root.
+ 
+ ## App Extensions
+ 
+ When using AFNetworking in an App Extension, `#define AF_APP_EXTENSIONS` to avoid using unavailable APIs.
 
  ## NSCoding & NSCopying Conformance
 
@@ -248,7 +252,7 @@
 
  @param handler A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified.
   */
-#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !(defined(__has_feature) && __has_feature(attribute_availability_app_extension))
+#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS)
 - (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler;
 #endif
 

+ 4 - 4
AFNetworking/AFURLConnectionOperation.m

@@ -26,7 +26,7 @@
 #import <UIKit/UIKit.h>
 #endif
 
-#if defined(__has_feature) && !__has_feature(objc_arc)
+#if !__has_feature(objc_arc)
 #error AFNetworking must be built with ARC.
 // You can turn on ARC for only AFNetworking files by adding -fobjc-arc to the build phase for each of its files.
 #endif
@@ -38,7 +38,7 @@ typedef NS_ENUM(NSInteger, AFOperationState) {
     AFOperationFinishedState    = 3,
 };
 
-#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !(defined(__has_feature) && __has_feature(attribute_availability_app_extension))
+#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS)
 typedef UIBackgroundTaskIdentifier AFBackgroundTaskIdentifier;
 #else
 typedef id AFBackgroundTaskIdentifier;
@@ -211,7 +211,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
         _outputStream = nil;
     }
     
-#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !(defined(__has_feature) && __has_feature(attribute_availability_app_extension))
+#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS)
     if (_backgroundTaskIdentifier) {
         [[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier];
         _backgroundTaskIdentifier = UIBackgroundTaskInvalid;
@@ -289,7 +289,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
     [self.lock unlock];
 }
 
-#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !(defined(__has_feature) && __has_feature(attribute_availability_app_extension))
+#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS)
 - (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler {
     [self.lock lock];
     if (!self.backgroundTaskIdentifier) {

+ 0 - 2
Tests/Tests/AFNetworkActivityManagerTests.m

@@ -25,7 +25,6 @@
 #import "AFNetworkActivityIndicatorManager.h"
 #import "AFHTTPRequestOperation.h"
 
-#if !(defined(__has_feature) && __has_feature(attribute_availability_app_extension))
 @interface AFNetworkActivityManagerTests : AFTestCase
 @property (nonatomic, strong) AFNetworkActivityIndicatorManager *networkActivityIndicatorManager;
 @property (nonatomic, assign) BOOL isNetworkActivityIndicatorVisible;
@@ -99,4 +98,3 @@
 }
 
 @end
-#endif

+ 0 - 2
UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m

@@ -114,9 +114,7 @@ static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notificat
 }
 
 - (void)updateNetworkActivityIndicatorVisibility {
-#if !(defined(__has_feature) && __has_feature(attribute_availability_app_extension))
     [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]];
-#endif
 }
 
 - (void)setActivityCount:(NSInteger)activityCount {