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

Commit a339093

Browse files
authored
Remove availability and fallbacks for iOS 11 and macOS 10.13 (#34919)
1 parent b2038b1 commit a339093

20 files changed

+325
-560
lines changed

impeller/renderer/backend/metal/allocator_mtl.mm

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ static MTLResourceOptions ToMTLResourceOptions(StorageMode type) {
4141
return MTLResourceStorageModePrivate;
4242
case StorageMode::kDeviceTransient:
4343
#if FML_OS_IOS
44-
if (@available(iOS 10.0, *)) {
45-
return MTLResourceStorageModeMemoryless;
46-
} else {
47-
return MTLResourceStorageModePrivate;
48-
}
44+
return MTLResourceStorageModeMemoryless;
4945
#else
5046
return MTLResourceStorageModePrivate;
5147
#endif
@@ -66,11 +62,7 @@ static MTLStorageMode ToMTLStorageMode(StorageMode mode) {
6662
return MTLStorageModePrivate;
6763
case StorageMode::kDeviceTransient:
6864
#if FML_OS_IOS
69-
if (@available(iOS 10.0, *)) {
70-
return MTLStorageModeMemoryless;
71-
} else {
72-
return MTLStorageModePrivate;
73-
}
65+
return MTLStorageModeMemoryless;
7466
#else
7567
return MTLStorageModePrivate;
7668
#endif

impeller/renderer/backend/metal/command_buffer_mtl.mm

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,6 @@
99
namespace impeller {
1010
namespace {
1111

12-
// NOLINTBEGIN(readability-identifier-naming)
13-
14-
// TODO(dnfield): remove this declaration when we no longer need to build on
15-
// machines with lower SDK versions than 11.0.
16-
#if !defined(MAC_OS_VERSION_11_0) || \
17-
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_11_0
18-
typedef NS_ENUM(NSInteger, MTLCommandEncoderErrorState) {
19-
MTLCommandEncoderErrorStateUnknown = 0,
20-
MTLCommandEncoderErrorStateCompleted = 1,
21-
MTLCommandEncoderErrorStateAffected = 2,
22-
MTLCommandEncoderErrorStatePending = 3,
23-
MTLCommandEncoderErrorStateFaulted = 4,
24-
} API_AVAILABLE(macos(11.0), ios(14.0));
25-
#endif
26-
27-
// NOLINTEND(readability-identifier-naming)
28-
2912
API_AVAILABLE(ios(14.0), macos(11.0))
3013
NSString* MTLCommandEncoderErrorStateToString(
3114
MTLCommandEncoderErrorState state) {

impeller/renderer/backend/metal/device_buffer_mtl.mm

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,9 @@
7373
if (label.empty()) {
7474
return false;
7575
}
76-
if (@available(macOS 10.12, iOS 10.0, *)) {
77-
[buffer_ addDebugMarker:@(label.c_str())
78-
range:NSMakeRange(range.offset, range.length)];
79-
return true;
80-
} else {
81-
return SetLabel(label);
82-
}
76+
[buffer_ addDebugMarker:@(label.c_str())
77+
range:NSMakeRange(range.offset, range.length)];
78+
return true;
8379
FML_UNREACHABLE();
8480
}
8581

impeller/renderer/backend/metal/vertex_descriptor_mtl.mm

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
3939
if (input.bit_width == 8 * sizeof(float) / 2) {
4040
switch (input.vec_size) {
4141
case 1:
42-
if (@available(macOS 10.13, iOS 11.0, *)) {
43-
return MTLVertexFormatHalf;
44-
} else {
45-
return MTLVertexFormatInvalid;
46-
}
42+
return MTLVertexFormatHalf;
4743
case 2:
4844
return MTLVertexFormatHalf2;
4945
case 3:
@@ -60,23 +56,15 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
6056
}
6157
case ShaderType::kBoolean: {
6258
if (input.bit_width == 8 * sizeof(bool) && input.vec_size == 1) {
63-
if (@available(macOS 10.13, iOS 11.0, *)) {
64-
return MTLVertexFormatChar;
65-
} else {
66-
return MTLVertexFormatInvalid;
67-
}
59+
return MTLVertexFormatChar;
6860
}
6961
return MTLVertexFormatInvalid;
7062
}
7163
case ShaderType::kSignedByte: {
7264
if (input.bit_width == 8 * sizeof(char)) {
7365
switch (input.vec_size) {
7466
case 1:
75-
if (@available(macOS 10.13, iOS 11.0, *)) {
76-
return MTLVertexFormatChar;
77-
} else {
78-
return MTLVertexFormatInvalid;
79-
}
67+
return MTLVertexFormatChar;
8068
case 2:
8169
return MTLVertexFormatChar2;
8270
case 3:
@@ -91,11 +79,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
9179
if (input.bit_width == 8 * sizeof(char)) {
9280
switch (input.vec_size) {
9381
case 1:
94-
if (@available(macOS 10.13, iOS 11.0, *)) {
95-
return MTLVertexFormatUChar;
96-
} else {
97-
return MTLVertexFormatInvalid;
98-
}
82+
return MTLVertexFormatUChar;
9983
case 2:
10084
return MTLVertexFormatUChar2;
10185
case 3:
@@ -110,11 +94,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
11094
if (input.bit_width == 8 * sizeof(short)) {
11195
switch (input.vec_size) {
11296
case 1:
113-
if (@available(macOS 10.13, iOS 11.0, *)) {
114-
return MTLVertexFormatShort;
115-
} else {
116-
return MTLVertexFormatInvalid;
117-
}
97+
return MTLVertexFormatShort;
11898
case 2:
11999
return MTLVertexFormatShort2;
120100
case 3:
@@ -129,11 +109,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
129109
if (input.bit_width == 8 * sizeof(ushort)) {
130110
switch (input.vec_size) {
131111
case 1:
132-
if (@available(macOS 10.13, iOS 11.0, *)) {
133-
return MTLVertexFormatUShort;
134-
} else {
135-
return MTLVertexFormatInvalid;
136-
}
112+
return MTLVertexFormatUShort;
137113
case 2:
138114
return MTLVertexFormatUShort2;
139115
case 3:

shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
2222
/**
2323
* Protocol for listener of events from the UIApplication, typically a FlutterPlugin.
2424
*/
25-
@protocol FlutterApplicationLifeCycleDelegate
26-
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
27-
<UNUserNotificationCenterDelegate>
28-
#endif
25+
@protocol FlutterApplicationLifeCycleDelegate <UNUserNotificationCenterDelegate>
26+
2927
@optional
3028
/**
3129
* Called if this has been registered for `UIApplicationDelegate` callbacks.
@@ -432,10 +430,7 @@ typedef enum {
432430
* For plugins to receive events from `UNUserNotificationCenter`, register this as the
433431
* `UNUserNotificationCenterDelegate`.
434432
*/
435-
@protocol FlutterAppLifeCycleProvider
436-
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
437-
<UNUserNotificationCenterDelegate>
438-
#endif
433+
@protocol FlutterAppLifeCycleProvider <UNUserNotificationCenterDelegate>
439434

440435
/**
441436
* Called when registering a new `FlutterApplicaitonLifeCycleDelegate`.

shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
1313
* Propagates `UIAppDelegate` callbacks to registered plugins.
1414
*/
1515
FLUTTER_DARWIN_EXPORT
16-
@interface FlutterPluginAppLifeCycleDelegate : NSObject
17-
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
18-
<UNUserNotificationCenterDelegate>
19-
#endif
16+
@interface FlutterPluginAppLifeCycleDelegate : NSObject <UNUserNotificationCenterDelegate>
2017

2118
/**
2219
* Registers `delegate` to receive life cycle callbacks via this FlutterPluginAppLifecycleDelegate

shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,11 @@ - (void)application:(UIApplication*)application
113113
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
114114
willPresentNotification:(UNNotification*)notification
115115
withCompletionHandler:
116-
(void (^)(UNNotificationPresentationOptions options))completionHandler
117-
NS_AVAILABLE_IOS(10_0) {
118-
if (@available(iOS 10.0, *)) {
119-
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
120-
[_lifeCycleDelegate userNotificationCenter:center
121-
willPresentNotification:notification
122-
withCompletionHandler:completionHandler];
123-
}
116+
(void (^)(UNNotificationPresentationOptions options))completionHandler {
117+
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
118+
[_lifeCycleDelegate userNotificationCenter:center
119+
willPresentNotification:notification
120+
withCompletionHandler:completionHandler];
124121
}
125122
}
126123

@@ -129,13 +126,11 @@ - (void)userNotificationCenter:(UNUserNotificationCenter*)center
129126
*/
130127
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
131128
didReceiveNotificationResponse:(UNNotificationResponse*)response
132-
withCompletionHandler:(void (^)(void))completionHandler NS_AVAILABLE_IOS(10_0) {
133-
if (@available(iOS 10.0, *)) {
134-
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
135-
[_lifeCycleDelegate userNotificationCenter:center
136-
didReceiveNotificationResponse:response
137-
withCompletionHandler:completionHandler];
138-
}
129+
withCompletionHandler:(void (^)(void))completionHandler {
130+
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
131+
[_lifeCycleDelegate userNotificationCenter:center
132+
didReceiveNotificationResponse:response
133+
withCompletionHandler:completionHandler];
139134
}
140135
}
141136

@@ -199,7 +194,7 @@ - (BOOL)application:(UIApplication*)application
199194

200195
- (void)application:(UIApplication*)application
201196
performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem
202-
completionHandler:(void (^)(BOOL succeeded))completionHandler NS_AVAILABLE_IOS(9_0) {
197+
completionHandler:(void (^)(BOOL succeeded))completionHandler {
203198
[_lifeCycleDelegate application:application
204199
performActionForShortcutItem:shortcutItem
205200
completionHandler:completionHandler];
@@ -213,16 +208,10 @@ - (void)application:(UIApplication*)application
213208
completionHandler:completionHandler];
214209
}
215210

216-
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 120000
217211
- (BOOL)application:(UIApplication*)application
218212
continueUserActivity:(NSUserActivity*)userActivity
219213
restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>>* __nullable
220214
restorableObjects))restorationHandler {
221-
#else
222-
- (BOOL)application:(UIApplication*)application
223-
continueUserActivity:(NSUserActivity*)userActivity
224-
restorationHandler:(void (^)(NSArray* __nullable restorableObjects))restorationHandler {
225-
#endif
226215
if ([_lifeCycleDelegate application:application
227216
continueUserActivity:userActivity
228217
restorationHandler:restorationHandler]) {

shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ + (NSData*)createTxtData:(NSURL*)url;
6060

6161
@end
6262

63-
@interface ObservatoryNSNetServiceDelegate
64-
: NSObject <FlutterObservatoryPublisherDelegate, NSNetServiceDelegate>
65-
@end
66-
6763
@interface ObservatoryDNSServiceDelegate : NSObject <FlutterObservatoryPublisherDelegate>
6864
@end
6965

@@ -116,15 +112,6 @@ - (void)publishServiceProtocolPort:(NSURL*)url {
116112
}
117113
}
118114

119-
/// TODO(aaclarke): Remove this preprocessor macro once infra is moved to Xcode 12.
120-
static const DNSServiceErrorType kFlutter_DNSServiceErr_PolicyDenied =
121-
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000
122-
kDNSServiceErr_PolicyDenied;
123-
#else
124-
// Found in usr/include/dns_sd.h.
125-
-65570;
126-
#endif // __IPHONE_OS_VERSION_MAX_ALLOWED
127-
128115
static void DNSSD_API RegistrationCallback(DNSServiceRef sdRef,
129116
DNSServiceFlags flags,
130117
DNSServiceErrorType errorCode,
@@ -134,7 +121,7 @@ static void DNSSD_API RegistrationCallback(DNSServiceRef sdRef,
134121
void* context) {
135122
if (errorCode == kDNSServiceErr_NoError) {
136123
FML_DLOG(INFO) << "FlutterObservatoryPublisher is ready!";
137-
} else if (errorCode == kFlutter_DNSServiceErr_PolicyDenied) {
124+
} else if (errorCode == kDNSServiceErr_PolicyDenied) {
138125
FML_LOG(ERROR)
139126
<< "Could not register as server for FlutterObservatoryPublisher, permission "
140127
<< "denied. Check your 'Local Network' permissions for this app in the Privacy section of "
@@ -147,38 +134,6 @@ static void DNSSD_API RegistrationCallback(DNSServiceRef sdRef,
147134

148135
@end
149136

150-
@implementation ObservatoryNSNetServiceDelegate {
151-
fml::scoped_nsobject<NSNetService> _netService;
152-
}
153-
154-
- (void)stopService {
155-
[_netService.get() stop];
156-
[_netService.get() setDelegate:nil];
157-
}
158-
159-
- (void)publishServiceProtocolPort:(NSURL*)url {
160-
NSNetService* netServiceTmp =
161-
[[NSNetService alloc] initWithDomain:@"local."
162-
type:@"_dartobservatory._tcp."
163-
name:FlutterObservatoryPublisher.serviceName
164-
port:[[url port] intValue]];
165-
[netServiceTmp setTXTRecordData:[FlutterObservatoryPublisher createTxtData:url]];
166-
_netService.reset(netServiceTmp);
167-
[_netService.get() setDelegate:self];
168-
[_netService.get() publish];
169-
}
170-
171-
- (void)netServiceDidPublish:(NSNetService*)sender {
172-
FML_DLOG(INFO) << "FlutterObservatoryPublisher is ready!";
173-
}
174-
175-
- (void)netService:(NSNetService*)sender didNotPublish:(NSDictionary*)errorDict {
176-
FML_LOG(ERROR) << "Could not register as server for FlutterObservatoryPublisher. Check your "
177-
"network settings and relaunch the application.";
178-
}
179-
180-
@end
181-
182137
@implementation FlutterObservatoryPublisher {
183138
flutter::DartServiceIsolate::CallbackHandle _callbackHandle;
184139
std::unique_ptr<fml::WeakPtrFactory<FlutterObservatoryPublisher>> _weakFactory;
@@ -188,11 +143,7 @@ - (instancetype)initWithEnableObservatoryPublication:(BOOL)enableObservatoryPubl
188143
self = [super init];
189144
NSAssert(self, @"Super must not return null on init.");
190145

191-
if (@available(iOS 9.3, *)) {
192-
_delegate.reset([[ObservatoryDNSServiceDelegate alloc] init]);
193-
} else {
194-
_delegate.reset([[ObservatoryNSNetServiceDelegate alloc] init]);
195-
}
146+
_delegate.reset([[ObservatoryDNSServiceDelegate alloc] init]);
196147
_enableObservatoryPublication = enableObservatoryPublication;
197148
_weakFactory = std::make_unique<fml::WeakPtrFactory<FlutterObservatoryPublisher>>(self);
198149

shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
constexpr char kTextPlainFormat[] = "text/plain";
1818
const UInt32 kKeyPressClickSoundId = 1306;
1919

20-
} // namespaces
20+
} // namespace
2121

2222
namespace flutter {
2323

@@ -107,19 +107,17 @@ - (void)vibrateHapticFeedback:(NSString*)feedbackType {
107107
return;
108108
}
109109

110-
if (@available(iOS 10, *)) {
111-
if ([@"HapticFeedbackType.lightImpact" isEqualToString:feedbackType]) {
112-
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight] autorelease]
113-
impactOccurred];
114-
} else if ([@"HapticFeedbackType.mediumImpact" isEqualToString:feedbackType]) {
115-
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium] autorelease]
116-
impactOccurred];
117-
} else if ([@"HapticFeedbackType.heavyImpact" isEqualToString:feedbackType]) {
118-
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy] autorelease]
119-
impactOccurred];
120-
} else if ([@"HapticFeedbackType.selectionClick" isEqualToString:feedbackType]) {
121-
[[[[UISelectionFeedbackGenerator alloc] init] autorelease] selectionChanged];
122-
}
110+
if ([@"HapticFeedbackType.lightImpact" isEqualToString:feedbackType]) {
111+
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight] autorelease]
112+
impactOccurred];
113+
} else if ([@"HapticFeedbackType.mediumImpact" isEqualToString:feedbackType]) {
114+
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium] autorelease]
115+
impactOccurred];
116+
} else if ([@"HapticFeedbackType.heavyImpact" isEqualToString:feedbackType]) {
117+
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy] autorelease]
118+
impactOccurred];
119+
} else if ([@"HapticFeedbackType.selectionClick" isEqualToString:feedbackType]) {
120+
[[[[UISelectionFeedbackGenerator alloc] init] autorelease] selectionChanged];
123121
}
124122
}
125123

@@ -276,15 +274,7 @@ - (void)setClipboardData:(NSDictionary*)data {
276274
}
277275

278276
- (NSDictionary*)clipboardHasStrings {
279-
bool hasStrings = false;
280-
UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
281-
if (@available(iOS 10, *)) {
282-
hasStrings = pasteboard.hasStrings;
283-
} else {
284-
NSString* stringInPasteboard = pasteboard.string;
285-
hasStrings = stringInPasteboard != nil;
286-
}
287-
return @{@"value" : @(hasStrings)};
277+
return @{@"value" : @([UIPasteboard generalPasteboard].hasStrings)};
288278
}
289279

290280
@end

0 commit comments

Comments
 (0)