Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions Sources/COpenSwiftUI/Overlay/UIKit/OpenSwiftUI+UIApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
// Status: Complete

#include "OpenSwiftUI+UIApplication.h"
#include "Shims/OpenSwiftUIShims.h"

#if OPENSWIFTUI_TARGET_OS_IOS || OPENSWIFTUI_TARGET_OS_VISION
#include <objc/runtime.h>

UIContentSizeCategory _UIApplicationDefaultContentSizeCategory() {
typedef UIContentSizeCategory (*Func)(Class, SEL);
SEL selector = NSSelectorFromString(@"_defaultContentSizeCategory");
Func func = nil;
if ([UIApplication resolveClassMethod:selector]) {
IMP impl = class_getMethodImplementation(UIApplication.class, selector);
func = (Func)impl;
}
if (func == nil) {
return UIContentSizeCategoryLarge;
}
return func(UIApplication.class, selector);
Class self = UIApplication.class;
OPENSWIFTUI_SAFE_WRAPPER_IMP(UIContentSizeCategory, @"_defaultContentSizeCategory", UIContentSizeCategoryLarge);
return func(self, selector);
}

#endif /* OPENSWIFTUI_TARGET_OS_IOS || OPENSWIFTUI_TARGET_OS_VISION */
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ - (BOOL)_OpenSwiftUITesting_wantsWideContentMargins {
@implementation UICollectionView (OpenSwiftUITesting_Swizzles)
+ (void)_performOpenSwiftUITestingOverrides {
#if !OPENSWIFTUI_TARGET_OS_VISION
_SwizzleMethods(UIScreen.class, @selector(_viewAnimationsForCurrentUpdateWithCollectionViewAnimator:), @selector(_OpenSwiftUITesting__viewAnimationsForCurrentUpdateWithCollectionViewAnimator:));
_SwizzleMethods(UICollectionView.class, @selector(_viewAnimationsForCurrentUpdateWithCollectionViewAnimator:), @selector(_OpenSwiftUITesting__viewAnimationsForCurrentUpdateWithCollectionViewAnimator:));
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ - (instancetype)initOpenSwiftUIAttributedStringWithFormat:(NSAttributedString *)
}

- (NSAttributedString *)_ui_attributedSubstringFromRange_openswiftui_safe_wrapper:(NSRange)range scaledByScaleFactor:(CGFloat)factor {
OPENSWIFTUI_SAFE_WRAPPER_IMP(NSAttributedString *, @"_ui_attributedSubstringFromRange:scaledByScaleFactor", nil, NSRange, CGFloat);
OPENSWIFTUI_SAFE_WRAPPER_IMP(NSAttributedString *, @"_ui_attributedSubstringFromRange:scaledByScaleFactor:", nil, NSRange, CGFloat);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR changes several runtime selector/swizzle strings without an accompanying regression test; because the safe wrappers return defaults when a selector is misspelled, another delimiter or target-class typo can pass the build and only surface as missing dynamic behavior. Other locations where this applies: Sources/OpenSwiftUI_SPI/Shims/UIFoundation/NSAttributedString.m:34, Sources/COpenSwiftUI/Overlay/UIKit/OpenSwiftUI+UIApplication.m:13, Sources/COpenSwiftUI/Overlay/UIKit/OpenSwiftUITesting_Swizzles+UIKit.m:33.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

return func(self, selector, range, factor);
}

Expand All @@ -31,7 +31,7 @@ - (NSAttributedString *)_ui_attributedSubstringFromRange_openswiftui_safe_wrappe
@implementation NSMutableAttributedString (OpenSwiftUI_SPI)

- (BOOL)isEmptyOrTerminatedByParagraphSeparator_openswiftui_safe_wrapper {
OPENSWIFTUI_SAFE_WRAPPER_IMP(BOOL, @"isEmptyOrTerminatedByParagraphSeparator:scaledByScaleFactor", false);
OPENSWIFTUI_SAFE_WRAPPER_IMP(BOOL, @"isEmptyOrTerminatedByParagraphSeparator", false);
return func(self, selector);
}

Expand Down
Loading