Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): fix compatability with iOS 9 #11091

Merged
merged 10 commits into from
Aug 19, 2019
6 changes: 2 additions & 4 deletions build/lib/packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ const rollup = require('rollup').rollup;
const babel = require('rollup-plugin-babel');
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const appc = require('node-appc');
const version = appc.version;
const packageJSON = require('../../package.json');
const utils = require('./utils');
const copyFile = utils.copyFile;
Expand Down Expand Up @@ -85,12 +83,12 @@ function determineBabelOptions() {
const chromeVersion = parseInt(found[1] + found[2]); // concat the first two numbers as string, then turn to int
// Now pull out min IOS target
// eslint-disable-next-line security/detect-non-literal-require
const minSupportedIosSdk = version.parseMin(require(path.join(ROOT_DIR, 'iphone/package.json')).vendorDependencies['ios sdk']);
const { minIosVersion } = require(path.join(ROOT_DIR, 'iphone/package.json'));
// TODO: filter to only targets relevant for platforms we're building?
const options = {
targets: {
chrome: chromeVersion,
ios: minSupportedIosSdk
ios: minIosVersion
},
useBuiltIns: 'entry',
// DO NOT include web polyfills!
Expand Down
6 changes: 2 additions & 4 deletions build/scons-xcode-project-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const rollup = require('rollup').rollup;
const babel = require('rollup-plugin-babel');
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const appc = require('node-appc');
const version = appc.version;

program.parse(process.argv);

Expand Down Expand Up @@ -53,10 +51,10 @@ async function generateIndexJSON(dirToTraverse) {

function determineBabelOptions() {
// eslint-disable-next-line security/detect-non-literal-require
const minSupportedIosSdk = version.parseMin(require(path.join(ROOT_DIR, 'iphone/package.json')).vendorDependencies['ios sdk']);
const { minIosVersion } = require(path.join(ROOT_DIR, 'iphone/package.json'));
const options = {
targets: {
ios: minSupportedIosSdk
ios: minIosVersion
},
useBuiltIns: 'entry',
// DO NOT include web polyfills!
Expand Down
7 changes: 6 additions & 1 deletion iphone/Classes/GeolocationModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,11 @@ - (CLLocationManager *)locationManager

locationManager.allowsBackgroundLocationUpdates = allowsBackgroundLocationUpdates;

#if IS_SDK_IOS_11
if ([TiUtils isIOSVersionOrGreater:@"11.0"]) {
locationManager.showsBackgroundLocationIndicator = showBackgroundLocationIndicator;
}

#endif
locationManager.activityType = activityType;
locationManager.pausesLocationUpdatesAutomatically = pauseLocationUpdateAutomatically;

Expand Down Expand Up @@ -603,19 +604,23 @@ - (void)setHeadingFilter:(CLLocationDegrees)value

- (BOOL)showBackgroundLocationIndicator
{
#if IS_SDK_IOS_11
if ([TiUtils isIOSVersionOrGreater:@"11.0"]) {
return showBackgroundLocationIndicator;
}
#endif
DebugLog(@"[ERROR] The showBackgroundLocationIndicator property is only available on iOS 11.0+. Returning \"false\" ...");
return NO;
}

- (void)setShowBackgroundLocationIndicator:(BOOL)value
{
#if IS_SDK_IOS_11
if ([TiUtils isIOSVersionOrGreater:@"11.0"]) {
showBackgroundLocationIndicator = value;
return;
}
#endif
DebugLog(@"[ERROR] The showBackgroundLocationIndicator property is only available on iOS 11.0+. Ignoring call ...");
}

Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiAppiOSUserNotificationCenterProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,11 @@ - (void)requestUserNotificationSettings:(id)callback
@"carPlaySetting" : @([settings carPlaySetting]),
@"alertStyle" : @([settings alertStyle])
} mutableCopy];
#if IS_SDK_IOS_11
if ([TiUtils isIOSVersionOrGreater:@"11.0"]) {
propertiesDict[@"showPreviewsSetting"] = @([settings showPreviewsSetting]);
}
#endif
#if IS_SDK_IOS_12
if ([TiUtils isIOSVersionOrGreater:@"12.0"]) {
propertiesDict[@"criticalAlertSetting"] = @([settings criticalAlertSetting]);
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiUIListView.m
Original file line number Diff line number Diff line change
Expand Up @@ -2198,6 +2198,7 @@ - (void)viewResignFocus

- (void)viewGetFocus
{
#if IS_SDK_IOS_11
if (isSearchBarInNavigation) {
id proxy = [(TiViewProxy *)self.proxy parent];
while ([proxy isKindOfClass:[TiViewProxy class]] && ![proxy isKindOfClass:[TiWindowProxy class]]) {
Expand All @@ -2213,6 +2214,7 @@ - (void)viewGetFocus
controller.navigationItem.searchController = searchController;
}
}
#endif

if (isSearched && self.searchedString && ![searchController isActive]) {
isSearched = NO;
Expand Down
4 changes: 4 additions & 0 deletions iphone/Classes/TiUINavigationWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ - (void)navigationController:(UINavigationController *)navigationController will
}
}
TiWindowProxy *theWindow = (TiWindowProxy *)[(TiViewController *)viewController proxy];
#if IS_SDK_IOS_11
[theWindow processForSafeArea];
#endif
if ((theWindow != rootWindow) && [theWindow opening]) {
[theWindow windowWillOpen];
[theWindow windowDidOpen];
Expand Down Expand Up @@ -384,6 +386,7 @@ - (void)viewDidDisappear:(BOOL)animated
[super viewDidDisappear:animated];
}

#if IS_SDK_IOS_11
- (BOOL)homeIndicatorAutoHide
{
UIViewController *topVC = [navController topViewController];
Expand All @@ -395,6 +398,7 @@ - (BOOL)homeIndicatorAutoHide
}
return [super homeIndicatorAutoHide];
}
#endif

- (BOOL)hidesStatusBar
{
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiUIScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ - (TiUIScrollViewImpl *)scrollView

- (void)adjustScrollViewInsets
{
#if IS_SDK_IOS_11
id viewProxy = self.proxy;
while (viewProxy && ![viewProxy isKindOfClass:[TiWindowProxy class]]) {
viewProxy = [viewProxy parent];
Expand All @@ -159,6 +160,7 @@ - (void)adjustScrollViewInsets
[scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
}
}
#endif
}

- (id)accessibilityElement
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiUITabGroupProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ - (UIStatusBarStyle)preferredStatusBarStyle;
return [super preferredStatusBarStyle];
}

#if IS_SDK_IOS_11
- (BOOL)homeIndicatorAutoHide
{
UITabBarController *tabController = [(TiUITabGroup *)[self view] tabController];
Expand All @@ -276,6 +277,7 @@ - (BOOL)homeIndicatorAutoHide
}
return [super homeIndicatorAutoHide];
}
#endif

- (BOOL)hidesStatusBar
{
Expand Down
8 changes: 6 additions & 2 deletions iphone/Classes/TiUITabProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,9 @@ - (void)openWindow:(NSArray *)args
TiWindowProxy *window = [args objectAtIndex:0];
ENSURE_TYPE(window, TiWindowProxy);

#if IS_SDK_IOS_11
[window processForSafeArea];

#endif
if (window == rootWindow) {
[rootWindow windowWillOpen];
[rootWindow windowDidOpen];
Expand Down Expand Up @@ -383,7 +384,9 @@ - (void)handleWillShowViewController:(UIViewController *)viewController animated
}
}
TiWindowProxy *theWindow = (TiWindowProxy *)[(TiViewController *)viewController proxy];
#if IS_SDK_IOS_11
[theWindow processForSafeArea];
#endif
if (theWindow == rootWindow) {
//This is probably too late for the root view controller.
//Figure out how to call open before this callback
Expand Down Expand Up @@ -738,6 +741,7 @@ - (void)popToRootWindow:(id)args

@synthesize parentOrientationController;

#if IS_SDK_IOS_11
- (BOOL)homeIndicatorAutoHide
{
if (rootWindow == nil) {
Expand All @@ -754,7 +758,7 @@ - (BOOL)homeIndicatorAutoHide
}
return NO;
}

#endif
- (BOOL)hidesStatusBar
{
if (rootWindow == nil) {
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiUITableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -2355,6 +2355,7 @@ - (void)viewResignFocus

- (void)viewGetFocus
{
#if IS_SDK_IOS_11
if (isSearchBarInNavigation) {
id proxy = [(TiViewProxy *)self.proxy parent];
while ([proxy isKindOfClass:[TiViewProxy class]] && ![proxy isKindOfClass:[TiWindowProxy class]]) {
Expand All @@ -2370,6 +2371,7 @@ - (void)viewGetFocus
controller.navigationItem.searchController = searchController;
}
}
#endif
if (!hideOnSearch && isSearched && self.searchedString && ![searchController isActive]) {
isSearched = NO;
searchController.searchBar.text = self.searchedString;
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiUIWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@

@end

#if IS_SDK_IOS_11
@interface WebAppProtocolHandler : NSObject <WKURLSchemeHandler> {
}

+ (NSString *)specialProtocolScheme;

@end
#endif

#endif
4 changes: 4 additions & 0 deletions iphone/Classes/TiUIWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ - (WKWebView *)webView

[config setUserContentController:controller];

#if IS_SDK_IOS_11
if ([TiUtils isIOSVersionOrGreater:@"11.0"]) {
if (![WKWebView handlesURLScheme:[WebAppProtocolHandler specialProtocolScheme]]) {
[config setURLSchemeHandler:[[WebAppProtocolHandler alloc] init] forURLScheme:[WebAppProtocolHandler specialProtocolScheme]];
}
}
#endif

_willHandleTouches = [TiUtils boolValue:[[self proxy] valueForKey:@"willHandleTouches"] def:YES];

Expand Down Expand Up @@ -1356,6 +1358,7 @@ - (NSHTTPCookie *)cookieForString:(NSString *)cookieStr

@end

#if IS_SDK_IOS_11
@implementation WebAppProtocolHandler

+ (NSString *)specialProtocolScheme
Expand Down Expand Up @@ -1406,5 +1409,6 @@ - (void)webView:(nonnull WKWebView *)webView stopURLSchemeTask:(nonnull id<WKURL
}

@end
#endif

#endif
2 changes: 2 additions & 0 deletions iphone/Classes/TiUIiOSProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,11 @@
@property (nonatomic, readonly) NSNumber *BLUR_EFFECT_STYLE_DARK;
#endif

#if IS_SDK_IOS_11
@property (nonatomic, readonly) NSNumber *LARGE_TITLE_DISPLAY_MODE_AUTOMATIC;
@property (nonatomic, readonly) NSNumber *LARGE_TITLE_DISPLAY_MODE_ALWAYS;
@property (nonatomic, readonly) NSNumber *LARGE_TITLE_DISPLAY_MODE_NEVER;
#endif

/**
Checks the force touch capibility of the current device.
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiUIiOSProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,11 @@ - (id)createFeedbackGenerator:(id)args
MAKE_SYSTEM_PROP(FEEDBACK_GENERATOR_IMPACT_STYLE_HEAVY, UIImpactFeedbackStyleHeavy);
#endif

#if IS_SDK_IOS_11
MAKE_SYSTEM_PROP(LARGE_TITLE_DISPLAY_MODE_AUTOMATIC, UINavigationItemLargeTitleDisplayModeAutomatic);
MAKE_SYSTEM_PROP(LARGE_TITLE_DISPLAY_MODE_ALWAYS, UINavigationItemLargeTitleDisplayModeAlways);
MAKE_SYSTEM_PROP(LARGE_TITLE_DISPLAY_MODE_NEVER, UINavigationItemLargeTitleDisplayModeNever);
#endif

#ifdef USE_TI_UIWEBVIEW

Expand Down
4 changes: 4 additions & 0 deletions iphone/Classes/TiUIiOSSplitWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,10 @@ - (void)setMasterView_:(id)args
RELEASE_TO_NIL(masterProxy);
masterProxy = [args retain];

#if IS_SDK_IOS_11
TiWindowProxy *masterWindowProxy = (TiWindowProxy *)masterProxy;
masterWindowProxy.isMasterWindow = YES;
#endif

if (viewsInitialized) {
[self initProxy:masterProxy withWrapper:masterViewWrapper];
Expand All @@ -280,8 +282,10 @@ - (void)setDetailView_:(id)args
RELEASE_TO_NIL(detailProxy);
detailProxy = [args retain];

#if IS_SDK_IOS_11
TiWindowProxy *detailWindowProxy = (TiWindowProxy *)detailProxy;
detailWindowProxy.isDetailWindow = YES;
#endif

if (viewsInitialized) {
[self initProxy:detailProxy withWrapper:detailViewWrapper];
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/UIModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,10 @@ - (NSNumber *)ATTRIBUTE_LINE_BREAK_BY_TRUNCATING_MIDDLE
MAKE_SYSTEM_STR(AUTOFILL_TYPE_URL, UITextContentTypeURL);
MAKE_SYSTEM_STR(AUTOFILL_TYPE_CARD_NUMBER, UITextContentTypeCreditCardNumber);

#if IS_SDK_IOS_11
MAKE_SYSTEM_STR(AUTOFILL_TYPE_USERNAME, UITextContentTypeUsername);
MAKE_SYSTEM_STR(AUTOFILL_TYPE_PASSWORD, UITextContentTypePassword);
#endif

#if IS_SDK_IOS_12
MAKE_SYSTEM_STR(AUTOFILL_TYPE_NEW_PASSWORD, UITextContentTypeNewPassword);
Expand Down
6 changes: 6 additions & 0 deletions iphone/iphone/Titanium_Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@
#else
#define IS_SDK_IOS_12 false
#endif

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
#define IS_SDK_IOS_11 true
#else
#define IS_SDK_IOS_11 false
#endif
4 changes: 2 additions & 2 deletions iphone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"minIosVersion": "9.0",
"minWatchosVersion": "2.0",
"vendorDependencies": {
"xcode": ">=9.0 <=11.x",
"ios sdk": ">=10.0 <=13.x"
ewanharris marked this conversation as resolved.
Show resolved Hide resolved
"xcode": ">=8.0 <=11.x",
"ios sdk": ">=9.0 <=13.x"
},
"repository": {
"type": "git",
Expand Down