Skip to content
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

Merged
merged 31 commits into from
Mar 11, 2018

Conversation

alexhillc
Copy link
Contributor

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.

@ghost
Copy link

ghost commented Dec 28, 2017

🚫 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
@ghost
Copy link

ghost commented Dec 29, 2017

🚫 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)) {
Copy link
Contributor Author

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))
Copy link
Contributor Author

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)
@nguyenhuy
Copy link
Member

@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?

@Eke
Copy link
Contributor

Eke commented Jan 16, 2018

@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:
@alexhillc for example i replaced UITapGestureRecognizer for control taps with Low-Level Event Handling and etc.

@alexhillc
Copy link
Contributor Author

@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 master branch, but wanted to see this PR through before opening another!

@Eke
Copy link
Contributor

Eke commented Jan 21, 2018

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.

@TextureGroup TextureGroup deleted a comment Jan 31, 2018
@TextureGroup TextureGroup deleted a comment Jan 31, 2018
@TextureGroup TextureGroup deleted a comment Jan 31, 2018
@Adlai-Holler Adlai-Holler mentioned this pull request Jan 31, 2018
@appleguy
Copy link
Member

appleguy commented Feb 9, 2018

@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)
Copy link
Member

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;
Copy link
Member

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 {
Copy link
Member

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 }.

Copy link
Member

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;
Copy link
Member

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.

Copy link
Member

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'
Copy link
Member

Choose a reason for hiding this comment

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

Hooray!

Copy link
Member

@Adlai-Holler Adlai-Holler left a 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;
Copy link
Member

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?

Copy link
Contributor Author

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

@alexhillc
Copy link
Contributor Author

I’ll get back to this soon, been busy lately but will hopefully find some time later this week

@appleguy
Copy link
Member

@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).

Copy link
Contributor

@maicki maicki left a comment

Choose a reason for hiding this comment

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

Nice work!

@alexhillc
Copy link
Contributor Author

@appleguy, just made some small changes to formatting as requested -- I'm ready 👍
Looking forward to adding more support for tvOS!

@ghost
Copy link

ghost commented Feb 28, 2018

🚫 CI failed with log

@ghost
Copy link

ghost commented Mar 4, 2018

4 Warnings
⚠️ Please ensure license is correct for ASTextAttribute.m:

//
//  ASTextAttribute.m
//  Texture
//
//  Copyright (c) 2014-present, Facebook, Inc.  All rights reserved.
//  This source code is licensed under the BSD-style license found in the
//  LICENSE file in the /ASDK-Licenses directory of this source tree. An additional
//  grant of patent rights can be found in the PATENTS file in the same directory.
//
//  Modifications to this file made after 4/13/2017 are: Copyright (c) through the present,
//  Pinterest, Inc.  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//

    
⚠️ Please ensure license is correct for NSAttributedString+ASText.h:

//
//  NSAttributedString+ASText.h
//  Texture
//
//  Copyright (c) 2014-present, Facebook, Inc.  All rights reserved.
//  This source code is licensed under the BSD-style license found in the
//  LICENSE file in the /ASDK-Licenses directory of this source tree. An additional
//  grant of patent rights can be found in the PATENTS file in the same directory.
//
//  Modifications to this file made after 4/13/2017 are: Copyright (c) through the present,
//  Pinterest, Inc.  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//

    
⚠️ Please ensure license is correct for NSAttributedString+ASText.m:

//
//  NSAttributedString+ASText.m
//  Texture
//
//  Copyright (c) 2014-present, Facebook, Inc.  All rights reserved.
//  This source code is licensed under the BSD-style license found in the
//  LICENSE file in the /ASDK-Licenses directory of this source tree. An additional
//  grant of patent rights can be found in the PATENTS file in the same directory.
//
//  Modifications to this file made after 4/13/2017 are: Copyright (c) through the present,
//  Pinterest, Inc.  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//

    
⚠️ Please ensure license is correct for NSParagraphStyle+ASText.m:

//
//  NSParagraphStyle+ASText.m
//  Texture
//
//  Copyright (c) 2014-present, Facebook, Inc.  All rights reserved.
//  This source code is licensed under the BSD-style license found in the
//  LICENSE file in the /ASDK-Licenses directory of this source tree. An additional
//  grant of patent rights can be found in the PATENTS file in the same directory.
//
//  Modifications to this file made after 4/13/2017 are: Copyright (c) through the present,
//  Pinterest, Inc.  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//

    

Generated by 🚫 Danger

@Adlai-Holler Adlai-Holler merged commit d9d9a29 into TextureGroup:master Mar 11, 2018
bernieperez pushed a commit to AtomTickets/Texture that referenced this pull request Apr 25, 2018
* [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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants