Skip to content

Commit 85f4f79

Browse files
authored
Merge pull request #208 from SimpleNexus/dev
Adds Support for Swift Package Manager
2 parents 5a0079a + 416e20d commit 85f4f79

File tree

3 files changed

+67
-6
lines changed

3 files changed

+67
-6
lines changed

LTHPasscodeViewController/LTHPasscodeViewController.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,22 @@
1010
#import "LTHKeychainUtils.h"
1111
#import <LocalAuthentication/LocalAuthentication.h>
1212

13+
#ifndef SWIFTPM_MODULE_BUNDLE
14+
#define SWIFTPM_MODULE_BUNDLE [NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]]
15+
#endif
16+
1317
#define LTHiPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
1418

1519
#define LTHFailedAttemptLabelHeight [_failedAttemptLabel.text sizeWithAttributes: @{NSFontAttributeName : _labelFont}].height
1620

21+
#ifndef LTHLocalizedString
22+
#define LTHLocalizedString(key) [[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName]
23+
#endif
24+
1725
#ifndef LTHPasscodeViewControllerStrings
18-
#define LTHPasscodeViewControllerStrings(key) \
19-
[[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName]
26+
#define LTHPasscodeViewControllerStrings(key) [LTHLocalizedString(key) length] == 0 \
27+
? [[NSBundle bundleWithPath: [SWIFTPM_MODULE_BUNDLE pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] \
28+
: LTHLocalizedString(key)
2029
#endif
2130

2231
// MARK: Please read
@@ -147,6 +156,7 @@ + (void)useKeychain:(BOOL)useKeychain {
147156

148157

149158
#pragma mark - Private methods
159+
150160
- (void)_close {
151161
if (_displayedAsLockScreen) [self _dismissMe];
152162
else [self _cancelAndDismissMe];

Package.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// swift-tools-version:5.3
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "LTHPasscodeViewController",
6+
defaultLocalization: "en",
7+
platforms: [
8+
.iOS(.v10)
9+
],
10+
products: [
11+
.library(
12+
name: "LTHPasscodeViewController",
13+
targets: ["LTHPasscodeViewController"]
14+
),
15+
],
16+
targets: [
17+
.target(
18+
name: "LTHPasscodeViewController",
19+
path: ".",
20+
exclude: ["Demo", "CHANGELOG.md", "README.md"],
21+
resources: [
22+
.process("Localizations/LTHPasscodeViewController.bundle"),
23+
.process("LICENSE.txt")
24+
],
25+
publicHeadersPath: "LTHPasscodeViewController"
26+
)
27+
]
28+
)

README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
# LTHPasscodeViewController
22
Simple to use iOS 7 style Passcode - the one you get in Settings when changing your passcode.
33

4+
# Installation
5+
6+
### Swift Package Manager
7+
8+
__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._
9+
10+
1. Go to File > Swift Packages > Add Package Dependency...
11+
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:
12+
3. Select what version you want to use, then hit next (Xcode will automatically suggest the current version Up to Next Major).
13+
4. Select the `LTHPasscodeViewController` library and then hit finish.
14+
5. You're done!
15+
16+
### CocoaPods
17+
18+
[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`:
19+
20+
```ruby
21+
pod 'LTHPasscodeViewController', '~> 4.0.1'
22+
```
23+
24+
### Manually
25+
26+
Simply clone the repo and drag the contents of `LTHPasscodeViewController` to your project.
27+
428
# How to use
5-
Drag the contents of `LTHPasscodeViewController` to your project, or add `pod 'LTHPasscodeViewController'` to your Podfile (preffered).
629

730
If your app uses extensions, `LTH_IS_APP_EXTENSION` needs to be defined:
831

@@ -14,8 +37,8 @@ Example, called in `application:didFinishLaunchingWithOptions`:
1437
```objc
1538
[LTHPasscodeViewController useKeychain:NO];
1639
if ([LTHPasscodeViewController doesPasscodeExist]) {
17-
if ([LTHPasscodeViewController didPasscodeTimerEnd])
18-
[[LTHPasscodeViewController sharedUser] showLockScreenWithAnimation:YES
40+
if ([LTHPasscodeViewController didPasscodeTimerEnd])
41+
[[LTHPasscodeViewController sharedUser] showLockScreenWithAnimation:YES
1942
withLogout:NO
2043
andLogoutTitle:nil];
2144
}
@@ -46,7 +69,7 @@ if ([LTHPasscodeViewController doesPasscodeExist]) {
4669

4770
```objc
4871
/**
49-
@param viewController The view controller where the passcode view controller will be displayed.
72+
@param viewController The view controller where the passcode view controller will be displayed.
5073
@param asModal Set to YES to present as a modal, or to NO to push on the current nav stack.
5174
*/
5275
- (void)showForEnablingPasscodeInViewController:(UIViewController *)viewController asModal:(BOOL)isModal;

0 commit comments

Comments
 (0)