Skip to content

Commit

Permalink
Raise deployment target to iOS 9 (#743)
Browse files Browse the repository at this point in the history
#743

Manually merged since I forgot to retarget that diff onto master before merge
  • Loading branch information
Adlai Holler committed Jan 15, 2018
1 parent 1d105c2 commit 61dade6
Show file tree
Hide file tree
Showing 98 changed files with 361 additions and 415 deletions.
6 changes: 3 additions & 3 deletions AsyncDisplayKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2509,7 +2509,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -2553,7 +2553,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
Expand Down Expand Up @@ -2702,7 +2702,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [Automatic Subnode Management] Nodes with ASM enabled now insert/delete their subnodes as soon as they enter preload state, so the subnodes can preload too. [Huy Nguyen](https://github.com/nguyenhuy) [#706](https://github.com/TextureGroup/Texture/pull/706)
- [ASCollectionNode] Added support for interactive item movement. [Adlai Holler](https://github.com/Adlai-Holler)
- Added an experimental "no-copy" rendering API. See ASGraphicsContext.h for info. [Adlai Holler](https://github.com/Adlai-Holler)
- Dropped support for iOS 8. [Adlai Holler](https://github.com/Adlai-Holler)

## 2.6
- [Xcode 9] Updated to require Xcode 9 (to fix warnings) [Garrett Moon](https://github.com/garrettmoon)
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'
platform :ios, '9.0'

target :'AsyncDisplayKitTests' do
pod 'OCMock', '~> 3.4'
Expand Down
2 changes: 1 addition & 1 deletion Source/ASCellNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ - (void)didLoad
if ([_viewController isKindOfClass:[ASViewController class]]) {
ASViewController *asViewController = (ASViewController *)_viewController;
_viewControllerNode = asViewController.node;
[_viewController view];
[_viewController loadViewIfNeeded];
} else {
// Careful to avoid retain cycle
UIViewController *viewController = _viewController;
Expand Down
35 changes: 0 additions & 35 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,6 @@ @interface ASCollectionView () <ASRangeControllerDataSource, ASRangeControllerDe

ASCollectionViewInvalidationStyle _nextLayoutInvalidationStyle;

/**
* Our layer, retained. Under iOS < 9, when collection views are removed from the hierarchy,
* their layers may be deallocated and become dangling pointers. This puts the collection view
* into a very dangerous state where pretty much any call will crash it. So we manually retain our layer.
*
* You should never access this, and it will be nil under iOS >= 9.
*/
CALayer *_retainedLayer;

/**
* If YES, the `UICollectionView` will reload its data on next layout pass so we should not forward any updates to it.
Expand Down Expand Up @@ -316,10 +307,6 @@ - (instancetype)_initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionV

[self registerClass:[_ASCollectionViewCell class] forCellWithReuseIdentifier:kReuseIdentifier];

if (!AS_AT_LEAST_IOS9) {
_retainedLayer = self.layer;
}

[self _configureCollectionViewLayout:layout];

return self;
Expand Down Expand Up @@ -2039,28 +2026,6 @@ - (ASRangeController *)rangeController
return _rangeController;
}

/// The UIKit version of this method is only available on iOS >= 9
- (NSArray<NSIndexPath *> *)asdk_indexPathsForVisibleSupplementaryElementsOfKind:(NSString *)kind
{
if (AS_AVAILABLE_IOS(9)) {
return [self indexPathsForVisibleSupplementaryElementsOfKind:kind];
}

// iOS 8 workaround
// We cannot use willDisplaySupplementaryView/didEndDisplayingSupplementaryView
// because those methods send index paths for _deleted items_ (invalid index paths)
[self layoutIfNeeded];
NSArray<UICollectionViewLayoutAttributes *> *visibleAttributes = [self.collectionViewLayout layoutAttributesForElementsInRect:self.bounds];
NSMutableArray *result = [NSMutableArray array];
for (UICollectionViewLayoutAttributes *attributes in visibleAttributes) {
if (attributes.representedElementCategory == UICollectionElementCategorySupplementaryView
&& [attributes.representedElementKind isEqualToString:kind]) {
[result addObject:attributes.indexPath];
}
}
return result;
}

- (NSHashTable<ASCollectionElement *> *)visibleElementsForRangeController:(ASRangeController *)rangeController
{
return ASPointerTableByFlatMapping(_visibleElements, id element, element);
Expand Down
10 changes: 4 additions & 6 deletions Source/ASDisplayNode+Yoga.mm
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,10 @@ - (void)insertYogaChild:(ASDisplayNode *)child atIndex:(NSUInteger)index

- (void)semanticContentAttributeDidChange:(UISemanticContentAttribute)attribute
{
if (AS_AT_LEAST_IOS9) {
UIUserInterfaceLayoutDirection layoutDirection =
[UIView userInterfaceLayoutDirectionForSemanticContentAttribute:attribute];
self.style.direction = (layoutDirection == UIUserInterfaceLayoutDirectionLeftToRight
? YGDirectionLTR : YGDirectionRTL);
}
UIUserInterfaceLayoutDirection layoutDirection =
[UIView userInterfaceLayoutDirectionForSemanticContentAttribute:attribute];
self.style.direction = (layoutDirection == UIUserInterfaceLayoutDirectionLeftToRight
? YGDirectionLTR : YGDirectionRTL);
}

- (void)setYogaParent:(ASDisplayNode *)yogaParent
Expand Down
9 changes: 7 additions & 2 deletions Source/ASMultiplexImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ - (void)_loadNextImage
finishedLoadingBlock(downloadedImage, nextImageIdentifier, error);
}];
}
// Likewise, if it's a iOS 8 Photo asset, we need to fetch it accordingly.
// Likewise, if it's a Photos asset, we need to fetch it accordingly.
else if (ASPhotosFrameworkImageRequest *request = [ASPhotosFrameworkImageRequest requestWithURL:nextImageURL]) {
[self _loadPHAssetWithRequest:request identifier:nextImageIdentifier completion:^(UIImage *image, NSError *error) {
as_log_verbose(ASImageLoadingLog(), "Acquired image from Photos for %@ %@", weakSelf, nextImageIdentifier);
Expand Down Expand Up @@ -673,7 +673,11 @@ - (void)_loadALAssetWithIdentifier:(id)imageIdentifier URL:(NSURL *)assetURL com
ASDisplayNodeAssertNotNil(imageIdentifier, @"imageIdentifier is required");
ASDisplayNodeAssertNotNil(assetURL, @"assetURL is required");
ASDisplayNodeAssertNotNil(completionBlock, @"completionBlock is required");


// ALAssetsLibrary was replaced in iOS 8 and deprecated in iOS 9.
// We'll drop support very soon.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];

[assetLibrary assetForURL:assetURL resultBlock:^(ALAsset *asset) {
Expand All @@ -685,6 +689,7 @@ - (void)_loadALAssetWithIdentifier:(id)imageIdentifier URL:(NSURL *)assetURL com
} failureBlock:^(NSError *error) {
completionBlock(nil, error);
}];
#pragma clang diagnostic pop
}

- (void)_loadPHAssetWithRequest:(ASPhotosFrameworkImageRequest *)request identifier:(id)imageIdentifier completion:(void (^)(UIImage *image, NSError *error))completionBlock
Expand Down
5 changes: 0 additions & 5 deletions Source/ASRunLoopQueue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ + (ASDeallocQueue *)sharedDeallocationQueue

- (void)releaseObjectInBackground:(id _Nullable __strong *)objectPtr
{
// Disable background deallocation on iOS 8 and below to avoid crashes related to UIAXDelegateClearer (#2767).
if (!AS_AT_LEAST_IOS9) {
return;
}

if (objectPtr != NULL && *objectPtr != nil) {
ASDN::MutexLocker l(_queueLock);
_queue.push_back(*objectPtr);
Expand Down
13 changes: 0 additions & 13 deletions Source/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,6 @@ @interface ASTableView () <ASRangeControllerDataSource, ASRangeControllerDelegat
BOOL _automaticallyAdjustsContentOffset;

CGPoint _deceleratingVelocity;

/**
* Our layer, retained. Under iOS < 9, when table views are removed from the hierarchy,
* their layers may be deallocated and become dangling pointers. This puts the table view
* into a very dangerous state where pretty much any call will crash it. So we manually retain our layer.
*
* You should never access this, and it will be nil under iOS >= 9.
*/
CALayer *_retainedLayer;

CGFloat _nodesConstrainedWidth;
BOOL _queuedNodeHeightUpdate;
Expand Down Expand Up @@ -350,10 +341,6 @@ - (instancetype)_initWithFrame:(CGRect)frame style:(UITableViewStyle)style dataC

[self registerClass:_ASTableViewCell.class forCellReuseIdentifier:kCellReuseIdentifier];

if (!AS_AT_LEAST_IOS9) {
_retainedLayer = self.layer;
}

// iOS 11 automatically uses estimated heights, so disable those (see PR #485)
if (AS_AT_LEAST_IOS11) {
super.estimatedRowHeight = 0.0;
Expand Down
2 changes: 2 additions & 0 deletions Source/ASTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ - (void)dealloc
{
CGColorRelease(_shadowColor);

// TODO: This may not be necessary post-iOS-9 when most UIKit assign APIs
// were changed to weak.
if (_longPressGestureRecognizer) {
_longPressGestureRecognizer.delegate = nil;
[_longPressGestureRecognizer removeTarget:nil action:NULL];
Expand Down
5 changes: 0 additions & 5 deletions Source/Base/ASAvailability.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@

#pragma once

#ifndef kCFCoreFoundationVersionNumber_iOS_9_0
#define kCFCoreFoundationVersionNumber_iOS_9_0 1240.10
#endif

#ifndef kCFCoreFoundationVersionNumber_iOS_10_0
#define kCFCoreFoundationVersionNumber_iOS_10_0 1348.00
#endif
Expand All @@ -35,7 +31,6 @@
#define __IPHONE_11_0 110000
#endif

#define AS_AT_LEAST_IOS9 (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_9_0)
#define AS_AT_LEAST_IOS10 (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_10_0)
#define AS_AT_LEAST_IOS11 (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_11_0)

Expand Down
39 changes: 12 additions & 27 deletions Source/Details/ASTraitCollection.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,17 @@ BOOL ASPrimitiveTraitCollectionIsEqualToASPrimitiveTraitCollection(ASPrimitiveTr

// Named so as not to conflict with a hidden Apple function, in case compiler decides not to inline
ASDISPLAYNODE_INLINE NSString *AS_NSStringFromUIUserInterfaceIdiom(UIUserInterfaceIdiom idiom) {
if (AS_AVAILABLE_IOS(9)) {
switch (idiom) {
case UIUserInterfaceIdiomTV:
return @"TV";
case UIUserInterfaceIdiomPad:
return @"Pad";
case UIUserInterfaceIdiomPhone:
return @"Phone";
case UIUserInterfaceIdiomCarPlay:
return @"CarPlay";
default:
return @"Unspecified";
}
} else {
switch (idiom) {
case UIUserInterfaceIdiomPad:
return @"Pad";
case UIUserInterfaceIdiomPhone:
return @"Phone";
default:
return @"Unspecified";
}
switch (idiom) {
case UIUserInterfaceIdiomTV:
return @"TV";
case UIUserInterfaceIdiomPad:
return @"Pad";
case UIUserInterfaceIdiomPhone:
return @"Phone";
case UIUserInterfaceIdiomCarPlay:
return @"CarPlay";
default:
return @"Unspecified";
}
}

Expand Down Expand Up @@ -178,15 +167,11 @@ + (instancetype)traitCollectionWithASPrimitiveTraitCollection:(ASPrimitiveTraitC
+ (instancetype)traitCollectionWithUITraitCollection:(UITraitCollection *)traitCollection
containerSize:(CGSize)windowSize
{
UIForceTouchCapability forceTouch = UIForceTouchCapabilityUnknown;
if(AS_AVAILABLE_IOS(9)) {
forceTouch = traitCollection.forceTouchCapability;
}
return [self traitCollectionWithDisplayScale:traitCollection.displayScale
userInterfaceIdiom:traitCollection.userInterfaceIdiom
horizontalSizeClass:traitCollection.horizontalSizeClass
verticalSizeClass:traitCollection.verticalSizeClass
forceTouchCapability:forceTouch
forceTouchCapability:traitCollection.forceTouchCapability
containerSize:windowSize];
}

Expand Down
11 changes: 3 additions & 8 deletions Source/Private/ASDisplayNode+UIViewBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -854,21 +854,16 @@ - (void)setEdgeAntialiasingMask:(unsigned int)edgeAntialiasingMask
- (UISemanticContentAttribute)semanticContentAttribute
{
_bridge_prologue_read;
if (AS_AT_LEAST_IOS9) {
return _getFromViewOnly(semanticContentAttribute);
}
return UISemanticContentAttributeUnspecified;
return _getFromViewOnly(semanticContentAttribute);
}

- (void)setSemanticContentAttribute:(UISemanticContentAttribute)semanticContentAttribute
{
_bridge_prologue_write;
if (AS_AT_LEAST_IOS9) {
_setToViewOnly(semanticContentAttribute, semanticContentAttribute);
_setToViewOnly(semanticContentAttribute, semanticContentAttribute);
#if YOGA
[self semanticContentAttributeDidChange:semanticContentAttribute];
[self semanticContentAttributeDidChange:semanticContentAttribute];
#endif
}
}

@end
Expand Down
18 changes: 1 addition & 17 deletions Source/Private/TextExperiment/Component/ASTextLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -405,25 +405,9 @@ + (ASTextLayout *)layoutWithContainer:(ASTextContainer *)container text:(NSAttri
container->_readonly = YES;
maximumNumberOfRows = container.maximumNumberOfRows;

// CoreText bug when draw joined emoji since iOS 8.3.
// See -[NSMutableAttributedString setClearColorToJoinedEmoji] for more information.
static BOOL needFixJoinedEmojiBug = NO;
// It may use larger constraint size when create CTFrame with
// CTFramesetterCreateFrame in iOS 10.
static BOOL needFixLayoutSizeBug = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
double systemVersionDouble = [UIDevice currentDevice].systemVersion.doubleValue;
if (8.3 <= systemVersionDouble && systemVersionDouble < 9) {
needFixJoinedEmojiBug = YES;
}
if (systemVersionDouble >= 10) {
needFixLayoutSizeBug = YES;
}
});
if (needFixJoinedEmojiBug) {
[((NSMutableAttributedString *)text) as_setClearColorToJoinedEmoji];
}
BOOL needFixLayoutSizeBug = AS_AT_LEAST_IOS10;

layout = [[ASTextLayout alloc] _init];
layout.text = text;
Expand Down
3 changes: 3 additions & 0 deletions Source/Private/TextExperiment/String/ASTextAttribute.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ ASTextAttributeType ASTextAttributeGetType(NSString *name){
dic[(id)kCTSuperscriptAttributeName] = UIKit; //it's a CoreText attrubite, but only supported by UIKit...
dic[NSVerticalGlyphFormAttributeName] = All;
dic[(id)kCTGlyphInfoAttributeName] = CoreText_ASText;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
dic[(id)kCTCharacterShapeAttributeName] = CoreText_ASText;
#pragma clang diagnostic pop
dic[(id)kCTRunDelegateAttributeName] = CoreText_ASText;
dic[(id)kCTBaselineClassAttributeName] = CoreText_ASText;
dic[(id)kCTBaselineInfoAttributeName] = CoreText_ASText;
Expand Down
15 changes: 0 additions & 15 deletions Source/Private/TextExperiment/Utility/NSAttributedString+ASText.h
Original file line number Diff line number Diff line change
Expand Up @@ -1357,21 +1357,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)as_appendString:(NSString *)string;

/**
Set foreground color with [UIColor clearColor] in joined-emoji range.
Emoji drawing will not be affected by the foreground color.

@discussion In iOS 8.3, Apple releases some new diversified emojis.
There's some single emoji which can be assembled to a new 'joined-emoji'.
The joiner is unicode character 'ZERO WIDTH JOINER' (U+200D).
For example: πŸ‘¨πŸ‘©πŸ‘§πŸ‘§ -> πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘§.

When there are more than 5 'joined-emoji' in a same CTLine, CoreText may render some
extra glyphs above the emoji. It's a bug in CoreText, try this method to avoid.
This bug is fixed in iOS 9.
*/
- (void)as_setClearColorToJoinedEmoji;

/**
Removes all discontinuous attributes in a specified range.
See `allDiscontinuousAttributeKeys`.
Expand Down
Loading

0 comments on commit 61dade6

Please sign in to comment.