Add way to compile out ASTextNode + TextKit dependencies (#1242)

* Add way to compile out ASTextNode + TextKit dependencies

* Compile out ASExperimentalTextNode and fix tests
This commit is contained in:
Michael Schneider 2018-11-23 09:13:15 -08:00 committed by GitHub
parent 31125ff6cf
commit f2bc63f05a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 196 additions and 6 deletions

View File

@ -7,6 +7,7 @@
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <AsyncDisplayKit/ASAvailability.h>
#import <AsyncDisplayKit/ASBaseDefines.h> #import <AsyncDisplayKit/ASBaseDefines.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -16,7 +17,9 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
typedef NS_OPTIONS(NSUInteger, ASExperimentalFeatures) { typedef NS_OPTIONS(NSUInteger, ASExperimentalFeatures) {
ASExperimentalGraphicsContexts = 1 << 0, // exp_graphics_contexts ASExperimentalGraphicsContexts = 1 << 0, // exp_graphics_contexts
#if AS_ENABLE_TEXTNODE
ASExperimentalTextNode = 1 << 1, // exp_text_node ASExperimentalTextNode = 1 << 1, // exp_text_node
#endif
ASExperimentalInterfaceStateCoalescing = 1 << 2, // exp_interface_state_coalesce ASExperimentalInterfaceStateCoalescing = 1 << 2, // exp_interface_state_coalesce
ASExperimentalUnfairLock = 1 << 3, // exp_unfair_lock ASExperimentalUnfairLock = 1 << 3, // exp_unfair_lock
ASExperimentalLayerDefaults = 1 << 4, // exp_infer_layer_defaults ASExperimentalLayerDefaults = 1 << 4, // exp_infer_layer_defaults

View File

@ -8,9 +8,17 @@
// //
#import <AsyncDisplayKit/ASAvailability.h> #import <AsyncDisplayKit/ASAvailability.h>
#import <AsyncDisplayKit/ASControlNode.h> #import <AsyncDisplayKit/ASControlNode.h>
#import <AsyncDisplayKit/ASTextNodeCommon.h> #import <AsyncDisplayKit/ASTextNodeCommon.h>
#if (!AS_ENABLE_TEXTNODE)
// Pull in ASTextNode2 to replace ASTextNode with ASTextNode2
#import <AsyncDisplayKit/ASTextNode2.h>
#else
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/** /**
@ -251,3 +259,5 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
#endif

View File

@ -8,6 +8,9 @@
// //
#import <AsyncDisplayKit/ASTextNode.h> #import <AsyncDisplayKit/ASTextNode.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASTextNode2.h> #import <AsyncDisplayKit/ASTextNode2.h>
#import <AsyncDisplayKit/ASTextNode+Beta.h> #import <AsyncDisplayKit/ASTextNode+Beta.h>
@ -1427,3 +1430,5 @@ static NSAttributedString *DefaultTruncationAttributedString()
} }
@end @end
#endif

View File

@ -17,7 +17,11 @@ NS_ASSUME_NONNULL_BEGIN
@abstract Draws interactive rich text. @abstract Draws interactive rich text.
@discussion Backed by the code in TextExperiment folder, on top of CoreText. @discussion Backed by the code in TextExperiment folder, on top of CoreText.
*/ */
#if AS_ENABLE_TEXTNODE
@interface ASTextNode2 : ASControlNode @interface ASTextNode2 : ASControlNode
#else
@interface ASTextNode : ASControlNode
#endif
/** /**
@abstract The styled text displayed by the node. @abstract The styled text displayed by the node.
@ -215,7 +219,11 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
#if AS_ENABLE_TEXTNODE
@interface ASTextNode2 (Unavailable) @interface ASTextNode2 (Unavailable)
#else
@interface ASTextNode (Unavailable)
#endif
- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; - (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE;
@ -223,6 +231,11 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
#if (!AS_ENABLE_TEXTNODE)
// For the time beeing remap ASTextNode2 to ASTextNode
#define ASTextNode2 ASTextNode
#endif
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@ -141,11 +141,19 @@ static const CGFloat ASTextNodeHighlightLightOpacity = 0.11;
static const CGFloat ASTextNodeHighlightDarkOpacity = 0.22; static const CGFloat ASTextNodeHighlightDarkOpacity = 0.22;
static NSString *ASTextNodeTruncationTokenAttributeName = @"ASTextNodeTruncationAttribute"; static NSString *ASTextNodeTruncationTokenAttributeName = @"ASTextNodeTruncationAttribute";
#if AS_ENABLE_TEXTNODE
@interface ASTextNode2 () <UIGestureRecognizerDelegate> @interface ASTextNode2 () <UIGestureRecognizerDelegate>
#else
@interface ASTextNode () <UIGestureRecognizerDelegate>
#endif
@end @end
#if AS_ENABLE_TEXTNODE
@implementation ASTextNode2 { @implementation ASTextNode2 {
#else
@implementation ASTextNode {
#endif
ASTextContainer *_textContainer; ASTextContainer *_textContainer;
CGSize _shadowOffset; CGSize _shadowOffset;

View File

@ -8,6 +8,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <AsyncDisplayKit/ASAvailability.h>
@class ASTextNode; @class ASTextNode;
#define AS_TEXT_ALERT_UNIMPLEMENTED_FEATURE() { \ #define AS_TEXT_ALERT_UNIMPLEMENTED_FEATURE() { \

View File

@ -17,6 +17,10 @@
#define AS_TLS_AVAILABLE 1 #define AS_TLS_AVAILABLE 1
#endif #endif
#ifndef AS_ENABLE_TEXTNODE
#define AS_ENABLE_TEXTNODE 1 // Enable old TextNode by default
#endif
// This needs to stay in sync with Weaver // This needs to stay in sync with Weaver
#ifndef AS_USE_VIDEO #ifndef AS_USE_VIDEO
#define AS_USE_VIDEO 0 #define AS_USE_VIDEO 0

View File

@ -10,6 +10,11 @@
#pragma once #pragma once
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <AsyncDisplayKit/ASAvailability.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASEqualityHelpers.h> #import <AsyncDisplayKit/ASEqualityHelpers.h>
AS_EXTERN NSString *const ASTextKitTruncationAttributeName; AS_EXTERN NSString *const ASTextKitTruncationAttributeName;
@ -119,3 +124,5 @@ struct ASTextKitAttributes {
size_t hash() const; size_t hash() const;
}; };
#endif

View File

@ -9,6 +9,8 @@
#import <AsyncDisplayKit/ASTextKitAttributes.h> #import <AsyncDisplayKit/ASTextKitAttributes.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASHashing.h> #import <AsyncDisplayKit/ASHashing.h>
NSString *const ASTextKitTruncationAttributeName = @"ck_truncation"; NSString *const ASTextKitTruncationAttributeName = @"ck_truncation";
@ -44,3 +46,5 @@ size_t ASTextKitAttributes::hash() const
}; };
return ASHashBytes(&data, sizeof(data)); return ASHashBytes(&data, sizeof(data));
} }
#endif

View File

@ -8,6 +8,7 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <AsyncDisplayKit/ASBaseDefines.h> #import <AsyncDisplayKit/ASBaseDefines.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN

View File

@ -8,6 +8,11 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <AsyncDisplayKit/ASAvailability.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASBaseDefines.h> #import <AsyncDisplayKit/ASBaseDefines.h>
/** /**
@ -44,3 +49,5 @@ AS_SUBCLASSING_RESTRICTED
NSTextContainer *textContainer))block; NSTextContainer *textContainer))block;
@end @end
#endif

View File

@ -8,6 +8,9 @@
// //
#import <AsyncDisplayKit/ASTextKitContext.h> #import <AsyncDisplayKit/ASTextKitContext.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASLayoutManager.h> #import <AsyncDisplayKit/ASLayoutManager.h>
#import <AsyncDisplayKit/ASThread.h> #import <AsyncDisplayKit/ASThread.h>
@ -73,3 +76,5 @@
} }
@end @end
#endif

View File

@ -7,9 +7,12 @@
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0 // Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
// //
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <AsyncDisplayKit/ASAvailability.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASBaseDefines.h> #import <AsyncDisplayKit/ASBaseDefines.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -82,3 +85,5 @@ AS_EXTERN NSAttributedString *ASCleanseAttributedStringOfCoreTextAttributes(NSAt
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
#endif

View File

@ -9,6 +9,8 @@
#import <AsyncDisplayKit/ASTextKitCoreTextAdditions.h> #import <AsyncDisplayKit/ASTextKitCoreTextAdditions.h>
#if AS_ENABLE_TEXTNODE
#import <CoreText/CTFont.h> #import <CoreText/CTFont.h>
#import <CoreText/CTStringAttributes.h> #import <CoreText/CTStringAttributes.h>
@ -333,3 +335,5 @@ NSAttributedString *ASCleanseAttributedStringOfCoreTextAttributes(NSAttributedSt
} }
@end @end
#endif

View File

@ -8,6 +8,11 @@
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <AsyncDisplayKit/ASAvailability.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASBaseDefines.h> #import <AsyncDisplayKit/ASBaseDefines.h>
/** /**
@ -27,3 +32,5 @@ AS_SUBCLASSING_RESTRICTED
- (instancetype)initWithEntity:(id<NSObject>)entity; - (instancetype)initWithEntity:(id<NSObject>)entity;
@end @end
#endif

View File

@ -9,6 +9,8 @@
#import <AsyncDisplayKit/ASTextKitEntityAttribute.h> #import <AsyncDisplayKit/ASTextKitEntityAttribute.h>
#if AS_ENABLE_TEXTNODE
@implementation ASTextKitEntityAttribute @implementation ASTextKitEntityAttribute
- (instancetype)initWithEntity:(id<NSObject>)entity - (instancetype)initWithEntity:(id<NSObject>)entity
@ -37,3 +39,5 @@
} }
@end @end
#endif

View File

@ -8,8 +8,12 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <AsyncDisplayKit/ASAvailability.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASTextKitAttributes.h> #import <AsyncDisplayKit/ASTextKitAttributes.h>
#import <AsyncDisplayKit/ASBaseDefines.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -50,3 +54,5 @@ AS_SUBCLASSING_RESTRICTED
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
#endif

View File

@ -10,6 +10,8 @@
#import <AsyncDisplayKit/ASTextKitFontSizeAdjuster.h> #import <AsyncDisplayKit/ASTextKitFontSizeAdjuster.h>
#if AS_ENABLE_TEXTNODE
#import <tgmath.h> #import <tgmath.h>
#import <mutex> #import <mutex>
@ -235,3 +237,5 @@
} }
@end @end
#endif

View File

@ -9,6 +9,8 @@
#import <AsyncDisplayKit/ASTextKitRenderer.h> #import <AsyncDisplayKit/ASTextKitRenderer.h>
#if AS_ENABLE_TEXTNODE
typedef void (^as_text_component_index_block_t)(NSUInteger characterIndex, typedef void (^as_text_component_index_block_t)(NSUInteger characterIndex,
CGRect glyphBoundingRect, CGRect glyphBoundingRect,
BOOL *stop); BOOL *stop);
@ -100,3 +102,5 @@ typedef NS_ENUM(NSUInteger, ASTextKitRendererMeasureOption) {
- (CGRect)trailingRect; - (CGRect)trailingRect;
@end @end
#endif

View File

@ -9,6 +9,8 @@
#import <AsyncDisplayKit/ASTextKitRenderer+Positioning.h> #import <AsyncDisplayKit/ASTextKitRenderer+Positioning.h>
#if AS_ENABLE_TEXTNODE
#import <CoreText/CoreText.h> #import <CoreText/CoreText.h>
#import <tgmath.h> #import <tgmath.h>
@ -380,3 +382,5 @@ static const CGFloat ASTextKitRendererTextCapHeightPadding = 1.3;
} }
@end @end
#endif

View File

@ -9,6 +9,8 @@
#import <AsyncDisplayKit/ASTextKitRenderer.h> #import <AsyncDisplayKit/ASTextKitRenderer.h>
#if AS_ENABLE_TEXTNODE
/** /**
Application extensions to NSTextCheckingType. We're allowed to do this (see NSTextCheckingAllCustomTypes). Application extensions to NSTextCheckingType. We're allowed to do this (see NSTextCheckingAllCustomTypes).
*/ */
@ -26,3 +28,5 @@ static uint64_t const ASTextKitTextCheckingTypeTruncation = 1ULL << 34
- (NSTextCheckingResult *)textCheckingResultAtPoint:(CGPoint)point; - (NSTextCheckingResult *)textCheckingResultAtPoint:(CGPoint)point;
@end @end
#endif

View File

@ -9,6 +9,8 @@
#import <AsyncDisplayKit/ASTextKitRenderer+TextChecking.h> #import <AsyncDisplayKit/ASTextKitRenderer+TextChecking.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASTextKitEntityAttribute.h> #import <AsyncDisplayKit/ASTextKitEntityAttribute.h>
#import <AsyncDisplayKit/ASTextKitRenderer+Positioning.h> #import <AsyncDisplayKit/ASTextKitRenderer+Positioning.h>
#import <AsyncDisplayKit/ASTextKitTailTruncater.h> #import <AsyncDisplayKit/ASTextKitTailTruncater.h>
@ -98,3 +100,5 @@
} }
@end @end
#endif

View File

@ -7,12 +7,16 @@
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0 // Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
// //
#import <vector>
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <AsyncDisplayKit/ASAvailability.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASTextKitAttributes.h> #import <AsyncDisplayKit/ASTextKitAttributes.h>
#import <vector>
@class ASTextKitContext; @class ASTextKitContext;
@class ASTextKitShadower; @class ASTextKitShadower;
@class ASTextKitFontSizeAdjuster; @class ASTextKitFontSizeAdjuster;
@ -100,3 +104,5 @@
@property (nonatomic, readonly) NSRange firstVisibleRange; @property (nonatomic, readonly) NSRange firstVisibleRange;
@end @end
#endif

View File

@ -9,6 +9,8 @@
#import <AsyncDisplayKit/ASTextKitRenderer.h> #import <AsyncDisplayKit/ASTextKitRenderer.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASAssert.h> #import <AsyncDisplayKit/ASAssert.h>
#import <AsyncDisplayKit/ASTextKitContext.h> #import <AsyncDisplayKit/ASTextKitContext.h>
@ -289,3 +291,5 @@ static NSCharacterSet *_defaultAvoidTruncationCharacterSet()
} }
@end @end
#endif

