Skip to content

Commit

Permalink
Merge pull request #208 from SimpleNexus/dev
Browse files Browse the repository at this point in the history
Adds Support for Swift Package Manager
  • Loading branch information
rolandleth authored Apr 12, 2024
2 parents 5a0079a + 416e20d commit 85f4f79
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 6 deletions.
14 changes: 12 additions & 2 deletions LTHPasscodeViewController/LTHPasscodeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@
#import "LTHKeychainUtils.h"
#import <LocalAuthentication/LocalAuthentication.h>

#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

#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]
#define LTHPasscodeViewControllerStrings(key) [LTHLocalizedString(key) length] == 0 \
? [[NSBundle bundleWithPath: [SWIFTPM_MODULE_BUNDLE pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName] \
: LTHLocalizedString(key)
#endif

// MARK: Please read
Expand Down Expand Up @@ -147,6 +156,7 @@ + (void)useKeychain:(BOOL)useKeychain {


#pragma mark - Private methods

- (void)_close {
if (_displayedAsLockScreen) [self _dismissMe];
else [self _cancelAndDismissMe];
Expand Down
28 changes: 28 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version:5.3
import PackageDescription

let package = Package(
name: "LTHPasscodeViewController",
defaultLocalization: "en",
platforms: [
.iOS(.v10)
],
products: [
.library(
name: "LTHPasscodeViewController",
targets: ["LTHPasscodeViewController"]
),
],
targets: [
.target(
name: "LTHPasscodeViewController",
path: ".",
exclude: ["Demo", "CHANGELOG.md", "README.md"],
resources: [
.process("Localizations/LTHPasscodeViewController.bundle"),
.process("LICENSE.txt")
],
publicHeadersPath: "LTHPasscodeViewController"
)
]
)
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
# LTHPasscodeViewController
Simple to use iOS 7 style Passcode - the one you get in Settings when changing your passcode.

# Installation

### 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!

### 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.

# 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:

Expand All @@ -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];
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 85f4f79

Please sign in to comment.