[ios]fix unused variable clang tidy warning (flutter/engine#56637)

Spot another clang-tidy linter failure from: https://github.com/flutter/engine/pull/56631

In release mode, if we remove NSAssert, then weakFlutterEngine is not used at all. This should have been an XCTAssert rather than NSAssert in the first place. 

```
❌ Failures for clang-tidy on /Volumes/Work/s/w/ir/cache/builder/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm:
/Volumes/Work/s/w/ir/cache/builder/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm:239:5: error: Value stored to 'weakFlutterEngine' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
  239 |     weakFlutterEngine = flutterEngine;
      |     ^                   ~~~~~~~~~~~~~
/Volumes/Work/s/w/ir/cache/builder/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm:239:5: note: Value stored to 'weakFlutterEngine' is never read
  239 |     weakFlutterEngine = flutterEngine;
      |     ^                   ~~~~~~~~~~~~~
Suppressed 9240 warnings (9111 in non-user code, 129 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```

*List which issues are fixed by this PR. You must list at least one issue.*
https://github.com/flutter/flutter/issues/157837

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
hellohuanlin 2024-11-16 09:26:20 -08:00 committed by GitHub
parent 76abedcd79
commit aae55894be

View File

@ -237,7 +237,7 @@ FLUTTER_ASSERT_ARC
@autoreleasepool {
FlutterEngine* flutterEngine = OCMClassMock([FlutterEngine class]);
weakFlutterEngine = flutterEngine;
NSAssert(weakFlutterEngine, @"flutter engine must not be nil");
XCTAssertNotNil(weakFlutterEngine, @"flutter engine must not be nil");
FlutterTextInputPlugin* flutterTextInputPlugin = [[FlutterTextInputPlugin alloc]
initWithDelegate:(id<FlutterTextInputDelegate>)flutterEngine];
weakFlutterTextInputPlugin = flutterTextInputPlugin;
@ -254,8 +254,8 @@ FLUTTER_ASSERT_ARC
currentView = flutterTextInputPlugin.activeView;
}
NSAssert(!weakFlutterEngine, @"flutter engine must be nil");
NSAssert(currentView, @"current view must not be nil");
XCTAssertNil(weakFlutterEngine, @"flutter engine must be nil");
XCTAssertNotNil(currentView, @"current view must not be nil");
XCTAssertNil(weakFlutterTextInputPlugin);
// Verify that the view can no longer access the deallocated engine/text input plugin