diff --git a/iphone/Classes/AppModule.m b/iphone/Classes/AppModule.m index b2dcdf3e7a4..1798d02ae65 100644 --- a/iphone/Classes/AppModule.m +++ b/iphone/Classes/AppModule.m @@ -7,7 +7,6 @@ #ifdef USE_TI_APP #import "AppModule.h" -#import "TiUtils+Addons.h" #import #import #import diff --git a/iphone/Classes/GeolocationModule.m b/iphone/Classes/GeolocationModule.m index d7f014c2c0b..19d1d43a6cc 100644 --- a/iphone/Classes/GeolocationModule.m +++ b/iphone/Classes/GeolocationModule.m @@ -7,7 +7,6 @@ #ifdef USE_TI_GEOLOCATION #import "GeolocationModule.h" -#import "TiUtils+Addons.h" #import #import #import diff --git a/iphone/Classes/PlatformModule.m b/iphone/Classes/PlatformModule.m index 9bbb83cf8aa..64f7a7db190 100644 --- a/iphone/Classes/PlatformModule.m +++ b/iphone/Classes/PlatformModule.m @@ -8,7 +8,6 @@ #import "PlatformModule.h" #import "TiPlatformDisplayCaps.h" -#import "TiUtils+Addons.h" #import #import diff --git a/iphone/Classes/TiUtils+Addons.h b/iphone/Classes/TiUtils+Addons.h deleted file mode 100644 index f9e748a0a88..00000000000 --- a/iphone/Classes/TiUtils+Addons.h +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Appcelerator Titanium Mobile - * Copyright (c) 2019-present by Appcelerator, Inc. All Rights Reserved. - * Licensed under the terms of the Apache Public License - * Please see the LICENSE included with this distribution for details. - */ - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface TiUtils (Addons) - -/** - Returns a unique identifier for this app. - - This will change upon a fresh install. - - @return UUID for this app. - */ -+ (NSString *)appIdentifier; - -@end - -NS_ASSUME_NONNULL_END diff --git a/iphone/Classes/TiUtils+Addons.m b/iphone/Classes/TiUtils+Addons.m deleted file mode 100644 index a2d8f807f66..00000000000 --- a/iphone/Classes/TiUtils+Addons.m +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Appcelerator Titanium Mobile - * Copyright (c) 2019-present by Appcelerator, Inc. All Rights Reserved. - * Licensed under the terms of the Apache Public License - * Please see the LICENSE included with this distribution for details. - */ - -#import "TiUtils+Addons.h" - -static NSString *kAppUUIDString = @"com.appcelerator.uuid"; - -@implementation TiUtils (Addons) - -+ (NSString *)appIdentifier -{ - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSString *uid = [defaults stringForKey:kAppUUIDString]; - if (uid == nil) { - uid = [TiUtils createUUID]; - [defaults setObject:uid forKey:kAppUUIDString]; - [defaults synchronize]; - } - - return uid; -} - -@end diff --git a/iphone/Classes/TiUtils+Addons.swift b/iphone/Classes/TiUtils+Addons.swift new file mode 100644 index 00000000000..102e71b6b28 --- /dev/null +++ b/iphone/Classes/TiUtils+Addons.swift @@ -0,0 +1,33 @@ +/** + * Appcelerator Titanium Mobile + * Copyright (c) 2020-present by Appcelerator, Inc. All Rights Reserved. + * Licensed under the terms of the Apache Public License + * Please see the LICENSE included with this distribution for details. + */ + +import TitaniumKit + +extension TiUtils { + + /** + Returns a unique identifier for this app. + + This will change upon a fresh install. + + @return UUID for this app. + */ + @objc(appIdentifier) + class func appIdentifier() -> String? { + let kAppUUIDString = "com.appcelerator.uuid" + let defaults = UserDefaults.standard + var uid = defaults.string(forKey: kAppUUIDString) + + if uid == nil { + uid = TiUtils.createUUID() + defaults.set(uid, forKey: kAppUUIDString) + defaults.synchronize() + } + + return uid + } +} diff --git a/iphone/TitaniumKit/TitaniumKit.xcodeproj/project.pbxproj b/iphone/TitaniumKit/TitaniumKit.xcodeproj/project.pbxproj index 11a1daffbd9..0414578f821 100644 --- a/iphone/TitaniumKit/TitaniumKit.xcodeproj/project.pbxproj +++ b/iphone/TitaniumKit/TitaniumKit.xcodeproj/project.pbxproj @@ -1010,7 +1010,7 @@ "$(PROJECT_DIR)/TitaniumKit/Libraries/APSAnalytics", "$(PROJECT_DIR)/TitaniumKit/Libraries/APSHTTPClient", ); - ONLY_ACTIVE_ARCH = NO; + ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = "-DTARGET_OS_IPHONE"; OTHER_LDFLAGS = ( "$(inherited)", diff --git a/iphone/TitaniumKit/TitaniumKit.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme b/iphone/TitaniumKit/TitaniumKit.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme index cbb342ad849..e70d6e59b3b 100644 --- a/iphone/TitaniumKit/TitaniumKit.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme +++ b/iphone/TitaniumKit/TitaniumKit.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme @@ -29,11 +29,9 @@ shouldUseLaunchSchemeArgsEnv = "YES"> - - - - { should(Ti.Platform).have.readOnlyProperty('id').which.is.a.String(); - // TODO Verify format?! + if (OS_IOS) { + const platformId = Ti.Platform.id; + should(platformId).be.a.String(); + should(platformId.length).eql(36); + // Verify format using regexp! + platformId.should.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i); + } }); it('.locale', () => { @@ -225,6 +231,13 @@ describe('Titanium.Platform', function () { it('.macaddress', () => { should(Ti.Platform).have.readOnlyProperty('macaddress').which.is.a.String(); + if (OS_IOS) { + const macaddress = Ti.Platform.macaddress; + should(macaddress).be.a.String(); + should(macaddress.length).eql(36); + // Verify format using regexp! + macaddress.should.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i); + } }); it('.manufacturer', () => {