From 87758a11ef1baf23f96b577797a704480ff9d036 Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Mon, 25 Nov 2024 14:19:30 +0900 Subject: [PATCH 01/17] Add some @MainActor annotations --- Package.swift | 6 +++--- Source/ASDisplayNode+Subclasses.h | 18 +++++++++++------- Source/ASDisplayNode.h | 12 ++++++------ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Package.swift b/Package.swift index 358a30cab..d602da36f 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -42,8 +42,8 @@ let package = Package( name: "Texture", platforms: [ .macOS(.v10_15), - .iOS(.v10), - .tvOS(.v10), + .iOS(.v12), + .tvOS(.v12), ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/Source/ASDisplayNode+Subclasses.h b/Source/ASDisplayNode+Subclasses.h index 3f4a59b30..8a50e38a9 100644 --- a/Source/ASDisplayNode+Subclasses.h +++ b/Source/ASDisplayNode+Subclasses.h @@ -71,7 +71,7 @@ NS_ASSUME_NONNULL_BEGIN * @discussion This is the best time to add gesture recognizers to the view. */ AS_CATEGORY_IMPLEMENTABLE -- (void)didLoad ASDISPLAYNODE_REQUIRES_SUPER; +- (void)didLoad ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR; /** * An empty method that you can implement in a category to add global @@ -95,7 +95,7 @@ AS_CATEGORY_IMPLEMENTABLE * * @discussion Subclasses override this method to layout all subnodes or subviews. */ -- (void)layout ASDISPLAYNODE_REQUIRES_SUPER; +- (void)layout ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR; /** * @abstract Called on the main thread by the view's -layoutSubviews, after -layout. @@ -104,7 +104,8 @@ AS_CATEGORY_IMPLEMENTABLE * out. */ AS_CATEGORY_IMPLEMENTABLE -- (void)layoutDidFinish ASDISPLAYNODE_REQUIRES_SUPER; + +- (void)layoutDidFinish ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR; /** * @abstract Called on a background thread if !isNodeLoaded - called on the main thread if isNodeLoaded. @@ -255,7 +256,8 @@ AS_CATEGORY_IMPLEMENTABLE * * @note Called on the main thread only */ -- (nullable id)drawParametersForAsyncLayer:(_ASDisplayLayer *)layer; + +- (nullable id)drawParametersForAsyncLayer:(_ASDisplayLayer *)layer NS_SWIFT_UI_ACTOR; /** * @abstract Indicates that the receiver is about to display. @@ -267,7 +269,8 @@ AS_CATEGORY_IMPLEMENTABLE * * @note Called on the main thread only */ -- (void)displayWillStart ASDISPLAYNODE_REQUIRES_SUPER ASDISPLAYNODE_DEPRECATED_MSG("Use displayWillStartAsynchronously: instead."); + +- (void)displayWillStart ASDISPLAYNODE_REQUIRES_SUPER ASDISPLAYNODE_DEPRECATED_MSG("Use displayWillStartAsynchronously: instead.") NS_SWIFT_UI_ACTOR; /** * @abstract Indicates that the receiver is about to display. @@ -277,7 +280,8 @@ AS_CATEGORY_IMPLEMENTABLE * * @note Called on the main thread only */ -- (void)displayWillStartAsynchronously:(BOOL)asynchronously ASDISPLAYNODE_REQUIRES_SUPER; + +- (void)displayWillStartAsynchronously:(BOOL)asynchronously ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR; /** * @abstract Indicates that the receiver has finished displaying. @@ -317,7 +321,7 @@ AS_CATEGORY_IMPLEMENTABLE * @discussion Called by -recursivelyClearContents. Always called on main thread. Base class implements self.contents = nil, clearing any backing * store, for asynchronous regeneration when needed. */ -- (void)clearContents ASDISPLAYNODE_REQUIRES_SUPER; +- (void)clearContents ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR; /** * @abstract Indicates that the receiver is about to display its subnodes. This method is not called if there are no diff --git a/Source/ASDisplayNode.h b/Source/ASDisplayNode.h index 443f633c1..62e79a311 100644 --- a/Source/ASDisplayNode.h +++ b/Source/ASDisplayNode.h @@ -49,7 +49,7 @@ typedef CALayer * _Nonnull(^ASDisplayNodeLayerBlock)(void); /** * ASDisplayNode loaded callback block. This block is called BEFORE the -didLoad method and is always called on the main thread. */ -typedef void (^ASDisplayNodeDidLoadBlock)(__kindof ASDisplayNode * node); +typedef NS_SWIFT_UI_ACTOR void (^ASDisplayNodeDidLoadBlock)(__kindof ASDisplayNode * node); /** * ASDisplayNode will / did render node content in context. @@ -209,7 +209,7 @@ ASDK_EXTERN NSInteger const ASDefaultDrawingPriority; * @warning The first access to it must be on the main thread, and should only be used on the main thread thereafter as * well. */ -@property (readonly) UIView *view; +@property (readonly) NS_SWIFT_UI_ACTOR UIView *view; /** * @abstract Returns whether a node's backing view or layer is loaded. @@ -234,7 +234,7 @@ ASDK_EXTERN NSInteger const ASDefaultDrawingPriority; * @warning The first access to it must be on the main thread, and should only be used on the main thread thereafter as * well. */ -@property (readonly) CALayer * layer; +@property (readonly) NS_SWIFT_UI_ACTOR CALayer * layer; /** * Returns YES if the node is – at least partially – visible in a window. @@ -275,7 +275,7 @@ ASDK_EXTERN NSInteger const ASDefaultDrawingPriority; * * @see ASInterfaceState */ -- (void)addInterfaceStateDelegate:(id )interfaceStateDelegate; +- (NS_SWIFT_UI_ACTOR void)addInterfaceStateDelegate:(id )interfaceStateDelegate; /** * @abstract Removes a delegate from receiving notifications on interfaceState changes. @@ -284,7 +284,7 @@ ASDK_EXTERN NSInteger const ASDefaultDrawingPriority; * * @see ASInterfaceState */ -- (void)removeInterfaceStateDelegate:(id )interfaceStateDelegate; +- (NS_SWIFT_UI_ACTOR void)removeInterfaceStateDelegate:(id )interfaceStateDelegate; /** * @abstract Class property that allows to set a block that can be called on non-fatal errors. This @@ -917,7 +917,7 @@ typedef NS_ENUM(NSInteger, ASLayoutEngineType) { * @see animateLayoutTransition: * */ -- (void)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize +- (NS_SWIFT_UI_ACTOR void)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize animated:(BOOL)animated shouldMeasureAsync:(BOOL)shouldMeasureAsync measurementCompletion:(nullable void(^)(void))completion; From 559e7dbbbe3c541280d9bde98ebaf4f97008969b Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Mon, 25 Nov 2024 15:03:01 +0900 Subject: [PATCH 02/17] Sending --- Source/Layout/ASLayoutSpec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Layout/ASLayoutSpec.h b/Source/Layout/ASLayoutSpec.h index fbcd71961..d2e91d35f 100644 --- a/Source/Layout/ASLayoutSpec.h +++ b/Source/Layout/ASLayoutSpec.h @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A layout spec is an immutable object that describes a layout, loosely inspired by React. */ -@interface ASLayoutSpec : NSObject +@interface ASLayoutSpec : NSObject NS_SWIFT_SENDING /** * Creation of a layout spec should only happen by a user in layoutSpecThatFits:. During that method, a From a5067a5da07f897280dc52f9b7cb6d7ece2d84ff Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Mon, 25 Nov 2024 15:12:32 +0900 Subject: [PATCH 03/17] Sendable --- Source/Layout/ASLayoutSpec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Layout/ASLayoutSpec.h b/Source/Layout/ASLayoutSpec.h index d2e91d35f..a30244bdd 100644 --- a/Source/Layout/ASLayoutSpec.h +++ b/Source/Layout/ASLayoutSpec.h @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A layout spec is an immutable object that describes a layout, loosely inspired by React. */ -@interface ASLayoutSpec : NSObject NS_SWIFT_SENDING +NS_SWIFT_SENDING @interface ASLayoutSpec : NSObject /** * Creation of a layout spec should only happen by a user in layoutSpecThatFits:. During that method, a From 65150f0d3b529a2b31a373e5f8fd1ae8f4450efd Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Mon, 25 Nov 2024 15:25:57 +0900 Subject: [PATCH 04/17] Update : MainActor --- Source/ASDisplayNode.h | 6 +++--- Source/UIResponder+AsyncDisplayKit.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/ASDisplayNode.h b/Source/ASDisplayNode.h index 62e79a311..29ff95da2 100644 --- a/Source/ASDisplayNode.h +++ b/Source/ASDisplayNode.h @@ -764,7 +764,7 @@ ASDK_EXTERN NSInteger const ASDefaultDrawingPriority; */ @property (readonly) UIEdgeInsets safeAreaInsets; @property BOOL insetsLayoutMarginsFromSafeArea; // Default: YES -- (void)safeAreaInsetsDidChange; +- (void)safeAreaInsetsDidChange NS_SWIFT_UI_ACTOR; // UIResponder methods @@ -917,10 +917,10 @@ typedef NS_ENUM(NSInteger, ASLayoutEngineType) { * @see animateLayoutTransition: * */ -- (NS_SWIFT_UI_ACTOR void)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize +- (void)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize animated:(BOOL)animated shouldMeasureAsync:(BOOL)shouldMeasureAsync - measurementCompletion:(nullable void(^)(void))completion; + measurementCompletion:(nullable void(^)(void))completion NS_SWIFT_UI_ACTOR; /** diff --git a/Source/UIResponder+AsyncDisplayKit.h b/Source/UIResponder+AsyncDisplayKit.h index 17afab3ae..573d5e192 100644 --- a/Source/UIResponder+AsyncDisplayKit.h +++ b/Source/UIResponder+AsyncDisplayKit.h @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN * * This property must be accessed on the main thread. */ -@property (nonatomic, nullable, readonly) __kindof UIViewController *asdk_associatedViewController; +@property (nonatomic, nullable, readonly) NS_SWIFT_UI_ACTOR __kindof UIViewController *asdk_associatedViewController; @end From 7d59b6a76cf58403ba6e4a7e9444b79e5e0f0f93 Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Mon, 25 Nov 2024 15:30:38 +0900 Subject: [PATCH 05/17] Main Actor --- Source/ASDisplayNode+Subclasses.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/ASDisplayNode+Subclasses.h b/Source/ASDisplayNode+Subclasses.h index 8a50e38a9..f8d598029 100644 --- a/Source/ASDisplayNode+Subclasses.h +++ b/Source/ASDisplayNode+Subclasses.h @@ -400,7 +400,7 @@ AS_CATEGORY_IMPLEMENTABLE * @param touches A set of UITouch instances. * @param event A UIEvent associated with the touch. */ -- (void)touchesBegan:(NSSet *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER; +- (void)touchesBegan:(NSSet *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR; /** * @abstract Tells the node when touches moved in its view. @@ -408,7 +408,7 @@ AS_CATEGORY_IMPLEMENTABLE * @param touches A set of UITouch instances. * @param event A UIEvent associated with the touch. */ -- (void)touchesMoved:(NSSet *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER; +- (void)touchesMoved:(NSSet *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR; /** * @abstract Tells the node when touches ended in its view. @@ -416,7 +416,7 @@ AS_CATEGORY_IMPLEMENTABLE * @param touches A set of UITouch instances. * @param event A UIEvent associated with the touch. */ -- (void)touchesEnded:(NSSet *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER; +- (void)touchesEnded:(NSSet *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR; /** * @abstract Tells the node when touches was cancelled in its view. @@ -424,7 +424,7 @@ AS_CATEGORY_IMPLEMENTABLE * @param touches A set of UITouch instances. * @param event A UIEvent associated with the touch. */ -- (void)touchesCancelled:(nullable NSSet *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER; +- (void)touchesCancelled:(nullable NSSet *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR; #pragma mark - Managing Gesture Recognizers @@ -455,7 +455,7 @@ AS_CATEGORY_IMPLEMENTABLE * 1) allows sending events to plain UIViews that don't have attached nodes, * 2) hitTest: is never called before the views are created. */ -- (nullable UIView *)hitTest:(CGPoint)point withEvent:(nullable UIEvent *)event; +- (nullable UIView *)hitTest:(CGPoint)point withEvent:(nullable UIEvent *)event NS_SWIFT_UI_ACTOR; #pragma mark - Placeholders From 571123961547241d2432d0f2b4ae47bd333e1c88 Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Mon, 25 Nov 2024 15:33:21 +0900 Subject: [PATCH 06/17] Update --- Source/ASControlNode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ASControlNode.h b/Source/ASControlNode.h index 9506c41d0..0e3c02fbc 100644 --- a/Source/ASControlNode.h +++ b/Source/ASControlNode.h @@ -74,7 +74,7 @@ static UIControlState const ASControlStateSelected ASDISPLAYNODE_DEPRECATED_MSG( @abstract Indicates whether or not the receiver is highlighted. @discussion This is set automatically when the there is a touch inside the control and removed on exit or touch up. This is different from touchInside in that it includes an area around the control, rather than just for touches inside the control. */ -@property (getter=isHighlighted) BOOL highlighted; +@property (getter=isHighlighted) NS_SWIFT_UI_ACTOR BOOL highlighted; /** @abstract Indicates whether or not the receiver is highlighted. From 59e59a242b9e37d44462ddcedc9e4bd567f529cb Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Mon, 25 Nov 2024 15:38:57 +0900 Subject: [PATCH 07/17] Update --- Source/Layout/ASLayoutSpec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Layout/ASLayoutSpec.h b/Source/Layout/ASLayoutSpec.h index a30244bdd..1d81da3f3 100644 --- a/Source/Layout/ASLayoutSpec.h +++ b/Source/Layout/ASLayoutSpec.h @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A layout spec is an immutable object that describes a layout, loosely inspired by React. */ -NS_SWIFT_SENDING @interface ASLayoutSpec : NSObject +NS_SWIFT_SENDABLE @interface ASLayoutSpec : NSObject /** * Creation of a layout spec should only happen by a user in layoutSpecThatFits:. During that method, a From fc8ddb0082ec142cda9ec1d23af3dc260f7ac2b0 Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Mon, 25 Nov 2024 15:42:36 +0900 Subject: [PATCH 08/17] Update --- Source/ASCellNode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ASCellNode.h b/Source/ASCellNode.h index 8328e59b4..a0ae182b7 100644 --- a/Source/ASCellNode.h +++ b/Source/ASCellNode.h @@ -100,7 +100,7 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) { * A Boolean value that is synchronized with the underlying collection or tableView cell property. * Setting this value is equivalent to calling highlightItem / unHighlightItem on the collection or table. */ -@property (getter=isHighlighted) BOOL highlighted; +@property (getter=isHighlighted) NS_SWIFT_UI_ACTOR BOOL highlighted; /** * The current index path of this cell node, or @c nil if this node is From 56c8a1c6fb8cf4102bf9954a27a1901c3e238673 Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Mon, 25 Nov 2024 15:51:01 +0900 Subject: [PATCH 09/17] Update --- Source/ASDisplayNode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ASDisplayNode.h b/Source/ASDisplayNode.h index 29ff95da2..8ea3fc952 100644 --- a/Source/ASDisplayNode.h +++ b/Source/ASDisplayNode.h @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN /** * UIView creation block. Used to create the backing view of a new display node. */ -typedef UIView * _Nonnull(^ASDisplayNodeViewBlock)(void); +typedef NS_SWIFT_UI_ACTOR UIView * _Nonnull(^ASDisplayNodeViewBlock)(void); /** * UIView creation block. Used to create the backing view of a new display node. From 0ec1d4f6d5cfd00bbd14413258dc649ded41c891 Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Mon, 25 Nov 2024 15:56:08 +0900 Subject: [PATCH 10/17] Update --- Source/ASDisplayNode.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ASDisplayNode.h b/Source/ASDisplayNode.h index 8ea3fc952..0ff83b71f 100644 --- a/Source/ASDisplayNode.h +++ b/Source/ASDisplayNode.h @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN /** * UIView creation block. Used to create the backing view of a new display node. */ -typedef NS_SWIFT_UI_ACTOR UIView * _Nonnull(^ASDisplayNodeViewBlock)(void); +typedef UIView * _Nonnull(NS_SWIFT_UI_ACTOR ^ASDisplayNodeViewBlock)(void); /** * UIView creation block. Used to create the backing view of a new display node. @@ -49,7 +49,7 @@ typedef CALayer * _Nonnull(^ASDisplayNodeLayerBlock)(void); /** * ASDisplayNode loaded callback block. This block is called BEFORE the -didLoad method and is always called on the main thread. */ -typedef NS_SWIFT_UI_ACTOR void (^ASDisplayNodeDidLoadBlock)(__kindof ASDisplayNode * node); +typedef void (NS_SWIFT_UI_ACTOR ^ASDisplayNodeDidLoadBlock)(__kindof ASDisplayNode * node); /** * ASDisplayNode will / did render node content in context. From 54e9e1a1d5e2281fe2c0ae784b378a236eb32195 Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Mon, 25 Nov 2024 16:54:08 +0900 Subject: [PATCH 11/17] Update --- Source/ASCellNode.h | 2 +- Source/ASDisplayNode.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ASCellNode.h b/Source/ASCellNode.h index a0ae182b7..88097c940 100644 --- a/Source/ASCellNode.h +++ b/Source/ASCellNode.h @@ -49,7 +49,7 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) { * calling `-setNeedsLayout` will also notify the collection on the main thread * so that the collection can update its item layout if the cell's size changed. */ -@interface ASCellNode : ASDisplayNode +@interface ASCellNode : ASDisplayNode, NS_SWIFT_SENDABLE /** * @abstract When enabled, ensures that the cell is completely displayed before allowed onscreen. diff --git a/Source/ASDisplayNode.h b/Source/ASDisplayNode.h index 0ff83b71f..ff07fbd9d 100644 --- a/Source/ASDisplayNode.h +++ b/Source/ASDisplayNode.h @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN /** * UIView creation block. Used to create the backing view of a new display node. */ -typedef UIView * _Nonnull(NS_SWIFT_UI_ACTOR ^ASDisplayNodeViewBlock)(void); +typedef NS_SWIFT_UI_ACTOR UIView * _Nonnull(NS_SWIFT_UI_ACTOR ^ASDisplayNodeViewBlock) (void); /** * UIView creation block. Used to create the backing view of a new display node. From 2a8c4b9ca4591229e0017c06083165cd1d3242ab Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Mon, 25 Nov 2024 16:55:52 +0900 Subject: [PATCH 12/17] Update --- Source/ASCellNode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ASCellNode.h b/Source/ASCellNode.h index 88097c940..79f20019a 100644 --- a/Source/ASCellNode.h +++ b/Source/ASCellNode.h @@ -49,7 +49,7 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) { * calling `-setNeedsLayout` will also notify the collection on the main thread * so that the collection can update its item layout if the cell's size changed. */ -@interface ASCellNode : ASDisplayNode, NS_SWIFT_SENDABLE +NS_SWIFT_SENDABLE @interface ASCellNode : ASDisplayNode /** * @abstract When enabled, ensures that the cell is completely displayed before allowed onscreen. From 5bd706009aeee6711656cc993fdb60131c4d04f0 Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Wed, 27 Nov 2024 13:31:29 +0900 Subject: [PATCH 13/17] Workaround for typdef not forwarding main actor isolation --- Source/ASDisplayNode.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ASDisplayNode.h b/Source/ASDisplayNode.h index ff07fbd9d..b8007848f 100644 --- a/Source/ASDisplayNode.h +++ b/Source/ASDisplayNode.h @@ -167,7 +167,7 @@ ASDK_EXTERN NSInteger const ASDefaultDrawingPriority; * * @precondition The node is not already loaded. */ -- (void)onDidLoad:(ASDisplayNodeDidLoadBlock)body; +- (void)onDidLoad:(NS_SWIFT_UI_ACTOR ASDisplayNodeDidLoadBlock)body; /** * Set the block that should be used to load this node's view. @@ -178,7 +178,7 @@ ASDK_EXTERN NSInteger const ASDefaultDrawingPriority; * * @note You will usually NOT call this. See the limitations documented in @c initWithViewBlock: */ -- (void)setViewBlock:(ASDisplayNodeViewBlock)viewBlock; +- (void)setViewBlock:(NS_SWIFT_UI_ACTOR ASDisplayNodeViewBlock)viewBlock; /** * Set the block that should be used to load this node's layer. From 9ca10a413b5677b58a276d94c7c745621c255b99 Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Wed, 27 Nov 2024 18:56:50 +0900 Subject: [PATCH 14/17] Add more main thread declarations --- Source/ASDisplayNode+Convenience.h | 2 +- Source/ASDisplayNode+InterfaceState.h | 22 +++++++++++----------- Source/ASDisplayNode+Subclasses.h | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Source/ASDisplayNode+Convenience.h b/Source/ASDisplayNode+Convenience.h index 7c8d6d59b..341dbc44e 100644 --- a/Source/ASDisplayNode+Convenience.h +++ b/Source/ASDisplayNode+Convenience.h @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN * @warning This property may only be accessed on the main thread. This property may * be @c nil until the node's view is actually hosted in the view hierarchy. */ -@property (nonatomic, nullable, readonly) __kindof UIViewController *closestViewController; +@property (nonatomic, nullable, readonly) NS_SWIFT_UI_ACTOR __kindof UIViewController *closestViewController; @end diff --git a/Source/ASDisplayNode+InterfaceState.h b/Source/ASDisplayNode+InterfaceState.h index 96ff70322..f994cc9c9 100644 --- a/Source/ASDisplayNode+InterfaceState.h +++ b/Source/ASDisplayNode+InterfaceState.h @@ -53,56 +53,56 @@ typedef NS_OPTIONS(unsigned char, ASInterfaceState) * @discussion Subclasses may use this to monitor when they become visible. * @note This method is guaranteed to be called on main. */ -- (void)didEnterVisibleState; +- (void)didEnterVisibleState NS_SWIFT_UI_ACTOR; /** * @abstract Called whenever the node is no longer visible. * @discussion Subclasses may use this to monitor when they are no longer visible. * @note This method is guaranteed to be called on main. */ -- (void)didExitVisibleState; +- (void)didExitVisibleState NS_SWIFT_UI_ACTOR; /** * @abstract Called whenever the the node has entered the display state. * @discussion Subclasses may use this to monitor when a node should be rendering its content. * @note This method is guaranteed to be called on main. */ -- (void)didEnterDisplayState; +- (void)didEnterDisplayState NS_SWIFT_UI_ACTOR; /** * @abstract Called whenever the the node has exited the display state. * @discussion Subclasses may use this to monitor when a node should no longer be rendering its content. * @note This method is guaranteed to be called on main. */ -- (void)didExitDisplayState; +- (void)didExitDisplayState NS_SWIFT_UI_ACTOR; /** * @abstract Called whenever the the node has entered the preload state. * @discussion Subclasses may use this to monitor data for a node should be preloaded, either from a local or remote source. * @note This method is guaranteed to be called on main. */ -- (void)didEnterPreloadState; +- (void)didEnterPreloadState NS_SWIFT_UI_ACTOR; /** * @abstract Called whenever the the node has exited the preload state. * @discussion Subclasses may use this to monitor whether preloading data for a node should be canceled. * @note This method is guaranteed to be called on main. */ -- (void)didExitPreloadState; +- (void)didExitPreloadState NS_SWIFT_UI_ACTOR; /** * @abstract Called when the node has completed applying the layout. * @discussion Can be used for operations that are performed after layout has completed. * @note This method is guaranteed to be called on main. */ -- (void)nodeDidLayout; +- (void)nodeDidLayout NS_SWIFT_UI_ACTOR; /** * @abstract Called when the node loads. * @discussion Can be used for operations that are performed after the node's view is available. * @note This method is guaranteed to be called on main. */ -- (void)nodeDidLoad; +- (void)nodeDidLoad NS_SWIFT_UI_ACTOR; /** * @abstract Indicates that the receiver and all subnodes have finished displaying. @@ -114,7 +114,7 @@ typedef NS_OPTIONS(unsigned char, ASInterfaceState) * the progressImage block. * @note This method is guaranteed to be called on main. */ -- (void)hierarchyDisplayDidFinish; +- (void)hierarchyDisplayDidFinish NS_SWIFT_UI_ACTOR; @optional /** @@ -134,7 +134,7 @@ typedef NS_OPTIONS(unsigned char, ASInterfaceState) * re-parented multiple times, and each time will trigger this call. * @note This method is guaranteed to be called on main. */ -- (void)didEnterHierarchy; +- (void)didEnterHierarchy NS_SWIFT_UI_ACTOR; /** * @abstract Called when the node's layer has exited the hierarchy. @@ -143,6 +143,6 @@ typedef NS_OPTIONS(unsigned char, ASInterfaceState) * re-parented multiple times, and each time will trigger this call. * @note This method is guaranteed to be called on main. */ -- (void)didExitHierarchy; +- (void)didExitHierarchy NS_SWIFT_UI_ACTOR; @end diff --git a/Source/ASDisplayNode+Subclasses.h b/Source/ASDisplayNode+Subclasses.h index f8d598029..48eb24daa 100644 --- a/Source/ASDisplayNode+Subclasses.h +++ b/Source/ASDisplayNode+Subclasses.h @@ -281,7 +281,7 @@ AS_CATEGORY_IMPLEMENTABLE * @note Called on the main thread only */ -- (void)displayWillStartAsynchronously:(BOOL)asynchronously ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR; +- (NS_SWIFT_UI_ACTOR void)displayWillStartAsynchronously:(BOOL)asynchronously ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR; /** * @abstract Indicates that the receiver has finished displaying. @@ -291,7 +291,7 @@ AS_CATEGORY_IMPLEMENTABLE * * @note Called on the main thread only */ -- (void)displayDidFinish ASDISPLAYNODE_REQUIRES_SUPER; +- (void)displayDidFinish ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR; /** * Called just before the view is added to a window. @@ -307,7 +307,7 @@ AS_CATEGORY_IMPLEMENTABLE * Called just after the view is added to a window. * Note: this may be called multiple times during view controller transitions. To overcome this: use didEnterVisibleState or its equavalents. */ -- (void)didEnterHierarchy ASDISPLAYNODE_REQUIRES_SUPER; +- (void)didEnterHierarchy ASDISPLAYNODE_REQUIRES_SUPER NS_SWIFT_UI_ACTOR; /** * @abstract Whether the view or layer of this display node is currently in a window From 13ce386b226f6881335736bd1d9ff2806c1ec127 Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Fri, 29 Nov 2024 12:34:35 +0900 Subject: [PATCH 15/17] missing main actor --- Source/ASDisplayNode.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ASDisplayNode.h b/Source/ASDisplayNode.h index b8007848f..5bb883eee 100644 --- a/Source/ASDisplayNode.h +++ b/Source/ASDisplayNode.h @@ -124,7 +124,7 @@ ASDK_EXTERN NSInteger const ASDefaultDrawingPriority; * @return An ASDisplayNode instance that loads its view with the given block that is guaranteed to run on the main * queue. The view will render synchronously and -layout and touch handling methods on the node will not be called. */ -- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock; +- (instancetype)initWithViewBlock:(NS_SWIFT_UI_ACTOR ASDisplayNodeViewBlock)viewBlock; /** * @abstract Alternative initializer with a block to create the backing view. @@ -135,7 +135,7 @@ ASDK_EXTERN NSInteger const ASDefaultDrawingPriority; * @return An ASDisplayNode instance that loads its view with the given block that is guaranteed to run on the main * queue. The view will render synchronously and -layout and touch handling methods on the node will not be called. */ -- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock; +- (instancetype)initWithViewBlock:(NS_SWIFT_UI_ACTOR ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable NS_SWIFT_UI_ACTOR ASDisplayNodeDidLoadBlock)didLoadBlock; /** * @abstract Alternative initializer with a block to create the backing layer. From 31279d1eeb243cb16fa64812920edb6b2c552906 Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Fri, 29 Nov 2024 13:16:27 +0900 Subject: [PATCH 16/17] update --- Source/ASCollectionNode.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Source/ASCollectionNode.h b/Source/ASCollectionNode.h index 2c9c729f0..bad706f6a 100644 --- a/Source/ASCollectionNode.h +++ b/Source/ASCollectionNode.h @@ -231,7 +231,7 @@ NS_ASSUME_NONNULL_BEGIN * * This method must be called on the main thread. */ -- (void)scrollToItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UICollectionViewScrollPosition)scrollPosition animated:(BOOL)animated; +- (void)scrollToItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UICollectionViewScrollPosition)scrollPosition animated:(BOOL)animated NS_SWIFT_UI_ACTOR; /** * Determines collection node's current scroll direction. Supports 2-axis collection nodes. @@ -271,7 +271,7 @@ NS_ASSUME_NONNULL_BEGIN * Boolean parameter that contains the value YES if all of the related animations completed successfully or * NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread. */ -- (void)performBatchAnimated:(BOOL)animated updates:(nullable AS_NOESCAPE void (^)(void))updates completion:(nullable void (^)(BOOL finished))completion; +- (void)performBatchAnimated:(BOOL)animated updates:(nullable AS_NOESCAPE void (^)(void))updates completion:(nullable NS_SWIFT_UI_ACTOR void (^)(BOOL finished))completion NS_SWIFT_UI_ACTOR; /** * Perform a batch of updates asynchronously, optionally disabling all animations in the batch. This method must be called from the main thread. @@ -282,7 +282,7 @@ NS_ASSUME_NONNULL_BEGIN * Boolean parameter that contains the value YES if all of the related animations completed successfully or * NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread. */ -- (void)performBatchUpdates:(nullable AS_NOESCAPE void (^)(void))updates completion:(nullable void (^)(BOOL finished))completion; +- (void)performBatchUpdates:(nullable AS_NOESCAPE void (^)(void))updates completion:(nullable NS_SWIFT_UI_ACTOR void (^)(BOOL finished))completion NS_SWIFT_UI_ACTOR; /** * Returns YES if the ASCollectionNode is still processing changes from performBatchUpdates:. @@ -316,7 +316,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Blocks execution of the main thread until all section and item updates are committed to the view. This method must be called from the main thread. */ -- (void)waitUntilAllUpdatesAreProcessed; +- (void)waitUntilAllUpdatesAreProcessed NS_SWIFT_UI_ACTOR; /** * Inserts one or more sections. @@ -336,7 +336,7 @@ NS_ASSUME_NONNULL_BEGIN * @discussion This method must be called from the main thread. The data source must be updated to reflect the changes * before this method is called. */ -- (void)deleteSections:(NSIndexSet *)sections; +- (void)deleteSections:(NSIndexSet *)sections NS_SWIFT_UI_ACTOR; /** * Reloads the specified sections. @@ -358,7 +358,7 @@ NS_ASSUME_NONNULL_BEGIN * @discussion This method must be called from the main thread. The data source must be updated to reflect the changes * before this method is called. */ -- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection; +- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection NS_SWIFT_UI_ACTOR; /** * Inserts items at the locations identified by an array of index paths. @@ -368,7 +368,7 @@ NS_ASSUME_NONNULL_BEGIN * @discussion This method must be called from the main thread. The data source must be updated to reflect the changes * before this method is called. */ -- (void)insertItemsAtIndexPaths:(NSArray *)indexPaths; +- (void)insertItemsAtIndexPaths:(NSArray *)indexPaths NS_SWIFT_UI_ACTOR; /** * Deletes the items specified by an array of index paths. @@ -388,7 +388,7 @@ NS_ASSUME_NONNULL_BEGIN * @discussion This method must be called from the main thread. The data source must be updated to reflect the changes * before this method is called. */ -- (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths; +- (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths NS_SWIFT_UI_ACTOR; /** * Moves the item at a specified location to a destination location. @@ -409,7 +409,7 @@ NS_ASSUME_NONNULL_BEGIN * the main thread. * @warning This method is substantially more expensive than UICollectionView's version. */ -- (void)reloadDataWithCompletion:(nullable void (^)(void))completion; +- (void)reloadDataWithCompletion:(nullable NS_SWIFT_UI_ACTOR void (^)(void))completion NS_SWIFT_UI_ACTOR; /** @@ -459,7 +459,7 @@ NS_ASSUME_NONNULL_BEGIN * * @discussion This method must be called from the main thread. */ -- (void)deselectItemAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated; +- (void)deselectItemAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated NS_SWIFT_UI_ACTOR; #pragma mark - Querying Data @@ -518,7 +518,7 @@ NS_ASSUME_NONNULL_BEGIN * * @return an array containing the index paths of all visible items. This must be called on the main thread. */ -@property (nonatomic, readonly) NSArray *indexPathsForVisibleItems; +@property (nonatomic, readonly) NSArray *indexPathsForVisibleItems NS_SWIFT_UI_ACTOR; /** * Retrieve the index path of the item at the given point. @@ -536,7 +536,7 @@ NS_ASSUME_NONNULL_BEGIN * * @return The cell for the given index path. This must be called on the main thread. */ -- (nullable UICollectionViewCell *)cellForItemAtIndexPath:(NSIndexPath *)indexPath; +- (nullable UICollectionViewCell *)cellForItemAtIndexPath:(NSIndexPath *)indexPath NS_SWIFT_UI_ACTOR; /** * Retrieves the context object for the given section, as provided by the data source in @@ -603,7 +603,7 @@ NS_ASSUME_NONNULL_BEGIN * Must be thread-safe (can be called on the main thread or a background * queue) and should not implement reuse (it will be called once per row). */ -- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath; +- (NS_SWIFT_SENDABLE ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath; /** * Similar to -collectionView:cellForItemAtIndexPath:. @@ -615,7 +615,7 @@ NS_ASSUME_NONNULL_BEGIN * not implement reuse (it will be called once per item). Unlike UICollectionView's version, * this method is not called when the item is about to display. */ -- (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForItemAtIndexPath:(NSIndexPath *)indexPath; +- (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForItemAtIndexPath:(NSIndexPath *)indexPath NS_SWIFT_UI_ACTOR; /** * Asks the data source to provide a node-block to display for the given supplementary element in the collection view. From 2c945a0641d39628f06d21ef7b7f4fb64119812f Mon Sep 17 00:00:00 2001 From: Antoine Marandon Date: Fri, 29 Nov 2024 15:32:31 +0900 Subject: [PATCH 17/17] More annotations --- .../Private/ASCollectionView+Undeprecated.h | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/Private/ASCollectionView+Undeprecated.h b/Source/Private/ASCollectionView+Undeprecated.h index ce7a514f9..444cbf180 100644 --- a/Source/Private/ASCollectionView+Undeprecated.h +++ b/Source/Private/ASCollectionView+Undeprecated.h @@ -146,7 +146,7 @@ NS_ASSUME_NONNULL_BEGIN * Boolean parameter that contains the value YES if all of the related animations completed successfully or * NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread. */ -- (void)performBatchAnimated:(BOOL)animated updates:(nullable AS_NOESCAPE void (^)(void))updates completion:(nullable void (^)(BOOL finished))completion; +- (void)performBatchAnimated:(BOOL)animated updates:(nullable AS_NOESCAPE void (^)(void))updates completion:(nullable NS_SWIFT_UI_ACTOR void ( ^)(BOOL finished))completion NS_SWIFT_UI_ACTOR; /** * Perform a batch of updates asynchronously. This method must be called from the main thread. @@ -157,7 +157,7 @@ NS_ASSUME_NONNULL_BEGIN * Boolean parameter that contains the value YES if all of the related animations completed successfully or * NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread. */ -- (void)performBatchUpdates:(nullable AS_NOESCAPE void (^)(void))updates completion:(nullable void (^)(BOOL finished))completion; +- (void)performBatchUpdates:(nullable AS_NOESCAPE void (^)(void))updates completion:(nullable NS_SWIFT_UI_ACTOR void (^)(BOOL finished))completion NS_SWIFT_UI_ACTOR; /** * Triggers a relayout of all nodes. @@ -169,7 +169,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Blocks execution of the main thread until all section and row updates are committed. This method must be called from the main thread. */ -- (void)waitUntilAllUpdatesAreCommitted; +- (void)waitUntilAllUpdatesAreCommitted NS_SWIFT_UI_ACTOR; /** * Registers the given kind of supplementary node for use in creating node-backed supplementary views. @@ -191,7 +191,7 @@ NS_ASSUME_NONNULL_BEGIN * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes * before this method is called. */ -- (void)insertSections:(NSIndexSet *)sections; +- (void)insertSections:(NSIndexSet *)sections NS_SWIFT_UI_ACTOR; /** * Deletes one or more sections. @@ -201,7 +201,7 @@ NS_ASSUME_NONNULL_BEGIN * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes * before this method is called. */ -- (void)deleteSections:(NSIndexSet *)sections; +- (void)deleteSections:(NSIndexSet *)sections NS_SWIFT_UI_ACTOR; /** * Reloads the specified sections. @@ -211,7 +211,7 @@ NS_ASSUME_NONNULL_BEGIN * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes * before this method is called. */ -- (void)reloadSections:(NSIndexSet *)sections; +- (void)reloadSections:(NSIndexSet *)sections NS_SWIFT_UI_ACTOR; /** * Moves a section to a new location. @@ -223,7 +223,7 @@ NS_ASSUME_NONNULL_BEGIN * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes * before this method is called. */ -- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection; +- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection NS_SWIFT_UI_ACTOR; /** * Inserts items at the locations identified by an array of index paths. @@ -233,7 +233,7 @@ NS_ASSUME_NONNULL_BEGIN * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes * before this method is called. */ -- (void)insertItemsAtIndexPaths:(NSArray *)indexPaths; +- (void)insertItemsAtIndexPaths:(NSArray *)indexPaths NS_SWIFT_UI_ACTOR; /** * Deletes the items specified by an array of index paths. @@ -243,7 +243,7 @@ NS_ASSUME_NONNULL_BEGIN * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes * before this method is called. */ -- (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths; +- (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths NS_SWIFT_UI_ACTOR; /** * Reloads the specified items. @@ -253,7 +253,7 @@ NS_ASSUME_NONNULL_BEGIN * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes * before this method is called. */ -- (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths; +- (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths NS_SWIFT_UI_ACTOR; /** * Moves the item at a specified location to a destination location. @@ -265,7 +265,7 @@ NS_ASSUME_NONNULL_BEGIN * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes * before this method is called. */ -- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath; +- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath NS_SWIFT_UI_ACTOR; /** * Similar to -visibleCells.