Skip to content

Commit

Permalink
[tvOS] Fixes errors when building against tvOS SDK (#728)
Browse files Browse the repository at this point in the history
* [tvOS] Fixes errors when building against tvOS SDK

* Update CHANGELOG.md

* [tvOS] Fixes implicit conversion between UIViewAnimationCurve +
UIViewAnimationOptions

* Enable tvOS deployment target in Texture.podspec (for CI)

* [ASMultiplexImageNode] Fixes typo

* [tvOS] Fixes warnings related to @available guards in Xcode 9
[ASMultiplexImageNode] Enables support for Photos framework on tvOS 10+

[ASMultiplexImageNode] Fixes comment depth

[ASAvailability] Adjust logic in AS_AVAILABLE_IOS_TVOS to account for
both versions
Adjusts API_AVAILABLE to minimum deployment target

* [ASAvailability] Update AS_AVAILABLE_XXX fallbacks to function more like
the built-in solution (more accurately target OS by checking target)
Change AS_AVAILABLE_IOS -> AS_AVAILABLE_IOS_TVOS in places that shoud
allow for both

[ASAvailability] Simplify AS_AVAILABLE_IOS_TVOS

* [ASControlNode] Adds missing 'super' call in -[ASControlNode didLoad]
when targeting tvOS

* Fix API_AVAILABLE iOS requirement

* [ASDisplayNode] Fixes last of the linker warnings related to category
overrides. Removes methods already implemented in
ASDisplayNode+UIViewBridge category.
[ASControlNode] Moves tvOS category declaration to ASControlNode header
[ASImageNode] Moves tvOS category declaration to ASImageNode header
[ASControlNode+Private] Adds private category for ASControlNode to
access private selectors

* [NSParagraphStyle+ASText] Fixes typo related to testing

* [ASControlNode] Re-add helpful comment

* [ASTextKitCoreTextAdditions] Adds mappings for kCTParagraphStyleSpecifierMinimumLineSpacing, kCTParagraphStyleSpecifierMaximumLineSpacing, kCTParagraphStyleSpecifierLineSpacingAdjustment when mapping CTParagraphStyle onto NSParagraphStyle
[ASTextNode] Uses CoreText-cleansed attributed string when assigning ascender/descender to avoid crash when a CTParagraphStyle is passed as an attribute

* [AsyncDisplayKit] Update project file to include new/deleted files

* [ASControlNode+tvOS] Add missing Foundation import (whoops!)
[ASImageNode+tvOS] Add missing Foundation import (whoops!)

* Update podspec to only link AssetsLibrary framework on iOS

* [ASTextKitCoreTextAdditions] If kCTParagraphStyleAttributeName key-value
evaluates to an NSParagraphStyle, pass through to cleansed attributes. This
fixes a bug that would occur if a CTParagraphStyle was passed as an
attribute _alone_ (would not be caught by unsupported attributes
check)

* [ASMultiplexImageNode] Bump availability check to support < Xcode 9

* [ASTraitCollection] Fixes typo that was causing build to fail

* Clean up formatting to adhere to character/line limit + braces
  • Loading branch information
alexhillc authored and Adlai-Holler committed Mar 11, 2018
1 parent e0d07d0 commit d9d9a29
Show file tree
Hide file tree
Showing 29 changed files with 242 additions and 178 deletions.
12 changes: 4 additions & 8 deletions AsyncDisplayKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@
690C35621E055C5D00069B91 /* ASDimensionInternal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 690C35601E055C5D00069B91 /* ASDimensionInternal.mm */; };
690C35641E055C7B00069B91 /* ASDimensionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 690C35631E055C7B00069B91 /* ASDimensionInternal.h */; settings = {ATTRIBUTES = (Public, ); }; };
690ED58E1E36BCA6000627C0 /* ASLayoutElementStylePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 690ED58D1E36BCA6000627C0 /* ASLayoutElementStylePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
690ED5961E36D118000627C0 /* ASControlNode+tvOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 690ED5921E36D118000627C0 /* ASControlNode+tvOS.h */; settings = {ATTRIBUTES = (Private, ); }; };
690ED5981E36D118000627C0 /* ASControlNode+tvOS.m in Sources */ = {isa = PBXBuildFile; fileRef = 690ED5931E36D118000627C0 /* ASControlNode+tvOS.m */; };
690ED5991E36D118000627C0 /* ASImageNode+tvOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 690ED5941E36D118000627C0 /* ASImageNode+tvOS.h */; settings = {ATTRIBUTES = (Private, ); }; };
690ED59B1E36D118000627C0 /* ASImageNode+tvOS.m in Sources */ = {isa = PBXBuildFile; fileRef = 690ED5951E36D118000627C0 /* ASImageNode+tvOS.m */; };
692510141E74FB44003F2DD0 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 692510131E74FB44003F2DD0 /* [email protected] */; };
692BE8D71E36B65B00C86D87 /* ASLayoutSpecPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 692BE8D61E36B65B00C86D87 /* ASLayoutSpecPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down Expand Up @@ -475,6 +473,7 @@
E5E2D72E1EA780C4005C24C6 /* ASCollectionGalleryLayoutDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = E5E2D72D1EA780C4005C24C6 /* ASCollectionGalleryLayoutDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
E5E2D7301EA780DF005C24C6 /* ASCollectionGalleryLayoutDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5E2D72F1EA780DF005C24C6 /* ASCollectionGalleryLayoutDelegate.mm */; };
F711994E1D20C21100568860 /* ASDisplayNodeExtrasTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F711994D1D20C21100568860 /* ASDisplayNodeExtrasTests.m */; };
FA4FAF15200A850200E735BD /* ASControlNode+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = FA4FAF14200A850200E735BD /* ASControlNode+Private.h */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -670,9 +669,7 @@
690C35601E055C5D00069B91 /* ASDimensionInternal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASDimensionInternal.mm; sourceTree = "<group>"; };
690C35631E055C7B00069B91 /* ASDimensionInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASDimensionInternal.h; sourceTree = "<group>"; };
690ED58D1E36BCA6000627C0 /* ASLayoutElementStylePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutElementStylePrivate.h; sourceTree = "<group>"; };
690ED5921E36D118000627C0 /* ASControlNode+tvOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASControlNode+tvOS.h"; sourceTree = "<group>"; };
690ED5931E36D118000627C0 /* ASControlNode+tvOS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ASControlNode+tvOS.m"; sourceTree = "<group>"; };
690ED5941E36D118000627C0 /* ASImageNode+tvOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASImageNode+tvOS.h"; sourceTree = "<group>"; };
690ED5951E36D118000627C0 /* ASImageNode+tvOS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ASImageNode+tvOS.m"; sourceTree = "<group>"; };
692510131E74FB44003F2DD0 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
692BE8D61E36B65B00C86D87 /* ASLayoutSpecPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutSpecPrivate.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -982,6 +979,7 @@
E5E2D72F1EA780DF005C24C6 /* ASCollectionGalleryLayoutDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = ASCollectionGalleryLayoutDelegate.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
EFA731F0396842FF8AB635EE /* libPods-AsyncDisplayKitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AsyncDisplayKitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
F711994D1D20C21100568860 /* ASDisplayNodeExtrasTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASDisplayNodeExtrasTests.m; sourceTree = "<group>"; };
FA4FAF14200A850200E735BD /* ASControlNode+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASControlNode+Private.h"; sourceTree = "<group>"; };
FB07EABBCF28656C6297BC2D /* Pods-AsyncDisplayKitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AsyncDisplayKitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -1424,6 +1422,7 @@
CC2E317F1DAC353700EEE891 /* ASCollectionView+Undeprecated.h */,
CC0F885A1E42807F00576FED /* ASCollectionViewFlowLayoutInspector.h */,
CC0F88591E42807F00576FED /* ASCollectionViewFlowLayoutInspector.m */,
FA4FAF14200A850200E735BD /* ASControlNode+Private.h */,
9F98C0231DBDF2A300476D92 /* ASControlTargetAction.h */,
9F98C0241DBDF2A300476D92 /* ASControlTargetAction.m */,
8B0768B11CE752EC002E1453 /* ASDefaultPlaybackButton.h */,
Expand Down Expand Up @@ -1531,9 +1530,7 @@
690ED5911E36D118000627C0 /* tvOS */ = {
isa = PBXGroup;
children = (
690ED5921E36D118000627C0 /* ASControlNode+tvOS.h */,
690ED5931E36D118000627C0 /* ASControlNode+tvOS.m */,
690ED5941E36D118000627C0 /* ASImageNode+tvOS.h */,
690ED5951E36D118000627C0 /* ASImageNode+tvOS.m */,
);
path = tvOS;
Expand Down Expand Up @@ -1887,6 +1884,7 @@
9C70F20F1CDBE9FF007D6C76 /* ASLayoutManager.h in Headers */,
6947B0C31E36B5040007C478 /* ASStackPositionedLayout.h in Headers */,
DBABFAFC1C6A8D2F0039EA4A /* _ASTransitionContext.h in Headers */,
FA4FAF15200A850200E735BD /* ASControlNode+Private.h in Headers */,
B350624F1B010EFD0018CF92 /* ASDisplayNode+DebugTiming.h in Headers */,
CC57EAF71E3939350034C595 /* ASCollectionView+Undeprecated.h in Headers */,
B35062521B010EFD0018CF92 /* ASDisplayNodeInternal.h in Headers */,
Expand All @@ -1902,14 +1900,12 @@
DEC146B71C37A16A004A0EE7 /* ASCollectionInternal.h in Headers */,
68B8A4E21CBDB958007E4543 /* ASWeakProxy.h in Headers */,
9F98C0271DBE29FC00476D92 /* ASControlTargetAction.h in Headers */,
690ED5961E36D118000627C0 /* ASControlNode+tvOS.h in Headers */,
695943401D70815300B0EE1F /* ASDisplayNodeLayout.h in Headers */,
0442850E1BAA64EC00D16268 /* ASTwoDimensionalArrayUtils.h in Headers */,
DE8BEAC21C2DF3FC00D57C12 /* ASDelegateProxy.h in Headers */,
B350623E1B010EFD0018CF92 /* _ASAsyncTransactionContainer+Private.h in Headers */,
AC6145411D8AFAE8003D62A2 /* ASSection.h in Headers */,
8BBBAB8C1CEBAF1700107FC6 /* ASDefaultPlaybackButton.h in Headers */,
690ED5991E36D118000627C0 /* ASImageNode+tvOS.h in Headers */,
254C6B741BF94DF4003EC431 /* ASTextNodeWordKerner.h in Headers */,
698DFF441E36B6C9002891F1 /* ASStackLayoutSpecUtilities.h in Headers */,
CCF18FF41D2575E300DF5895 /* NSIndexSet+ASHelpers.h in Headers */,
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## master
* Add your own contributions to the next release on the line below this with your name.
- [tvOS] Fixes errors when building against tvOS SDK [Alex Hill](https://github.com/alexhillc) [#728](https://github.com/TextureGroup/Texture/pull/728)
- [ASDisplayNode] Add unit tests for layout z-order changes (with an open issue to fix).
- [ASDisplayNode] Consolidate main thread initialization and allow apps to invoke it manually instead of +load.
- [ASRunloopQueue] Introduce new runloop queue(ASCATransactionQueue) to coalesce Interface state update calls for view controller transitions.
Expand Down
2 changes: 1 addition & 1 deletion Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ - (instancetype)_initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionV
// Experiments done by Instagram show that this option being YES (default)
// when unused causes a significant hit to scroll performance.
// https://github.com/Instagram/IGListKit/issues/318
if (AS_AVAILABLE_IOS(10)) {
if (AS_AVAILABLE_IOS_TVOS(10, 10)) {
super.prefetchingEnabled = NO;
}

Expand Down
7 changes: 6 additions & 1 deletion Source/ASControlNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,17 @@ static UIControlState const ASControlStateSelected ASDISPLAYNODE_DEPRECATED_MSG(
@param event The event which triggered these control actions. May be nil.
*/
- (void)sendActionsForControlEvents:(ASControlNodeEvent)controlEvents withEvent:(nullable UIEvent *)event;
@end

#if TARGET_OS_TV
@interface ASControlNode (tvOS)

/**
@abstract How the node looks when it isn't focused. Exposed here so that subclasses can override.
*/
- (void)setDefaultFocusAppearance;
#endif

@end
#endif

NS_ASSUME_NONNULL_END
5 changes: 4 additions & 1 deletion Source/ASControlNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
//

#import <AsyncDisplayKit/ASControlNode.h>
#import <AsyncDisplayKit/ASControlNode+Private.h>
#import <AsyncDisplayKit/ASControlNode+Subclasses.h>
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>
#import <AsyncDisplayKit/ASImageNode.h>
Expand Down Expand Up @@ -103,10 +104,12 @@ - (instancetype)init
#if TARGET_OS_TV
- (void)didLoad
{
[super didLoad];

// On tvOS all controls, such as buttons, interact with the focus system even if they don't have a target set on them.
// Here we add our own internal tap gesture to handle this behaviour.
self.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGestureRec = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pressDown)];
UITapGestureRecognizer *tapGestureRec = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_pressDown)];
tapGestureRec.allowedPressTypes = @[@(UIPressTypeSelect)];
[self.view addGestureRecognizer:tapGestureRec];
}
Expand Down
34 changes: 0 additions & 34 deletions Source/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3601,40 +3601,6 @@ - (void)asyncTraitCollectionDidChange
{
// Subclass override
}

