From f2bc63f05a443137463b1a5afbb7f9de20bd58af Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Fri, 23 Nov 2018 09:13:15 -0800 Subject: [PATCH] Add way to compile out ASTextNode + TextKit dependencies (#1242) * Add way to compile out ASTextNode + TextKit dependencies * Compile out ASExperimentalTextNode and fix tests --- Source/ASExperimentalFeatures.h | 3 +++ Source/ASTextNode.h | 10 ++++++++++ Source/ASTextNode.mm | 5 +++++ Source/ASTextNode2.h | 13 +++++++++++++ Source/ASTextNode2.mm | 8 ++++++++ Source/ASTextNodeCommon.h | 2 ++ Source/Base/ASAvailability.h | 4 ++++ Source/TextKit/ASTextKitAttributes.h | 7 +++++++ Source/TextKit/ASTextKitAttributes.mm | 4 ++++ Source/TextKit/ASTextKitComponents.h | 1 + Source/TextKit/ASTextKitContext.h | 7 +++++++ Source/TextKit/ASTextKitContext.mm | 5 +++++ Source/TextKit/ASTextKitCoreTextAdditions.h | 7 ++++++- Source/TextKit/ASTextKitCoreTextAdditions.mm | 4 ++++ Source/TextKit/ASTextKitEntityAttribute.h | 7 +++++++ Source/TextKit/ASTextKitEntityAttribute.mm | 4 ++++ Source/TextKit/ASTextKitFontSizeAdjuster.h | 8 +++++++- Source/TextKit/ASTextKitFontSizeAdjuster.mm | 4 ++++ Source/TextKit/ASTextKitRenderer+Positioning.h | 4 ++++ Source/TextKit/ASTextKitRenderer+Positioning.mm | 4 ++++ Source/TextKit/ASTextKitRenderer+TextChecking.h | 4 ++++ Source/TextKit/ASTextKitRenderer+TextChecking.mm | 4 ++++ Source/TextKit/ASTextKitRenderer.h | 10 ++++++++-- Source/TextKit/ASTextKitRenderer.mm | 4 ++++ Source/TextKit/ASTextKitShadower.h | 7 +++++++ Source/TextKit/ASTextKitShadower.mm | 4 ++++ Source/TextKit/ASTextKitTailTruncater.h | 5 ++++- Source/TextKit/ASTextKitTailTruncater.mm | 7 ++++++- Source/TextKit/ASTextKitTruncating.h | 9 +++++++++ Source/TextKit/ASTextNodeWordKerner.h | 1 + Tests/ASConfigurationTests.mm | 7 +++++++ Tests/ASTextKitCoreTextAdditionsTests.mm | 4 ++++ Tests/ASTextKitFontSizeAdjusterTests.mm | 4 ++++ Tests/ASTextKitTests.mm | 5 +++++ Tests/ASTextKitTruncationTests.mm | 5 +++++ Tests/ASTextNode2SnapshotTests.mm | 2 ++ Tests/ASTextNodeTests.mm | 3 +++ Texture.podspec | 6 ++++++ 38 files changed, 196 insertions(+), 6 deletions(-) diff --git a/Source/ASExperimentalFeatures.h b/Source/ASExperimentalFeatures.h index b51523e1d..482296450 100644 --- a/Source/ASExperimentalFeatures.h +++ b/Source/ASExperimentalFeatures.h @@ -7,6 +7,7 @@ // #import +#import #import NS_ASSUME_NONNULL_BEGIN @@ -16,7 +17,9 @@ NS_ASSUME_NONNULL_BEGIN */ typedef NS_OPTIONS(NSUInteger, ASExperimentalFeatures) { ASExperimentalGraphicsContexts = 1 << 0, // exp_graphics_contexts +#if AS_ENABLE_TEXTNODE ASExperimentalTextNode = 1 << 1, // exp_text_node +#endif ASExperimentalInterfaceStateCoalescing = 1 << 2, // exp_interface_state_coalesce ASExperimentalUnfairLock = 1 << 3, // exp_unfair_lock ASExperimentalLayerDefaults = 1 << 4, // exp_infer_layer_defaults diff --git a/Source/ASTextNode.h b/Source/ASTextNode.h index 1048017e7..e3830a155 100644 --- a/Source/ASTextNode.h +++ b/Source/ASTextNode.h @@ -8,9 +8,17 @@ // #import + #import #import +#if (!AS_ENABLE_TEXTNODE) + +// Pull in ASTextNode2 to replace ASTextNode with ASTextNode2 +#import + +#else + NS_ASSUME_NONNULL_BEGIN /** @@ -251,3 +259,5 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + +#endif diff --git a/Source/ASTextNode.mm b/Source/ASTextNode.mm index 1cf8489c8..15bf4bf1a 100644 --- a/Source/ASTextNode.mm +++ b/Source/ASTextNode.mm @@ -8,6 +8,9 @@ // #import + +#if AS_ENABLE_TEXTNODE + #import #import @@ -1427,3 +1430,5 @@ - (NSAttributedString *)truncationAttributedString } @end + +#endif diff --git a/Source/ASTextNode2.h b/Source/ASTextNode2.h index 442a47602..177751610 100644 --- a/Source/ASTextNode2.h +++ b/Source/ASTextNode2.h @@ -17,7 +17,11 @@ NS_ASSUME_NONNULL_BEGIN @abstract Draws interactive rich text. @discussion Backed by the code in TextExperiment folder, on top of CoreText. */ +#if AS_ENABLE_TEXTNODE @interface ASTextNode2 : ASControlNode +#else +@interface ASTextNode : ASControlNode +#endif /** @abstract The styled text displayed by the node. @@ -215,7 +219,11 @@ NS_ASSUME_NONNULL_BEGIN @end +#if AS_ENABLE_TEXTNODE @interface ASTextNode2 (Unavailable) +#else +@interface ASTextNode (Unavailable) +#endif - (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE; @@ -223,6 +231,11 @@ NS_ASSUME_NONNULL_BEGIN @end +#if (!AS_ENABLE_TEXTNODE) +// For the time beeing remap ASTextNode2 to ASTextNode +#define ASTextNode2 ASTextNode +#endif + NS_ASSUME_NONNULL_END diff --git a/Source/ASTextNode2.mm b/Source/ASTextNode2.mm index f3ec51fa3..a96f4f00f 100644 --- a/Source/ASTextNode2.mm +++ b/Source/ASTextNode2.mm @@ -141,11 +141,19 @@ @implementation ASTextCacheValue static const CGFloat ASTextNodeHighlightDarkOpacity = 0.22; static NSString *ASTextNodeTruncationTokenAttributeName = @"ASTextNodeTruncationAttribute"; +#if AS_ENABLE_TEXTNODE @interface ASTextNode2 () +#else +@interface ASTextNode () +#endif @end +#if AS_ENABLE_TEXTNODE @implementation ASTextNode2 { +#else +@implementation ASTextNode { +#endif ASTextContainer *_textContainer; CGSize _shadowOffset; diff --git a/Source/ASTextNodeCommon.h b/Source/ASTextNodeCommon.h index fbb32ca39..ab4e134bf 100644 --- a/Source/ASTextNodeCommon.h +++ b/Source/ASTextNodeCommon.h @@ -8,6 +8,8 @@ #import +#import + @class ASTextNode; #define AS_TEXT_ALERT_UNIMPLEMENTED_FEATURE() { \ diff --git a/Source/Base/ASAvailability.h b/Source/Base/ASAvailability.h index 6cb410859..76f3b2b93 100644 --- a/Source/Base/ASAvailability.h +++ b/Source/Base/ASAvailability.h @@ -17,6 +17,10 @@ #define AS_TLS_AVAILABLE 1 #endif +#ifndef AS_ENABLE_TEXTNODE + #define AS_ENABLE_TEXTNODE 1 // Enable old TextNode by default +#endif + // This needs to stay in sync with Weaver #ifndef AS_USE_VIDEO #define AS_USE_VIDEO 0 diff --git a/Source/TextKit/ASTextKitAttributes.h b/Source/TextKit/ASTextKitAttributes.h index 7f9fbd9b6..d8c21dbc2 100644 --- a/Source/TextKit/ASTextKitAttributes.h +++ b/Source/TextKit/ASTextKitAttributes.h @@ -10,6 +10,11 @@ #pragma once #import + +#import + +#if AS_ENABLE_TEXTNODE + #import AS_EXTERN NSString *const ASTextKitTruncationAttributeName; @@ -119,3 +124,5 @@ struct ASTextKitAttributes { size_t hash() const; }; + +#endif diff --git a/Source/TextKit/ASTextKitAttributes.mm b/Source/TextKit/ASTextKitAttributes.mm index 131771ab6..400ef437b 100644 --- a/Source/TextKit/ASTextKitAttributes.mm +++ b/Source/TextKit/ASTextKitAttributes.mm @@ -9,6 +9,8 @@ #import +#if AS_ENABLE_TEXTNODE + #import NSString *const ASTextKitTruncationAttributeName = @"ck_truncation"; @@ -44,3 +46,5 @@ }; return ASHashBytes(&data, sizeof(data)); } + +#endif diff --git a/Source/TextKit/ASTextKitComponents.h b/Source/TextKit/ASTextKitComponents.h index e5b516d1b..df89db203 100644 --- a/Source/TextKit/ASTextKitComponents.h +++ b/Source/TextKit/ASTextKitComponents.h @@ -8,6 +8,7 @@ // #import + #import NS_ASSUME_NONNULL_BEGIN diff --git a/Source/TextKit/ASTextKitContext.h b/Source/TextKit/ASTextKitContext.h index bed137434..82a40b7d8 100644 --- a/Source/TextKit/ASTextKitContext.h +++ b/Source/TextKit/ASTextKitContext.h @@ -8,6 +8,11 @@ // #import + +#import + +#if AS_ENABLE_TEXTNODE + #import /** @@ -44,3 +49,5 @@ AS_SUBCLASSING_RESTRICTED NSTextContainer *textContainer))block; @end + +#endif diff --git a/Source/TextKit/ASTextKitContext.mm b/Source/TextKit/ASTextKitContext.mm index fa0fb8834..d7f6d7b0b 100644 --- a/Source/TextKit/ASTextKitContext.mm +++ b/Source/TextKit/ASTextKitContext.mm @@ -8,6 +8,9 @@ // #import + +#if AS_ENABLE_TEXTNODE + #import #import @@ -73,3 +76,5 @@ - (void)performBlockWithLockedTextKitComponents:(NS_NOESCAPE void (^)(NSLayoutMa } @end + +#endif diff --git a/Source/TextKit/ASTextKitCoreTextAdditions.h b/Source/TextKit/ASTextKitCoreTextAdditions.h index 117a89ed3..9a8f48050 100644 --- a/Source/TextKit/ASTextKitCoreTextAdditions.h +++ b/Source/TextKit/ASTextKitCoreTextAdditions.h @@ -7,9 +7,12 @@ // Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0 // -#import #import +#import + +#if AS_ENABLE_TEXTNODE + #import NS_ASSUME_NONNULL_BEGIN @@ -82,3 +85,5 @@ AS_EXTERN NSAttributedString *ASCleanseAttributedStringOfCoreTextAttributes(NSAt @end NS_ASSUME_NONNULL_END + +#endif diff --git a/Source/TextKit/ASTextKitCoreTextAdditions.mm b/Source/TextKit/ASTextKitCoreTextAdditions.mm index 57a1a71e2..e98b236c5 100644 --- a/Source/TextKit/ASTextKitCoreTextAdditions.mm +++ b/Source/TextKit/ASTextKitCoreTextAdditions.mm @@ -9,6 +9,8 @@ #import +#if AS_ENABLE_TEXTNODE + #import #import @@ -333,3 +335,5 @@ + (NSParagraphStyle *)paragraphStyleWithCTParagraphStyle:(CTParagraphStyleRef)co } @end + +#endif diff --git a/Source/TextKit/ASTextKitEntityAttribute.h b/Source/TextKit/ASTextKitEntityAttribute.h index ddaf586a0..3655138be 100644 --- a/Source/TextKit/ASTextKitEntityAttribute.h +++ b/Source/TextKit/ASTextKitEntityAttribute.h @@ -8,6 +8,11 @@ // #import + +#import + +#if AS_ENABLE_TEXTNODE + #import /** @@ -27,3 +32,5 @@ AS_SUBCLASSING_RESTRICTED - (instancetype)initWithEntity:(id)entity; @end + +#endif diff --git a/Source/TextKit/ASTextKitEntityAttribute.mm b/Source/TextKit/ASTextKitEntityAttribute.mm index 4f460dfb7..fb87e9bd3 100644 --- a/Source/TextKit/ASTextKitEntityAttribute.mm +++ b/Source/TextKit/ASTextKitEntityAttribute.mm @@ -9,6 +9,8 @@ #import +#if AS_ENABLE_TEXTNODE + @implementation ASTextKitEntityAttribute - (instancetype)initWithEntity:(id)entity @@ -37,3 +39,5 @@ - (BOOL)isEqual:(id)object } @end + +#endif diff --git a/Source/TextKit/ASTextKitFontSizeAdjuster.h b/Source/TextKit/ASTextKitFontSizeAdjuster.h index ca2c2338d..1b7b10ff5 100644 --- a/Source/TextKit/ASTextKitFontSizeAdjuster.h +++ b/Source/TextKit/ASTextKitFontSizeAdjuster.h @@ -8,8 +8,12 @@ // #import + +#import + +#if AS_ENABLE_TEXTNODE + #import -#import NS_ASSUME_NONNULL_BEGIN @@ -50,3 +54,5 @@ AS_SUBCLASSING_RESTRICTED @end NS_ASSUME_NONNULL_END + +#endif diff --git a/Source/TextKit/ASTextKitFontSizeAdjuster.mm b/Source/TextKit/ASTextKitFontSizeAdjuster.mm index 1f4a397ac..fed70c6a4 100644 --- a/Source/TextKit/ASTextKitFontSizeAdjuster.mm +++ b/Source/TextKit/ASTextKitFontSizeAdjuster.mm @@ -10,6 +10,8 @@ #import +#if AS_ENABLE_TEXTNODE + #import #import @@ -235,3 +237,5 @@ - (CGFloat)scaleFactor } @end + +#endif diff --git a/Source/TextKit/ASTextKitRenderer+Positioning.h b/Source/TextKit/ASTextKitRenderer+Positioning.h index ebcf22967..c88728256 100644 --- a/Source/TextKit/ASTextKitRenderer+Positioning.h +++ b/Source/TextKit/ASTextKitRenderer+Positioning.h @@ -9,6 +9,8 @@ #import +#if AS_ENABLE_TEXTNODE + typedef void (^as_text_component_index_block_t)(NSUInteger characterIndex, CGRect glyphBoundingRect, BOOL *stop); @@ -100,3 +102,5 @@ typedef NS_ENUM(NSUInteger, ASTextKitRendererMeasureOption) { - (CGRect)trailingRect; @end + +#endif diff --git a/Source/TextKit/ASTextKitRenderer+Positioning.mm b/Source/TextKit/ASTextKitRenderer+Positioning.mm index a97e189b4..9dc770e1d 100644 --- a/Source/TextKit/ASTextKitRenderer+Positioning.mm +++ b/Source/TextKit/ASTextKitRenderer+Positioning.mm @@ -9,6 +9,8 @@ #import +#if AS_ENABLE_TEXTNODE + #import #import @@ -380,3 +382,5 @@ - (CGRect)frameForTextRange:(NSRange)textRange } @end + +#endif diff --git a/Source/TextKit/ASTextKitRenderer+TextChecking.h b/Source/TextKit/ASTextKitRenderer+TextChecking.h index b1d1cab8c..d4ba74fd3 100644 --- a/Source/TextKit/ASTextKitRenderer+TextChecking.h +++ b/Source/TextKit/ASTextKitRenderer+TextChecking.h @@ -9,6 +9,8 @@ #import +#if AS_ENABLE_TEXTNODE + /** 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; @end + +#endif diff --git a/Source/TextKit/ASTextKitRenderer+TextChecking.mm b/Source/TextKit/ASTextKitRenderer+TextChecking.mm index 527f82af2..e55639357 100644 --- a/Source/TextKit/ASTextKitRenderer+TextChecking.mm +++ b/Source/TextKit/ASTextKitRenderer+TextChecking.mm @@ -9,6 +9,8 @@ #import +#if AS_ENABLE_TEXTNODE + #import #import #import @@ -98,3 +100,5 @@ - (NSTextCheckingResult *)textCheckingResultAtPoint:(CGPoint)point } @end + +#endif diff --git a/Source/TextKit/ASTextKitRenderer.h b/Source/TextKit/ASTextKitRenderer.h index e6ea9eefa..0f0cc00e0 100644 --- a/Source/TextKit/ASTextKitRenderer.h +++ b/Source/TextKit/ASTextKitRenderer.h @@ -7,12 +7,16 @@ // Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0 // -#import - #import +#import + +#if AS_ENABLE_TEXTNODE + #import +#import + @class ASTextKitContext; @class ASTextKitShadower; @class ASTextKitFontSizeAdjuster; @@ -100,3 +104,5 @@ @property (nonatomic, readonly) NSRange firstVisibleRange; @end + +#endif diff --git a/Source/TextKit/ASTextKitRenderer.mm b/Source/TextKit/ASTextKitRenderer.mm index 6774dab9a..b724d7074 100644 --- a/Source/TextKit/ASTextKitRenderer.mm +++ b/Source/TextKit/ASTextKitRenderer.mm @@ -9,6 +9,8 @@ #import +#if AS_ENABLE_TEXTNODE + #import #import @@ -289,3 +291,5 @@ - (NSRange)firstVisibleRange } @end + +#endif diff --git a/Source/TextKit/ASTextKitShadower.h b/Source/TextKit/ASTextKitShadower.h index 1bec5aff8..2f9c604fb 100644 --- a/Source/TextKit/ASTextKitShadower.h +++ b/Source/TextKit/ASTextKitShadower.h @@ -8,6 +8,11 @@ // #import + +#import + +#if AS_ENABLE_TEXTNODE + #import /** @@ -69,3 +74,5 @@ AS_SUBCLASSING_RESTRICTED - (void)setShadowInContext:(CGContextRef)context; @end + +#endif diff --git a/Source/TextKit/ASTextKitShadower.mm b/Source/TextKit/ASTextKitShadower.mm index 714d93a0e..a2f37f7e0 100644 --- a/Source/TextKit/ASTextKitShadower.mm +++ b/Source/TextKit/ASTextKitShadower.mm @@ -9,6 +9,8 @@ #import +#if AS_ENABLE_TEXTNODE + #import static inline CGSize _insetSize(CGSize size, UIEdgeInsets insets) @@ -171,3 +173,5 @@ - (CGPoint)offsetPointWithExternalPoint:(CGPoint)externalPoint } @end + +#endif diff --git a/Source/TextKit/ASTextKitTailTruncater.h b/Source/TextKit/ASTextKitTailTruncater.h index 027a27e40..70734d9e2 100644 --- a/Source/TextKit/ASTextKitTailTruncater.h +++ b/Source/TextKit/ASTextKitTailTruncater.h @@ -9,10 +9,13 @@ #import -#import #import +#if AS_ENABLE_TEXTNODE + AS_SUBCLASSING_RESTRICTED @interface ASTextKitTailTruncater : NSObject @end + +#endif diff --git a/Source/TextKit/ASTextKitTailTruncater.mm b/Source/TextKit/ASTextKitTailTruncater.mm index 353869346..b81e27be0 100644 --- a/Source/TextKit/ASTextKitTailTruncater.mm +++ b/Source/TextKit/ASTextKitTailTruncater.mm @@ -7,9 +7,12 @@ // Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0 // -#import #import +#if AS_ENABLE_TEXTNODE + +#import + @implementation ASTextKitTailTruncater { __weak ASTextKitContext *_context; @@ -189,3 +192,5 @@ - (NSRange)firstVisibleRange } @end + +#endif diff --git a/Source/TextKit/ASTextKitTruncating.h b/Source/TextKit/ASTextKitTruncating.h index 8374f37b1..35392fd6b 100644 --- a/Source/TextKit/ASTextKitTruncating.h +++ b/Source/TextKit/ASTextKitTruncating.h @@ -8,6 +8,13 @@ // #import + +#import + +#if AS_ENABLE_TEXTNODE + +#import + #import NS_ASSUME_NONNULL_BEGIN @@ -50,3 +57,5 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + +#endif diff --git a/Source/TextKit/ASTextNodeWordKerner.h b/Source/TextKit/ASTextNodeWordKerner.h index 855cddbd5..795c4ea09 100644 --- a/Source/TextKit/ASTextNodeWordKerner.h +++ b/Source/TextKit/ASTextNodeWordKerner.h @@ -9,6 +9,7 @@ #import #import + #import NS_ASSUME_NONNULL_BEGIN diff --git a/Tests/ASConfigurationTests.mm b/Tests/ASConfigurationTests.mm index a563b9204..6358ad49a 100644 --- a/Tests/ASConfigurationTests.mm +++ b/Tests/ASConfigurationTests.mm @@ -8,13 +8,16 @@ #import #import "ASTestCase.h" +#import "ASAvailability.h" #import "ASConfiguration.h" #import "ASConfigurationDelegate.h" #import "ASConfigurationInternal.h" static ASExperimentalFeatures features[] = { ASExperimentalGraphicsContexts, +#if AS_ENABLE_TEXTNODE ASExperimentalTextNode, +#endif ASExperimentalInterfaceStateCoalescing, ASExperimentalUnfairLock, ASExperimentalLayerDefaults, @@ -56,6 +59,8 @@ - (ASExperimentalFeatures)allFeatures { return allFeatures; } +#if AS_ENABLE_TEXTNODE + - (void)testExperimentalFeatureConfig { // Set the config @@ -81,6 +86,8 @@ - (void)testExperimentalFeatureConfig [self waitForExpectationsWithTimeout:3 handler:nil]; } +#endif + - (void)textureDidActivateExperimentalFeatures:(ASExperimentalFeatures)feature { if (onActivate) { diff --git a/Tests/ASTextKitCoreTextAdditionsTests.mm b/Tests/ASTextKitCoreTextAdditionsTests.mm index 09114a4ad..8b0c47be8 100644 --- a/Tests/ASTextKitCoreTextAdditionsTests.mm +++ b/Tests/ASTextKitCoreTextAdditionsTests.mm @@ -13,6 +13,8 @@ #import +#if AS_ENABLE_TEXTNODE + BOOL floatsCloseEnough(CGFloat float1, CGFloat float2) { CGFloat epsilon = 0.00001; return (fabs(float1 - float2) < epsilon); @@ -68,3 +70,5 @@ - (void)testNSParagraphStyleNoCleansing } @end + +#endif diff --git a/Tests/ASTextKitFontSizeAdjusterTests.mm b/Tests/ASTextKitFontSizeAdjusterTests.mm index 2f9cc0157..c91ff99a4 100644 --- a/Tests/ASTextKitFontSizeAdjusterTests.mm +++ b/Tests/ASTextKitFontSizeAdjusterTests.mm @@ -9,6 +9,8 @@ #import #import +#if AS_ENABLE_TEXTNODE + @interface ASFontSizeAdjusterTests : XCTestCase @end @@ -45,3 +47,5 @@ - (void)testFontSizeAdjusterAttributes } @end + +#endif diff --git a/Tests/ASTextKitTests.mm b/Tests/ASTextKitTests.mm index 1d765efe4..0d807824e 100644 --- a/Tests/ASTextKitTests.mm +++ b/Tests/ASTextKitTests.mm @@ -13,6 +13,9 @@ #import #import + +#if AS_ENABLE_TEXTNODE + #import #import #import @@ -221,3 +224,5 @@ - (void)testTextKitComponentsCanCalculateSizeInBackground } @end + +#endif diff --git a/Tests/ASTextKitTruncationTests.mm b/Tests/ASTextKitTruncationTests.mm index 647c31867..a9d5544c3 100644 --- a/Tests/ASTextKitTruncationTests.mm +++ b/Tests/ASTextKitTruncationTests.mm @@ -11,6 +11,9 @@ #import #import + +#if AS_ENABLE_TEXTNODE + #import @interface ASTextKitTruncationTests : XCTestCase @@ -158,3 +161,5 @@ - (void)testHandleZeroHeightConstrainedSize } @end + +#endif diff --git a/Tests/ASTextNode2SnapshotTests.mm b/Tests/ASTextNode2SnapshotTests.mm index 579ad067c..27073f09b 100644 --- a/Tests/ASTextNode2SnapshotTests.mm +++ b/Tests/ASTextNode2SnapshotTests.mm @@ -24,7 +24,9 @@ - (void)setUp // This will use ASTextNode2 for snapshot tests. // All tests are duplicated from ASTextNodeSnapshotTests. ASConfiguration *config = [[ASConfiguration alloc] initWithDictionary:nil]; +#if AS_ENABLE_TEXTNODE config.experimentalFeatures = ASExperimentalTextNode; +#endif [ASConfigurationManager test_resetWithConfiguration:config]; self.recordMode = NO; diff --git a/Tests/ASTextNodeTests.mm b/Tests/ASTextNodeTests.mm index 5b23270b5..0dc5137a6 100644 --- a/Tests/ASTextNodeTests.mm +++ b/Tests/ASTextNodeTests.mm @@ -13,6 +13,7 @@ #import +#import #import #import @@ -235,6 +236,7 @@ - (void)testAddingExclusionPathsShouldInvalidateAndIncreaseTheSize XCTAssertGreaterThan(sizeWithExclusionPaths.height, sizeWithoutExclusionPaths.height, @"Setting exclusions paths should invalidate the calculated size and return a greater size"); } +#if AS_ENABLE_TEXTNODE - (void)testThatTheExperimentWorksCorrectly { ASConfiguration *config = [ASConfiguration new]; @@ -303,6 +305,7 @@ - (void)testTextNodeSwitchWorksInMultiThreadEnvironment2 exp = nil; [textNodeBucket removeAllObjects]; } +#endif @end diff --git a/Texture.podspec b/Texture.podspec index a56a8dde0..8956e3984 100644 --- a/Texture.podspec +++ b/Texture.podspec @@ -54,6 +54,12 @@ Pod::Spec.new do |spec| yoga.dependency 'Yoga', '1.6.0' yoga.dependency 'Texture/Core' 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| video.frameworks = ['AVFoundation', 'CoreMedia']