From 18b2878af73248a5ea2847c9fb710b5b6759d70c Mon Sep 17 00:00:00 2001 From: Jason Rodriguez Date: Sat, 27 Mar 2021 07:22:12 -0700 Subject: [PATCH 01/11] Adds package.swift --- Package.swift | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Package.swift diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..9e25c9c --- /dev/null +++ b/Package.swift @@ -0,0 +1,25 @@ +// swift-tools-version:5.3 +import PackageDescription + +let package = Package( + name: "LTHPasscodeViewController", + platforms: [ + .iOS(.v10) + ], + products: [ + .library( + name: "LTHPasscodeViewController", + targets: ["LTHPasscodeViewController"] + ), + ], + targets: [ + .target( + name: "LTHPasscodeViewController", + path: ".", + exclude: ["Demo", "CHANGELOG.md", "LICENSE.txt", "README.md"], + sources: ["LTHPasscodeViewController/LTHKeychainUtils.h", "LTHPasscodeViewController/LTHKeychainUtils.m", "LTHPasscodeViewController/LTHPasscodeViewController.h", "LTHPasscodeViewController/LTHPasscodeViewController.m"], + resources: [.copy("Localizations")], + publicHeadersPath: "LTHPasscodeViewController" + ) + ] +) From 2f7bfd34d9886c46a26307f82af49c46fa5ab918 Mon Sep 17 00:00:00 2001 From: Jason Rodriguez Date: Sat, 27 Mar 2021 07:46:45 -0700 Subject: [PATCH 02/11] updates package.swift --- Package.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 9e25c9c..be79f5d 100644 --- a/Package.swift +++ b/Package.swift @@ -3,6 +3,7 @@ import PackageDescription let package = Package( name: "LTHPasscodeViewController", + defaultLocalization: "en", platforms: [ .iOS(.v10) ], @@ -18,7 +19,7 @@ let package = Package( path: ".", exclude: ["Demo", "CHANGELOG.md", "LICENSE.txt", "README.md"], sources: ["LTHPasscodeViewController/LTHKeychainUtils.h", "LTHPasscodeViewController/LTHKeychainUtils.m", "LTHPasscodeViewController/LTHPasscodeViewController.h", "LTHPasscodeViewController/LTHPasscodeViewController.m"], - resources: [.copy("Localizations")], + resources: [.process("Localizations/LTHPasscodeViewController.bundle")], publicHeadersPath: "LTHPasscodeViewController" ) ] From 21469b75bd1321ffad57b109d7d806d549ab0c73 Mon Sep 17 00:00:00 2001 From: Jason Rodriguez Date: Sat, 27 Mar 2021 07:46:50 -0700 Subject: [PATCH 03/11] updates readme --- README.md | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ba6218d..371fb5c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,31 @@ # LTHPasscodeViewController Simple to use iOS 7 style Passcode - the one you get in Settings when changing your passcode. +# Installation + +### CocoaPods + +[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate LTHPasscodeViewController into your Xcode project using CocoaPods, specify it in your `Podfile`: + +```ruby +pod 'LTHPasscodeViewController', '~> 4.0.1' +``` + +### Swift Package Manager + +__NOTE__: _These instructions are intended for usage on Xcode 11 and higher. Xcode 11 is the first version of Xcode that integrates Swift Package manager and makes it way easier to use than it was at the command line. If you are using older versions of Xcode, we recommend using CocoaPods._ + +1. Go to File > Swift Packages > Add Package Dependency... +2. Paste the URL to the LTHPasscodeViewController repo on GitHub (https://github.com/rolandleth/LTHPasscodeViewController.git) into the search bar, then hit the Next button: +3. Select what version you want to use, then hit next (Xcode will automatically suggest the current version Up to Next Major). +4. Select the `LTHPasscodeViewController` library and then hit finish. +5. You're done! + +### Manually + +Simply clone the repo and drag the contents of `LTHPasscodeViewController` to your project. + # How to use -Drag the contents of `LTHPasscodeViewController` to your project, or add `pod 'LTHPasscodeViewController'` to your Podfile (preffered). If your app uses extensions, `LTH_IS_APP_EXTENSION` needs to be defined: @@ -14,8 +37,8 @@ Example, called in `application:didFinishLaunchingWithOptions`: ```objc [LTHPasscodeViewController useKeychain:NO]; if ([LTHPasscodeViewController doesPasscodeExist]) { - if ([LTHPasscodeViewController didPasscodeTimerEnd]) - [[LTHPasscodeViewController sharedUser] showLockScreenWithAnimation:YES + if ([LTHPasscodeViewController didPasscodeTimerEnd]) + [[LTHPasscodeViewController sharedUser] showLockScreenWithAnimation:YES withLogout:NO andLogoutTitle:nil]; } @@ -46,7 +69,7 @@ if ([LTHPasscodeViewController doesPasscodeExist]) { ```objc /** - @param viewController The view controller where the passcode view controller will be displayed. + @param viewController The view controller where the passcode view controller will be displayed. @param asModal Set to YES to present as a modal, or to NO to push on the current nav stack. */ - (void)showForEnablingPasscodeInViewController:(UIViewController *)viewController asModal:(BOOL)isModal; From 6fa9110adaf5ef30b0c372c61099b59d032b2233 Mon Sep 17 00:00:00 2001 From: Jason Rodriguez Date: Sat, 27 Mar 2021 08:24:24 -0700 Subject: [PATCH 04/11] updates to also include SPM bundle --- .../LTHPasscodeViewController.m | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/LTHPasscodeViewController/LTHPasscodeViewController.m b/LTHPasscodeViewController/LTHPasscodeViewController.m index c18adb9..64e9e05 100755 --- a/LTHPasscodeViewController/LTHPasscodeViewController.m +++ b/LTHPasscodeViewController/LTHPasscodeViewController.m @@ -14,11 +14,22 @@ #define LTHFailedAttemptLabelHeight [_failedAttemptLabel.text sizeWithAttributes: @{NSFontAttributeName : _labelFont}].height +//#ifndef LTHPasscodeViewControllerStrings +//#define LTHPasscodeViewControllerStrings(key) \ +//NSString *localizedString = [[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] \ +//printf(localizedString); \ +//if ([localizedString length] == 0) { \ +// printf([SWIFTPM_MODULE_BUNDLE localizedStringForKey: (key) value:@"" table:_localizationTableName]); \ +// return [SWIFTPM_MODULE_BUNDLE localizedStringForKey: (key) value:@"" table:_localizationTableName] \ +//} else { \ +// return localizedString \ +//} +//#endif + #ifndef LTHPasscodeViewControllerStrings #define LTHPasscodeViewControllerStrings(key) \ -[[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] +[[[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] length] == 0 ? [SWIFTPM_MODULE_BUNDLE localizedStringForKey: (key) value:@"" table:_localizationTableName] : [[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] #endif - // MARK: Please read /* Using windows[0] instead of keyWindow due to an issue with UIAlertViews / UIActionSheets - displaying the lockscreen when an alertView / actionSheet is visible, or displaying one after the lockscreen is visible results in a few cases: @@ -147,6 +158,7 @@ + (void)useKeychain:(BOOL)useKeychain { #pragma mark - Private methods + - (void)_close { if (_displayedAsLockScreen) [self _dismissMe]; else [self _cancelAndDismissMe]; From 1b894f589869f919dda32ce39c262f4d3bb3923b Mon Sep 17 00:00:00 2001 From: Jason Rodriguez Date: Sat, 27 Mar 2021 08:31:12 -0700 Subject: [PATCH 05/11] removes unused comments --- .../LTHPasscodeViewController.m | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/LTHPasscodeViewController/LTHPasscodeViewController.m b/LTHPasscodeViewController/LTHPasscodeViewController.m index 64e9e05..73c8822 100755 --- a/LTHPasscodeViewController/LTHPasscodeViewController.m +++ b/LTHPasscodeViewController/LTHPasscodeViewController.m @@ -14,22 +14,11 @@ #define LTHFailedAttemptLabelHeight [_failedAttemptLabel.text sizeWithAttributes: @{NSFontAttributeName : _labelFont}].height -//#ifndef LTHPasscodeViewControllerStrings -//#define LTHPasscodeViewControllerStrings(key) \ -//NSString *localizedString = [[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] \ -//printf(localizedString); \ -//if ([localizedString length] == 0) { \ -// printf([SWIFTPM_MODULE_BUNDLE localizedStringForKey: (key) value:@"" table:_localizationTableName]); \ -// return [SWIFTPM_MODULE_BUNDLE localizedStringForKey: (key) value:@"" table:_localizationTableName] \ -//} else { \ -// return localizedString \ -//} -//#endif - #ifndef LTHPasscodeViewControllerStrings #define LTHPasscodeViewControllerStrings(key) \ -[[[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] length] == 0 ? [SWIFTPM_MODULE_BUNDLE localizedStringForKey: (key) value:@"" table:_localizationTableName] : [[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] +[[[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] length] == 0 ? NSLocalizedString(key, bundle: .module, comment: "") : [[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] #endif + // MARK: Please read /* Using windows[0] instead of keyWindow due to an issue with UIAlertViews / UIActionSheets - displaying the lockscreen when an alertView / actionSheet is visible, or displaying one after the lockscreen is visible results in a few cases: From bea8c67aeae87ef4f77975a6132cfba132561585 Mon Sep 17 00:00:00 2001 From: Jason Rodriguez Date: Mon, 29 Mar 2021 08:09:09 -0700 Subject: [PATCH 06/11] Updates Package.swift to include latest changes, and cleans up some Objc code --- .../LTHPasscodeViewController.m | 9 +++++++-- Package.swift | 1 - README.md | 20 +++++++++---------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/LTHPasscodeViewController/LTHPasscodeViewController.m b/LTHPasscodeViewController/LTHPasscodeViewController.m index 73c8822..13938ab 100755 --- a/LTHPasscodeViewController/LTHPasscodeViewController.m +++ b/LTHPasscodeViewController/LTHPasscodeViewController.m @@ -14,9 +14,14 @@ #define LTHFailedAttemptLabelHeight [_failedAttemptLabel.text sizeWithAttributes: @{NSFontAttributeName : _labelFont}].height +#ifndef LTHLocalizedString +#define LTHLocalizedString(key) [[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] +#endif + #ifndef LTHPasscodeViewControllerStrings -#define LTHPasscodeViewControllerStrings(key) \ -[[[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] length] == 0 ? NSLocalizedString(key, bundle: .module, comment: "") : [[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] +#define LTHPasscodeViewControllerStrings(key) [LTHLocalizedString(key) length] == 0 \ + ? NSLocalizedString(key, bundle: .module) \ + : LTHLocalizedString(key) #endif // MARK: Please read diff --git a/Package.swift b/Package.swift index be79f5d..eed7214 100644 --- a/Package.swift +++ b/Package.swift @@ -18,7 +18,6 @@ let package = Package( name: "LTHPasscodeViewController", path: ".", exclude: ["Demo", "CHANGELOG.md", "LICENSE.txt", "README.md"], - sources: ["LTHPasscodeViewController/LTHKeychainUtils.h", "LTHPasscodeViewController/LTHKeychainUtils.m", "LTHPasscodeViewController/LTHPasscodeViewController.h", "LTHPasscodeViewController/LTHPasscodeViewController.m"], resources: [.process("Localizations/LTHPasscodeViewController.bundle")], publicHeadersPath: "LTHPasscodeViewController" ) diff --git a/README.md b/README.md index 371fb5c..a82fbe3 100644 --- a/README.md +++ b/README.md @@ -3,24 +3,24 @@ Simple to use iOS 7 style Passcode - the one you get in Settings when changing y # Installation -### CocoaPods - -[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate LTHPasscodeViewController into your Xcode project using CocoaPods, specify it in your `Podfile`: - -```ruby -pod 'LTHPasscodeViewController', '~> 4.0.1' -``` - ### Swift Package Manager __NOTE__: _These instructions are intended for usage on Xcode 11 and higher. Xcode 11 is the first version of Xcode that integrates Swift Package manager and makes it way easier to use than it was at the command line. If you are using older versions of Xcode, we recommend using CocoaPods._ 1. Go to File > Swift Packages > Add Package Dependency... -2. Paste the URL to the LTHPasscodeViewController repo on GitHub (https://github.com/rolandleth/LTHPasscodeViewController.git) into the search bar, then hit the Next button: +2. Paste the URL to the `LTHPasscodeViewController` repo on GitHub (https://github.com/rolandleth/LTHPasscodeViewController.git) into the search bar, then hit the Next button: 3. Select what version you want to use, then hit next (Xcode will automatically suggest the current version Up to Next Major). 4. Select the `LTHPasscodeViewController` library and then hit finish. 5. You're done! +### CocoaPods + +[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate `LTHPasscodeViewController` into your Xcode project using CocoaPods, specify it in your `Podfile`: + +```ruby +pod 'LTHPasscodeViewController', '~> 4.0.1' +``` + ### Manually Simply clone the repo and drag the contents of `LTHPasscodeViewController` to your project. @@ -69,7 +69,7 @@ if ([LTHPasscodeViewController doesPasscodeExist]) { ```objc /** - @param viewController The view controller where the passcode view controller will be displayed. + @param viewController The view controller where the passcode view controller will be displayed. @param asModal Set to YES to present as a modal, or to NO to push on the current nav stack. */ - (void)showForEnablingPasscodeInViewController:(UIViewController *)viewController asModal:(BOOL)isModal; From d35bd14fd53c181b2ed07999fe2acc461205d373 Mon Sep 17 00:00:00 2001 From: Jason Rodriguez Date: Thu, 8 Apr 2021 10:19:58 -0700 Subject: [PATCH 07/11] Adds licence back into processed files --- Package.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index eed7214..ac2fab5 100644 --- a/Package.swift +++ b/Package.swift @@ -17,8 +17,11 @@ let package = Package( .target( name: "LTHPasscodeViewController", path: ".", - exclude: ["Demo", "CHANGELOG.md", "LICENSE.txt", "README.md"], - resources: [.process("Localizations/LTHPasscodeViewController.bundle")], + exclude: ["Demo", "CHANGELOG.md", "README.md"], + resources: [ + .process("Localizations/LTHPasscodeViewController.bundle"), + .process("LICENSE.txt") + ], publicHeadersPath: "LTHPasscodeViewController" ) ] From d10df5dc67ac0abdbf50a95a50a133cbff81f472 Mon Sep 17 00:00:00 2001 From: Jason Rodriguez Date: Mon, 6 Dec 2021 09:36:03 -0700 Subject: [PATCH 08/11] Fixes Localization Bundle --- LTHPasscodeViewController/LTHPasscodeViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LTHPasscodeViewController/LTHPasscodeViewController.m b/LTHPasscodeViewController/LTHPasscodeViewController.m index 13938ab..566a924 100755 --- a/LTHPasscodeViewController/LTHPasscodeViewController.m +++ b/LTHPasscodeViewController/LTHPasscodeViewController.m @@ -20,7 +20,7 @@ #ifndef LTHPasscodeViewControllerStrings #define LTHPasscodeViewControllerStrings(key) [LTHLocalizedString(key) length] == 0 \ - ? NSLocalizedString(key, bundle: .module) \ + ? [SWIFTPM_MODULE_BUNDLE localizedStringForKey:key value:@"" table:_localizationTableName] \ : LTHLocalizedString(key) #endif From 765f7c246a31602769cc0d1bdabe7f3fd5a0183d Mon Sep 17 00:00:00 2001 From: Jason Rodriguez Date: Mon, 6 Dec 2021 09:56:46 -0700 Subject: [PATCH 09/11] fixes SPM bundle issues --- LTHPasscodeViewController/LTHPasscodeViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LTHPasscodeViewController/LTHPasscodeViewController.m b/LTHPasscodeViewController/LTHPasscodeViewController.m index 566a924..bfd9f96 100755 --- a/LTHPasscodeViewController/LTHPasscodeViewController.m +++ b/LTHPasscodeViewController/LTHPasscodeViewController.m @@ -20,7 +20,7 @@ #ifndef LTHPasscodeViewControllerStrings #define LTHPasscodeViewControllerStrings(key) [LTHLocalizedString(key) length] == 0 \ - ? [SWIFTPM_MODULE_BUNDLE localizedStringForKey:key value:@"" table:_localizationTableName] \ + ? [[NSBundle bundleWithPath: [SWIFTPM_MODULE_BUNDLE pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(@"Unlock using Touch ID") value:@"" table:_localizationTableName] \ : LTHLocalizedString(key) #endif From d89f08918139745d820bc69ce5adb316a3077837 Mon Sep 17 00:00:00 2001 From: Jason Rodriguez Date: Tue, 7 Dec 2021 09:39:11 -0700 Subject: [PATCH 10/11] Fixes the bad demo project --- LTHPasscodeViewController/LTHPasscodeViewController.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LTHPasscodeViewController/LTHPasscodeViewController.m b/LTHPasscodeViewController/LTHPasscodeViewController.m index bfd9f96..854be7f 100755 --- a/LTHPasscodeViewController/LTHPasscodeViewController.m +++ b/LTHPasscodeViewController/LTHPasscodeViewController.m @@ -10,6 +10,10 @@ #import "LTHKeychainUtils.h" #import +#ifndef SWIFTPM_MODULE_BUNDLE +#define SWIFTPM_MODULE_BUNDLE [NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] +#endif + #define LTHiPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) #define LTHFailedAttemptLabelHeight [_failedAttemptLabel.text sizeWithAttributes: @{NSFontAttributeName : _labelFont}].height From 416e20d54ffa43fd310ce5d199a920619a295f6b Mon Sep 17 00:00:00 2001 From: Jason Rodriguez Date: Tue, 14 Dec 2021 22:16:56 -0700 Subject: [PATCH 11/11] Remove static string typo I was testing localization and set the Touch ID string as the value for the string to use. I have since removed this and use the key parameter instead --- LTHPasscodeViewController/LTHPasscodeViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LTHPasscodeViewController/LTHPasscodeViewController.m b/LTHPasscodeViewController/LTHPasscodeViewController.m index 854be7f..6a272ae 100755 --- a/LTHPasscodeViewController/LTHPasscodeViewController.m +++ b/LTHPasscodeViewController/LTHPasscodeViewController.m @@ -24,7 +24,7 @@ #ifndef LTHPasscodeViewControllerStrings #define LTHPasscodeViewControllerStrings(key) [LTHLocalizedString(key) length] == 0 \ - ? [[NSBundle bundleWithPath: [SWIFTPM_MODULE_BUNDLE pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(@"Unlock using Touch ID") value:@"" table:_localizationTableName] \ + ? [[NSBundle bundleWithPath: [SWIFTPM_MODULE_BUNDLE pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] \ : LTHLocalizedString(key) #endif