Commit 41bb917c authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

[ios] Fix compilation with Xcode 11

ScreenTime framework is only available with Xcode 12 or later. However,
Xcode 12 is still not required to build Chromium on iOS. Add compilation
guard checking for availability of iOS 14 or later SDK before using code
from ScreenTime framework.

Bug: 1123704
Change-Id: Ia63dcea01ab5973b564db39afe56b910caf6297b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2396139
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarRobbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/master@{#804780}
parent f8303fb7
......@@ -4,6 +4,8 @@
#import "ios/chrome/browser/ui/browser_container/browser_container_coordinator.h"
#import <Availability.h>
#include "base/check.h"
#import "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/overlays/public/overlay_presenter.h"
......@@ -11,9 +13,12 @@
#import "ios/chrome/browser/ui/browser_container/browser_container_view_controller.h"
#import "ios/chrome/browser/ui/overlays/overlay_container_coordinator.h"
#import "ios/chrome/browser/ui/screen_time/features.h"
#import "ios/chrome/browser/ui/screen_time/screen_time_coordinator.h"
#include "url/gurl.h"
#if defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
#import "ios/chrome/browser/ui/screen_time/screen_time_coordinator.h"
#endif // __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
......@@ -83,6 +88,7 @@
if (!IsScreenTimeIntegrationEnabled())
return;
#if defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
if (@available(iOS 14, *)) {
ScreenTimeCoordinator* screenTimeCoordinator =
[[ScreenTimeCoordinator alloc]
......@@ -93,6 +99,7 @@
screenTimeCoordinator.viewController;
self.screenTimeCoordinator = screenTimeCoordinator;
}
#endif // __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
}
@end
......@@ -2,32 +2,38 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/ios/ios_sdk.gni")
source_set("screen_time") {
sources = [
"screen_time_consumer.h",
"screen_time_coordinator.h",
"screen_time_coordinator.mm",
"screen_time_mediator.h",
"screen_time_mediator.mm",
"screen_time_view_controller.h",
"screen_time_view_controller.mm",
]
frameworks = [
"ScreenTime.framework",
"UIKit.framework",
]
configs += [ "//build/config/compiler:enable_arc" ]
deps = [
":feature_flags",
"//base",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/main:public",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/web_state_list",
"//ios/chrome/common/ui/util",
"//ios/web/public",
"//net",
]
# TODO(crbug.com/1123704): remove when it is recommended to build Chromium
# with version 12.0 or later of Xcode.
if (xcode_version_int >= 1200) {
sources = [
"screen_time_consumer.h",
"screen_time_coordinator.h",
"screen_time_coordinator.mm",
"screen_time_mediator.h",
"screen_time_mediator.mm",
"screen_time_view_controller.h",
"screen_time_view_controller.mm",
]
frameworks = [
"UIKit.framework",
"ScreenTime.framework",
]
configs += [ "//build/config/compiler:enable_arc" ]
deps = [
":feature_flags",
"//base",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/main:public",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/web_state_list",
"//ios/chrome/common/ui/util",
"//ios/web/public",
"//net",
]
}
}
source_set("feature_flags") {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment