-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tvOS] Fixes errors when building against tvOS SDK #728
Conversation
UIViewAnimationOptions
🚫 CI failed with log |
[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
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
when targeting tvOS
🚫 CI failed with log |
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
@@ -25,13 +25,15 @@ + (NSParagraphStyle *)as_styleWithCTStyle:(CTParagraphStyleRef)CTStyle { | |||
|
|||
NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; | |||
|
|||
#if TARGET_OS_IOS | |||
#pragma clang diagnostic push | |||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | |||
CGFloat lineSpacing; | |||
if (CTParagraphStyleGetValueForSpecifier(CTStyle, kCTParagraphStyleSpecifierLineSpacing, sizeof(CGFloat), &lineSpacing)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add back support for line spacing on tvOS since kCTParagraphStyleSpecifierLineSpacing
is unavailable on tvOS.
@@ -236,6 +237,7 @@ + (instancetype)paragraphStyleWithCTParagraphStyle:(CTParagraphStyleRef)coreText | |||
if (CTParagraphStyleGetValueForSpecifier(coreTextParagraphStyle, kCTParagraphStyleSpecifierLineSpacing, sizeof(lineSpacing), &lineSpacing)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add back support for line spacing on tvOS since kCTParagraphStyleSpecifierLineSpacing
is unavailable on tvOS.
…fierMinimumLineSpacing, 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
[ASImageNode+tvOS] Add missing Foundation import (whoops!)
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)
@alexhillc Awesome to see you taking the lead here. I know @Eke has been working on tvOS support for a while. @Eke Do you mind reviewing this diff? |
@alexhillc great job! I'm happy that someone managed to make this happen! I will compare it to my local changes, maybe we can collaborate on some parts? @nguyenhuy i will try to review it tomorrow UPD: |
@Eke, I'd be more than happy to collaborate on this. :) I'd also be interested to see your local changes as well. I didn't make any changes to the functionality of the existing tvOS code yet so I'd be interested to see how you're going about handling it. I have also added ASTableNode + ASCollectionNode support for the focus API in my |
Hello @alexhillc @nguyenhuy ! Sorry for delay, I had very busy week and i only managed to try building my project today. Both tvOS and iOS versions build good with this changes. I think this PR is big step forward for tvOS support implementation. Tomorrow morning i will review code changes as well. We had small conversation with @alexhillc and we will collaborate for further changes. |
@alexhillc I'm really grateful that you've worked on this! I think tvOS is a great platform for Texture and will meaningfully improve the UX of apps on the platform. Especially preloading will work very well, since the home internet connections can easily handle the higher bandwidth requirements, and it's worth that user experience win of thumbnails being loaded before they come onscreen (which many tvOS apps don't do today). |
#if TARGET_OS_TV | ||
@interface ASControlNode (tvOS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding categories, this is a nice improvement for organization.
@@ -450,10 +450,10 @@ - (void)setAttributedText:(NSAttributedString *)attributedText | |||
// Since truncation text matches style of attributedText, invalidate it now. | |||
[self _invalidateTruncationText]; | |||
|
|||
NSUInteger length = attributedText.length; | |||
NSUInteger length = _attributedText.length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting fix, this could be important in the case of cleansing attributed text...
if ([coreTextValue isKindOfClass:[NSParagraphStyle class]]) { | ||
cleanAttributes[NSParagraphStyleAttributeName] = (NSParagraphStyle *)coreTextValue; | ||
} | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please adjust if-else style to match project; else { should be on the line with the }.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I guess other parts of this file are not conforming either. So this is probably OK.
// - kCTParagraphStyleSpecifierLineSpacingAdjustment | ||
if (fabs(lineSpacing) <= FLT_EPSILON && | ||
CTParagraphStyleGetValueForSpecifier(coreTextParagraphStyle, kCTParagraphStyleSpecifierMinimumLineSpacing, sizeof(lineSpacing), &lineSpacing)) | ||
newParagraphStyle.lineSpacing = lineSpacing; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All if statements should use braces, even for one line. I'd suggest doing that for these statements even if the rest of the file doesn't / did not previously, since the conditions are so long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth making a macro for these checks, or at least a local variable for the FLT_EPSILON check.
|
||
# Uncomment when fixed: issues with tvOS build for release 2.0 | ||
# spec.tvos.deployment_target = '9.0' | ||
spec.tvos.deployment_target = '9.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hooray!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a ton of work, but tvOS is exciting! Thanks @alexhillc
self.separatorInset = node.separatorInset; | ||
#endif | ||
self.selectionStyle = node.selectionStyle; | ||
self.focusStyle = node.focusStyle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexhillc I had to do a manual merge of this file. Does this code look correct now / still?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@appleguy, looks correct to me
I’ll get back to this soon, been busy lately but will hopefully find some time later this week |
@alexhillc let us know when you're ready to go and I'm happy to merge this. BTW I did try building it locally with a hacked version of ASDKgram to build for tvOS, and no build failures encountered :). I did hit a weird runtime error with an assertion about lock handling though, so I'm still looking at that (but I don't think it's caused by this PR). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
@appleguy, just made some small changes to formatting as requested -- I'm ready 👍 |
🚫 CI failed with log |
Generated by 🚫 Danger |
* [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
Hello!
I decided to look into what needed fixing for tvOS support and discovered #653, which doesn't have any recent activity... so I thought that going through and fixing the build errors that the project has would be a good start.