View File

@ -8,6 +8,11 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <AsyncDisplayKit/ASAvailability.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASBaseDefines.h> #import <AsyncDisplayKit/ASBaseDefines.h>
/** /**
@ -69,3 +74,5 @@ AS_SUBCLASSING_RESTRICTED
- (void)setShadowInContext:(CGContextRef)context; - (void)setShadowInContext:(CGContextRef)context;
@end @end
#endif

View File

@ -9,6 +9,8 @@
#import <AsyncDisplayKit/ASTextKitShadower.h> #import <AsyncDisplayKit/ASTextKitShadower.h>
#if AS_ENABLE_TEXTNODE
#import <tgmath.h> #import <tgmath.h>
static inline CGSize _insetSize(CGSize size, UIEdgeInsets insets) static inline CGSize _insetSize(CGSize size, UIEdgeInsets insets)
@ -171,3 +173,5 @@ static inline UIEdgeInsets _invertInsets(UIEdgeInsets insets)
} }
@end @end
#endif

View File

@ -9,10 +9,13 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <AsyncDisplayKit/ASBaseDefines.h>
#import <AsyncDisplayKit/ASTextKitTruncating.h> #import <AsyncDisplayKit/ASTextKitTruncating.h>
#if AS_ENABLE_TEXTNODE
AS_SUBCLASSING_RESTRICTED AS_SUBCLASSING_RESTRICTED
@interface ASTextKitTailTruncater : NSObject <ASTextKitTruncating> @interface ASTextKitTailTruncater : NSObject <ASTextKitTruncating>
@end @end
#endif

View File

@ -7,9 +7,12 @@
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0 // Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
// //
#import <AsyncDisplayKit/ASTextKitContext.h>
#import <AsyncDisplayKit/ASTextKitTailTruncater.h> #import <AsyncDisplayKit/ASTextKitTailTruncater.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASTextKitContext.h>
@implementation ASTextKitTailTruncater @implementation ASTextKitTailTruncater
{ {
__weak ASTextKitContext *_context; __weak ASTextKitContext *_context;
@ -189,3 +192,5 @@
} }
@end @end
#endif

View File

@ -8,6 +8,13 @@
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <AsyncDisplayKit/ASAvailability.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASBaseDefines.h>
#import <vector> #import <vector>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -50,3 +57,5 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
#endif

View File

@ -9,6 +9,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <UIKit/NSLayoutManager.h> #import <UIKit/NSLayoutManager.h>
#import <AsyncDisplayKit/ASBaseDefines.h> #import <AsyncDisplayKit/ASBaseDefines.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN

View File

@ -8,13 +8,16 @@
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
#import "ASTestCase.h" #import "ASTestCase.h"
#import "ASAvailability.h"
#import "ASConfiguration.h" #import "ASConfiguration.h"
#import "ASConfigurationDelegate.h" #import "ASConfigurationDelegate.h"
#import "ASConfigurationInternal.h" #import "ASConfigurationInternal.h"
static ASExperimentalFeatures features[] = { static ASExperimentalFeatures features[] = {
ASExperimentalGraphicsContexts, ASExperimentalGraphicsContexts,
#if AS_ENABLE_TEXTNODE
ASExperimentalTextNode, ASExperimentalTextNode,
#endif
ASExperimentalInterfaceStateCoalescing, ASExperimentalInterfaceStateCoalescing,
ASExperimentalUnfairLock, ASExperimentalUnfairLock,
ASExperimentalLayerDefaults, ASExperimentalLayerDefaults,
@ -56,6 +59,8 @@ static ASExperimentalFeatures features[] = {
return allFeatures; return allFeatures;
} }
#if AS_ENABLE_TEXTNODE
- (void)testExperimentalFeatureConfig - (void)testExperimentalFeatureConfig
{ {
// Set the config // Set the config
@ -81,6 +86,8 @@ static ASExperimentalFeatures features[] = {
[self waitForExpectationsWithTimeout:3 handler:nil]; [self waitForExpectationsWithTimeout:3 handler:nil];
} }
#endif
- (void)textureDidActivateExperimentalFeatures:(ASExperimentalFeatures)feature - (void)textureDidActivateExperimentalFeatures:(ASExperimentalFeatures)feature
{ {
if (onActivate) { if (onActivate) {

View File

@ -13,6 +13,8 @@
#import <AsyncDisplayKit/ASTextKitCoreTextAdditions.h> #import <AsyncDisplayKit/ASTextKitCoreTextAdditions.h>
#if AS_ENABLE_TEXTNODE
BOOL floatsCloseEnough(CGFloat float1, CGFloat float2) { BOOL floatsCloseEnough(CGFloat float1, CGFloat float2) {
CGFloat epsilon = 0.00001; CGFloat epsilon = 0.00001;
return (fabs(float1 - float2) < epsilon); return (fabs(float1 - float2) < epsilon);
@ -68,3 +70,5 @@ BOOL floatsCloseEnough(CGFloat float1, CGFloat float2) {
} }
@end @end
#endif

View File

@ -9,6 +9,8 @@
#import <AsyncDisplayKit/ASTextKitFontSizeAdjuster.h> #import <AsyncDisplayKit/ASTextKitFontSizeAdjuster.h>
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
#if AS_ENABLE_TEXTNODE
@interface ASFontSizeAdjusterTests : XCTestCase @interface ASFontSizeAdjusterTests : XCTestCase
@end @end
@ -45,3 +47,5 @@
} }
@end @end
#endif

View File

@ -13,6 +13,9 @@
#import <FBSnapshotTestCase/FBSnapshotTestController.h> #import <FBSnapshotTestCase/FBSnapshotTestController.h>
#import <AsyncDisplayKit/ASTextKitAttributes.h> #import <AsyncDisplayKit/ASTextKitAttributes.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASTextKitComponents.h> #import <AsyncDisplayKit/ASTextKitComponents.h>
#import <AsyncDisplayKit/ASTextKitEntityAttribute.h> #import <AsyncDisplayKit/ASTextKitEntityAttribute.h>
#import <AsyncDisplayKit/ASTextKitRenderer.h> #import <AsyncDisplayKit/ASTextKitRenderer.h>
@ -221,3 +224,5 @@ static BOOL checkAttributes(const ASTextKitAttributes &attributes, const CGSize
} }
@end @end
#endif

View File

@ -11,6 +11,9 @@
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
#import <AsyncDisplayKit/ASTextKitContext.h> #import <AsyncDisplayKit/ASTextKitContext.h>
#if AS_ENABLE_TEXTNODE
#import <AsyncDisplayKit/ASTextKitTailTruncater.h> #import <AsyncDisplayKit/ASTextKitTailTruncater.h>
@interface ASTextKitTruncationTests : XCTestCase @interface ASTextKitTruncationTests : XCTestCase
@ -158,3 +161,5 @@
} }
@end @end
#endif

View File

@ -24,7 +24,9 @@
// This will use ASTextNode2 for snapshot tests. // This will use ASTextNode2 for snapshot tests.
// All tests are duplicated from ASTextNodeSnapshotTests. // All tests are duplicated from ASTextNodeSnapshotTests.
ASConfiguration *config = [[ASConfiguration alloc] initWithDictionary:nil]; ASConfiguration *config = [[ASConfiguration alloc] initWithDictionary:nil];
#if AS_ENABLE_TEXTNODE
config.experimentalFeatures = ASExperimentalTextNode; config.experimentalFeatures = ASExperimentalTextNode;
#endif
[ASConfigurationManager test_resetWithConfiguration:config]; [ASConfigurationManager test_resetWithConfiguration:config];
self.recordMode = NO; self.recordMode = NO;

View File

@ -13,6 +13,7 @@
#import <OCMock/OCMock.h> #import <OCMock/OCMock.h>
#import <AsyncDisplayKit/ASAvailability.h>
#import <AsyncDisplayKit/ASLayout.h> #import <AsyncDisplayKit/ASLayout.h>
#import <AsyncDisplayKit/ASTextNode.h> #import <AsyncDisplayKit/ASTextNode.h>
@ -235,6 +236,7 @@
XCTAssertGreaterThan(sizeWithExclusionPaths.height, sizeWithoutExclusionPaths.height, @"Setting exclusions paths should invalidate the calculated size and return a greater size"); XCTAssertGreaterThan(sizeWithExclusionPaths.height, sizeWithoutExclusionPaths.height, @"Setting exclusions paths should invalidate the calculated size and return a greater size");
} }
#if AS_ENABLE_TEXTNODE
- (void)testThatTheExperimentWorksCorrectly - (void)testThatTheExperimentWorksCorrectly
{ {
ASConfiguration *config = [ASConfiguration new]; ASConfiguration *config = [ASConfiguration new];
@ -303,6 +305,7 @@
exp = nil; exp = nil;
[textNodeBucket removeAllObjects]; [textNodeBucket removeAllObjects];
} }
#endif
@end @end

View File

@ -55,6 +55,12 @@ Pod::Spec.new do |spec|
yoga.dependency 'Texture/Core' yoga.dependency 'Texture/Core'
end end
# If flag is enabled the old TextNode with all dependencies will be compiled out
spec.subspec 'TextNode2' do |text_node|
text_node.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) AS_ENABLE_TEXTNODE=0' }
text_node.dependency 'Texture/Core'
end
spec.subspec 'Video' do |video| spec.subspec 'Video' do |video|
video.frameworks = ['AVFoundation', 'CoreMedia'] video.frameworks = ['AVFoundation', 'CoreMedia']
video.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) AS_USE_VIDEO=1' } video.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) AS_USE_VIDEO=1' }