Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

iOS: Use standard Obj-C cflags for ios_test_flutter #56384

Merged
merged 2 commits into from
Nov 5, 2024
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
14 changes: 8 additions & 6 deletions shell/platform/darwin/ios/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,20 @@ platform_frameworks_path =
shared_library("ios_test_flutter") {
testonly = true
visibility = [ "*" ]

# Xcode 15 beta has a bug where iOS 17 API usage is not guarded.
# This bug results engine build failure since the engine treats warnings as errors.
# The `-Wno-unguarded-availability-new` can be removed when the Xcode bug is fixed.
# See details in https://github.com/flutter/flutter/issues/128958.
cflags_objc = flutter_cflags_objc_arc
cflags_objcc =
flutter_cflags_objcc_arc + [ "-Wno-unguarded-availability-new" ]
cflags = [
"-fvisibility=default",
"-F$platform_frameworks_path",
"-fobjc-arc",
"-mios-simulator-version-min=$ios_testing_deployment_target",
]

# XCode 15 beta has a bug where iOS 17 API usage is not guarded.
# This bug results engine build failure since the engine treats warnings as errors.
# The `-Wno-unguarded-availability-new` can be removed when the XCode bug is fixed.
# See details in https://github.com/flutter/flutter/issues/128958.
cflags_objcc = [ "-Wno-unguarded-availability-new" ]
ldflags = [
"-F$platform_frameworks_path",
"-Wl,-install_name,@rpath/Frameworks/libios_test_flutter.dylib",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,10 @@ - (void)testReplaceTestLocalAdjustSelectionAndMarkedTextRange {

- (void)testFlutterTextInputViewOnlyRespondsToInsertionPointColorBelowIOS17 {
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin];
BOOL respondsToInsertionPointColor =
[inputView respondsToSelector:@selector(insertionPointColor)];
// [UITextInputTraits insertionPointColor] is non-public API, so @selector(insertionPointColor)
// would generate a compile-time warning.
SEL insertionPointColor = NSSelectorFromString(@"insertionPointColor");
BOOL respondsToInsertionPointColor = [inputView respondsToSelector:insertionPointColor];
if (@available(iOS 17, *)) {
XCTAssertFalse(respondsToInsertionPointColor);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,24 @@
#import <XCTest/XCTest.h>

#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h"

FLUTTER_ASSERT_ARC

/// OCMock does not allow mocking both class and protocol. Use this to mock the methods used on
/// `UIView<UITextInput>*` in the plugin.
@interface TextInputViewTest : NSObject

@property(nonatomic, weak) id<UITextInputDelegate> inputDelegate;
@property(nonatomic, readonly) UITextInputAssistantItem* inputAssistantItem;

@end

@implementation TextInputViewTest
@end

@interface FakeFlutterUndoManagerDelegate : NSObject <FlutterUndoManagerDelegate>

@property(readonly) NSUInteger undoCount;
@property(readonly) NSUInteger redoCount;
@property(nonatomic, nullable) NSUndoManager* undoManager;
@property(nonatomic, nullable) UIView<UITextInput>* activeTextInputView;

- (instancetype)initWithUndoManager:(NSUndoManager*)undoManager
activeTextInputView:(TextInputViewTest*)activeTextInputView;
activeTextInputView:(UIView<UITextInput>*)activeTextInputView;

@end

@implementation FakeFlutterUndoManagerDelegate

@synthesize undoManager = _undoManager;
@synthesize activeTextInputView = _activeTextInputView;

- (instancetype)initWithUndoManager:(NSUndoManager*)undoManager
activeTextInputView:(UIView<UITextInput>*)activeTextInputView {
self = [super init];
Expand All @@ -62,7 +49,7 @@ - (void)handleUndoWithDirection:(FlutterUndoRedoDirection)direction {
@interface FlutterUndoManagerPluginTest : XCTestCase
@property(nonatomic) FakeFlutterUndoManagerDelegate* undoManagerDelegate;
@property(nonatomic) FlutterUndoManagerPlugin* undoManagerPlugin;
@property(nonatomic) TextInputViewTest* activeTextInputView;
@property(nonatomic) UIView<UITextInput>* activeTextInputView;
@property(nonatomic) NSUndoManager* undoManager;
@end

Expand All @@ -72,7 +59,7 @@ - (void)setUp {
[super setUp];

self.undoManager = OCMClassMock([NSUndoManager class]);
self.activeTextInputView = OCMClassMock([TextInputViewTest class]);
self.activeTextInputView = OCMClassMock([FlutterTextInputView class]);

self.undoManagerDelegate =
[[FakeFlutterUndoManagerDelegate alloc] initWithUndoManager:self.undoManager
Expand Down Expand Up @@ -170,7 +157,7 @@ - (void)testDeallocRemovesAllUndoManagerActions {
// Use a real undo manager.
NSUndoManager* undoManager = [[NSUndoManager alloc] init];
@autoreleasepool {
id activeTextInputView = OCMClassMock([TextInputViewTest class]);
id activeTextInputView = OCMClassMock([FlutterTextInputView class]);

FakeFlutterUndoManagerDelegate* undoManagerDelegate =
[[FakeFlutterUndoManagerDelegate alloc] initWithUndoManager:undoManager
Expand Down