Skip to content

Commit

Permalink
Merge pull request #1 from scr037/SPM_support
Browse files Browse the repository at this point in the history
Adding Swift Package support
  • Loading branch information
scr037 authored Apr 9, 2021
2 parents a1c039c + 3df2c73 commit 71582e3
Show file tree
Hide file tree
Showing 17 changed files with 57 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "ZxcvbnSwift",
platforms: [
.iOS(.v8)
],
products: [
.library(
name: "ZxcvbnSwift",
targets: ["ZxcvbnSwift"]),
],
dependencies: [],
targets: [
.target(
name: "ZxcvbnSwift",
dependencies: [],
exclude: ["Info.plist"],
resources: [
.process("Resources")
],
publicHeadersPath: ".",
cSettings: [
.headerSearchPath("Public"),
.headerSearchPath("Internal")
],
linkerSettings: [
.linkedFramework("UIKit", .when(platforms: [.iOS]))
]
)
]
)
File renamed without changes.
File renamed without changes.
17 changes: 15 additions & 2 deletions ZxcvbnSwift/DBMatcher.m → Sources/ZxcvbnSwift/DBMatcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,14 @@ - (NSArray *)loadFrequencyLists
{
NSMutableArray *dictionaryMatchers = [[NSMutableArray alloc] init];

NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"frequency_lists" ofType:@"json"];
NSString *filePath = @"";

#if SWIFT_PACKAGE
filePath = [SWIFTPM_MODULE_BUNDLE pathForResource: @"frequency_lists" ofType: @"json"];
#else
filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"frequency_lists" ofType:@"json"];
#endif

NSData *data = [NSData dataWithContentsOfFile:filePath];

NSError *error;
Expand All @@ -629,7 +636,13 @@ - (NSArray *)loadFrequencyLists

- (NSDictionary *)loadAdjacencyGraphs
{
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"adjacency_graphs" ofType:@"json"];
NSString *filePath = @"";
#if SWIFT_PACKAGE
filePath = [SWIFTPM_MODULE_BUNDLE pathForResource: @"adjacency_graphs" ofType: @"json"];
#else
filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"adjacency_graphs" ofType:@"json"];
#endif

NSData *data = [NSData dataWithContentsOfFile:filePath];

NSError *error;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 71582e3

Please sign in to comment.