#if TARGET_OS_TV
#pragma mark - UIFocusEnvironment Protocol (tvOS)

- (void)setNeedsFocusUpdate
{

}

- (void)updateFocusIfNeeded
{

}

- (BOOL)shouldUpdateFocusInContext:(UIFocusUpdateContext *)context
{
return NO;
}

- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
{

}

- (UIView *)preferredFocusedView
{
if (self.nodeLoaded) {
return self.view;
} else {
return nil;
}
}
#endif

@end

#pragma mark - ASDisplayNode (Debugging)
Expand Down
2 changes: 1 addition & 1 deletion Source/ASImageNode+AnimatedImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ - (void)displayLinkFired:(CADisplayLink *)displayLink
CFTimeInterval timeBetweenLastFire;
if (self.lastDisplayLinkFire == 0) {
timeBetweenLastFire = 0;
} else if (AS_AVAILABLE_IOS(10)){
} else if (AS_AVAILABLE_IOS_TVOS(10, 10)) {
timeBetweenLastFire = displayLink.targetTimestamp - displayLink.timestamp;
} else {
timeBetweenLastFire = CACurrentMediaTime() - self.lastDisplayLinkFire;
Expand Down
5 changes: 5 additions & 0 deletions Source/ASImageNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ typedef UIImage * _Nullable (^asimagenode_modification_block_t)(UIImage *image);

@end

#if TARGET_OS_TV
@interface ASImageNode (tvOS)
@end
#endif

@interface ASImageNode (AnimatedImage)

/**
Expand Down
14 changes: 4 additions & 10 deletions Source/ASMultiplexImageNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,12 @@ typedef NS_ENUM(NSUInteger, ASMultiplexImageNodeErrorCode) {
*/
@property (nonatomic, assign, readwrite) BOOL shouldRenderProgressImages;

#if TARGET_OS_IOS
/**
* @abstract The image manager that this image node should use when requesting images from the Photos framework. If this is `nil` (the default), then `PHImageManager.defaultManager` is used.
* @see `+[NSURL URLWithAssetLocalIdentifier:targetSize:contentMode:options:]` below.
*/
@property (nullable, nonatomic, strong) PHImageManager *imageManager;
#endif
@property (nullable, nonatomic, strong) PHImageManager *imageManager API_AVAILABLE(ios(8.0), tvos(10.0));
@end


Expand Down Expand Up @@ -245,7 +243,6 @@ didFinishDownloadingImageWithIdentifier:(ASImageIdentifier)imageIdentifier
*/
- (nullable NSURL *)multiplexImageNode:(ASMultiplexImageNode *)imageNode URLForImageIdentifier:(ASImageIdentifier)imageIdentifier;

#if TARGET_OS_IOS
/**
* @abstract A PHAsset for the specific asset local identifier
* @param imageNode The sender.
Expand All @@ -256,12 +253,10 @@ didFinishDownloadingImageWithIdentifier:(ASImageIdentifier)imageIdentifier
* @note This method may be called from any thread.
* @return A PHAsset corresponding to `assetLocalIdentifier`, or nil if none is available.
*/
- (nullable PHAsset *)multiplexImageNode:(ASMultiplexImageNode *)imageNode assetForLocalIdentifier:(NSString *)assetLocalIdentifier;
#endif
- (nullable PHAsset *)multiplexImageNode:(ASMultiplexImageNode *)imageNode assetForLocalIdentifier:(NSString *)assetLocalIdentifier API_AVAILABLE(ios(8.0), tvos(10.0));
@end

#pragma mark -
#if TARGET_OS_IOS
#pragma mark -
@interface NSURL (ASPhotosFrameworkURLs)

/**
Expand All @@ -275,9 +270,8 @@ didFinishDownloadingImageWithIdentifier:(ASImageIdentifier)imageIdentifier
+ (NSURL *)URLWithAssetLocalIdentifier:(NSString *)assetLocalIdentifier
targetSize:(CGSize)targetSize
contentMode:(PHImageContentMode)contentMode
options:(PHImageRequestOptions *)options AS_WARN_UNUSED_RESULT;
options:(PHImageRequestOptions *)options AS_WARN_UNUSED_RESULT API_AVAILABLE(ios(8.0), tvos(10.0));

@end
#endif

NS_ASSUME_NONNULL_END
Loading

0 comments on commit d9d9a29

Please sign in to comment.