Skip to content

Commit cb011a8

Browse files
authored
fix: crash on catalyst (#1464)
## 📜 Description Fixed a crash when using `ClippingScrollViewDecorator` (`KeyboardAwareScrollView`/`KeyboardChatScrollView`) in MacCatalyst apps. ## 💡 Motivation and Context That crash happens because we try to exchange of methods that don't exist in MacCatalyst implementation. When we run this code the UIKit gets backed by AppKit and mobile-specific methods don't exist. The fix is very simple - for mac catalyst we don't need to exchange the implementations of methods that don't exist. Fix: #1454 ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### iOS - don't swizzle implementation of non-existing methods on MacCatalyst; ## 🤔 How Has This Been Tested? Tested in example catalyst app: <img width="750" height="345" alt="image" src="https://github.com/user-attachments/assets/280faf74-ed59-4da2-99d7-c1e6b12e6ddd" /> ## 📸 Screenshots (if appropriate): |Before|After| |-------|-----| |<img width="1506" height="1030" alt="image" src="https://github.com/user-attachments/assets/c727a030-f476-4260-922d-e1371feb5802" />|<img width="1026" height="767" alt="image" src="https://github.com/user-attachments/assets/a6b765a4-1f06-4180-84a7-9bed5c85686c" />| ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent 7dcd70a commit cb011a8

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@
195195
"lottiefiles",
196196
"dotlottie",
197197
"legendapp",
198-
"kortix"
198+
"kortix",
199+
"MACCATALYST"
199200
],
200201
"ignorePaths": [
201202
"node_modules",

ios/views/ClippingScrollViewDecoratorViewManager.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#import "RCTFabricComponentsPlugins.h"
1717
#endif
1818

19+
#import <TargetConditionals.h>
1920
#import <UIKit/UIKit.h>
2021
#import <objc/runtime.h>
2122

@@ -213,11 +214,16 @@ - (void)didMoveToWindow
213214
{
214215
[super didMoveToWindow];
215216
if (self.window) {
217+
#if TARGET_OS_MACCATALYST
218+
// Catalyst UIScrollView is AppKit-backed; avoid runtime subclassing it.
219+
return;
220+
#else
216221
UIScrollView *scrollView = KCFindFirstScrollView(self);
217222
KCApplyNoopScrollRectToVisible(scrollView);
218223
if (self.applyWorkaroundForContentInsetHitTestBug) {
219224
KCApplyFixedHitTest(scrollView);
220225
}
226+
#endif
221227
}
222228
}
223229

0 commit comments

Comments
 (0)