Skip to content

Commit d770c04

Browse files
committed
Updated to Swift 3
1 parent 850fa38 commit d770c04

File tree

17 files changed

+284
-250
lines changed

17 files changed

+284
-250
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3
1+
3.0

EncryptedDATAStack.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'EncryptedDATAStack'
11-
s.version = '1.0.0'
11+
s.version = '2.0.0'
1212
s.summary = 'Set up your encrypted database with only 1 line of code!'
1313

1414
s.description = <<-DESC

EncryptedDATAStack/Classes/DATAStack.swift

Lines changed: 104 additions & 90 deletions
Large diffs are not rendered by default.

EncryptedDATAStack/Classes/EncryptedDATAStack.swift

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,17 @@
99
import EncryptedCoreData
1010

1111
public class EncryptedDATAStack: DATAStack {
12-
private var hashKey: String
12+
fileprivate var hashKey: String
1313

14-
override public var mainContext: NSManagedObjectContext {
15-
get {
16-
if _mainContext == nil {
17-
let context = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
18-
context.undoManager = nil
19-
context.mergePolicy = NSMergeByPropertyStoreTrumpMergePolicy
20-
context.persistentStoreCoordinator = self.persistentStoreCoordinator
21-
22-
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(DATAStack.mainContextDidSave(_:)), name: NSManagedObjectContextDidSaveNotification, object: context)
23-
24-
_mainContext = context
25-
}
26-
27-
return _mainContext!
28-
}
29-
}
3014

3115
override internal var persistentStoreCoordinator: NSPersistentStoreCoordinator {
3216
get {
3317
if _persistentStoreCoordinator == nil {
3418
let filePath = (storeName ?? modelName) + ".sqlite"
35-
let storeURL = containerURL.URLByAppendingPathComponent(filePath)
19+
let storeURL = containerURL.appendingPathComponent(filePath)
3620
let model = NSManagedObjectModel(bundle: self.modelBundle, name: self.modelName)
37-
let options = [EncryptedStorePassphraseKey: self.hashKey, EncryptedStoreDatabaseLocation: storeURL!]
38-
let persistentStoreCoordinator = EncryptedStore.makeStoreWithOptions(options, managedObjectModel: model)
21+
let options = [EncryptedStorePassphraseKey: self.hashKey, EncryptedStoreDatabaseLocation: storeURL] as [String : Any]
22+
let persistentStoreCoordinator = EncryptedStore.make(options: options, managedObjectModel: model)
3923

4024
_persistentStoreCoordinator = persistentStoreCoordinator
4125
}
@@ -53,25 +37,25 @@ public class EncryptedDATAStack: DATAStack {
5337

5438

5539

56-
public init(modelName: String, hashKey: String, bundle: NSBundle) {
40+
public init(modelName: String, hashKey: String, bundle: Bundle) {
5741
self.hashKey = hashKey
5842

59-
super.init(modelName: modelName, bundle: bundle, storeType: .SQLite)
43+
super.init(modelName: modelName, bundle: bundle, storeType: .sqLite)
6044
}
6145

6246

63-
public init(modelName: String, hashKey: String, bundle: NSBundle, storeName: String) {
47+
public init(modelName: String, hashKey: String, bundle: Bundle, storeName: String) {
6448
self.hashKey = hashKey
6549

66-
super.init(modelName: modelName, bundle: bundle, storeType: .SQLite, storeName: storeName)
50+
super.init(modelName: modelName, bundle: bundle, storeType: .sqLite, storeName: storeName)
6751
}
6852

6953

70-
public init(modelName: String, hashKey: String, bundle: NSBundle, storeName: String, containerURL: NSURL) {
54+
public init(modelName: String, hashKey: String, bundle: Bundle, storeName: String, containerURL: URL) {
7155

7256
self.hashKey = hashKey
7357

74-
super.init(modelName: modelName, bundle: bundle, storeType: .SQLite, storeName: storeName, containerURL: containerURL)
58+
super.init(modelName: modelName, bundle: bundle, storeType: .sqLite, storeName: storeName, containerURL: containerURL)
7559
}
7660

7761
}

EncryptedDATAStack/Classes/TestCheck.swift

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ struct TestCheck {
66
- returns: A Bool, `true` if you're on testing mode, `false` if you're not.
77
*/
88
static let isTesting: Bool = {
9-
let enviroment = NSProcessInfo.processInfo().environment
9+
let enviroment = ProcessInfo.processInfo.environment
1010
let serviceName = enviroment["XPC_SERVICE_NAME"]
1111
let injectBundle = enviroment["XCInjectBundle"]
1212
var isRunning = (enviroment["TRAVIS"] != nil || enviroment["XCTestConfigurationFilePath"] != nil)

Example/EncryptedDATAStack.xcodeproj/project.pbxproj

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
5B0418181DBAC35A0042CB03 /* DataModel.xcdatamodel in Sources */ = {isa = PBXBuildFile; fileRef = 5B0418151DBAC35A0042CB03 /* DataModel.xcdatamodel */; };
11-
5B0418191DBAC35A0042CB03 /* Model.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 5B0418161DBAC35A0042CB03 /* Model.xcdatamodeld */; };
1210
5B04181C1DBAC6A40042CB03 /* DemoSwift.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 5B04181A1DBAC6A40042CB03 /* DemoSwift.xcdatamodeld */; };
11+
5B680FF41DC2141D009C9780 /* LightweightMigrationModel.xcdatamodel in Sources */ = {isa = PBXBuildFile; fileRef = 5B680FF01DC2141D009C9780 /* LightweightMigrationModel.xcdatamodel */; };
12+
5B680FF51DC2141D009C9780 /* ModelGroup.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 5B680FF11DC2141D009C9780 /* ModelGroup.xcdatamodeld */; };
13+
5B680FF61DC2141D009C9780 /* SimpleModel.xcdatamodel in Sources */ = {isa = PBXBuildFile; fileRef = 5B680FF31DC2141D009C9780 /* SimpleModel.xcdatamodel */; };
1314
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; };
1415
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; };
1516
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
@@ -33,9 +34,10 @@
3334
058DE430F84E05D54406892C /* Pods_EncryptedDATAStack_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_EncryptedDATAStack_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3435
10B9588F8E42F393D02D713F /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
3536
576DB806B6E46B3E9F404B4D /* Pods_EncryptedDATAStack_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_EncryptedDATAStack_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
36-
5B0418151DBAC35A0042CB03 /* DataModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = DataModel.xcdatamodel; sourceTree = "<group>"; };
37-
5B0418171DBAC35A0042CB03 /* Model.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model.xcdatamodel; sourceTree = "<group>"; };
3837
5B04181B1DBAC6A40042CB03 /* DemoSwift.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = DemoSwift.xcdatamodel; sourceTree = "<group>"; };
38+
5B680FF01DC2141D009C9780 /* LightweightMigrationModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = LightweightMigrationModel.xcdatamodel; sourceTree = "<group>"; };
39+
5B680FF21DC2141D009C9780 /* ModelGroup.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = ModelGroup.xcdatamodel; sourceTree = "<group>"; };
40+
5B680FF31DC2141D009C9780 /* SimpleModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = SimpleModel.xcdatamodel; sourceTree = "<group>"; };
3941
5BBEB6F61DBB6917001B559B /* .travis.yml */ = {isa = PBXFileReference; lastKnownFileType = text; name = .travis.yml; path = ../.travis.yml; sourceTree = "<group>"; };
4042
5BBEB6F71DBB692C001B559B /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; name = .gitignore; path = ../.gitignore; sourceTree = "<group>"; };
4143
607FACD01AFB9204008FA782 /* EncryptedDATAStack_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = EncryptedDATAStack_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -121,8 +123,9 @@
121123
607FACE81AFB9204008FA782 /* Tests */ = {
122124
isa = PBXGroup;
123125
children = (
124-
5B0418151DBAC35A0042CB03 /* DataModel.xcdatamodel */,
125-
5B0418161DBAC35A0042CB03 /* Model.xcdatamodeld */,
126+
5B680FF01DC2141D009C9780 /* LightweightMigrationModel.xcdatamodel */,
127+
5B680FF11DC2141D009C9780 /* ModelGroup.xcdatamodeld */,
128+
5B680FF31DC2141D009C9780 /* SimpleModel.xcdatamodel */,
126129
607FACEB1AFB9204008FA782 /* Tests.swift */,
127130
607FACE91AFB9204008FA782 /* Supporting Files */,
128131
);
@@ -220,14 +223,16 @@
220223
isa = PBXProject;
221224
attributes = {
222225
LastSwiftUpdateCheck = 0720;
223-
LastUpgradeCheck = 0720;
226+
LastUpgradeCheck = 0800;
224227
ORGANIZATIONNAME = CocoaPods;
225228
TargetAttributes = {
226229
607FACCF1AFB9204008FA782 = {
227230
CreatedOnToolsVersion = 6.3.1;
231+
LastSwiftMigration = 0800;
228232
};
229233
607FACE41AFB9204008FA782 = {
230234
CreatedOnToolsVersion = 6.3.1;
235+
LastSwiftMigration = 0800;
231236
TestTargetID = 607FACCF1AFB9204008FA782;
232237
};
233238
};
@@ -328,7 +333,7 @@
328333
);
329334
runOnlyForDeploymentPostprocessing = 0;
330335
shellPath = /bin/sh;
331-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
336+
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
332337
showEnvVarsInLog = 0;
333338
};
334339
DDB2CA4D8D16A1178B9C88EB /* [CP] Check Pods Manifest.lock */ = {
@@ -343,7 +348,7 @@
343348
);
344349
runOnlyForDeploymentPostprocessing = 0;
345350
shellPath = /bin/sh;
346-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
351+
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
347352
showEnvVarsInLog = 0;
348353
};
349354
E27E22FDEAD1DF50B59E4C46 /* [CP] Embed Pods Frameworks */ = {
@@ -378,9 +383,10 @@
378383
isa = PBXSourcesBuildPhase;
379384
buildActionMask = 2147483647;
380385
files = (
381-
5B0418181DBAC35A0042CB03 /* DataModel.xcdatamodel in Sources */,
382-
5B0418191DBAC35A0042CB03 /* Model.xcdatamodeld in Sources */,
386+
5B680FF41DC2141D009C9780 /* LightweightMigrationModel.xcdatamodel in Sources */,
383387
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */,
388+
5B680FF61DC2141D009C9780 /* SimpleModel.xcdatamodel in Sources */,
389+
5B680FF51DC2141D009C9780 /* ModelGroup.xcdatamodeld in Sources */,
384390
);
385391
runOnlyForDeploymentPostprocessing = 0;
386392
};
@@ -419,8 +425,10 @@
419425
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
420426
CLANG_WARN_EMPTY_BODY = YES;
421427
CLANG_WARN_ENUM_CONVERSION = YES;
428+
CLANG_WARN_INFINITE_RECURSION = YES;
422429
CLANG_WARN_INT_CONVERSION = YES;
423430
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
431+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
424432
CLANG_WARN_UNREACHABLE_CODE = YES;
425433
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
426434
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -464,8 +472,10 @@
464472
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
465473
CLANG_WARN_EMPTY_BODY = YES;
466474
CLANG_WARN_ENUM_CONVERSION = YES;
475+
CLANG_WARN_INFINITE_RECURSION = YES;
467476
CLANG_WARN_INT_CONVERSION = YES;
468477
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
478+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
469479
CLANG_WARN_UNREACHABLE_CODE = YES;
470480
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
471481
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -484,6 +494,7 @@
484494
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
485495
MTL_ENABLE_DEBUG_INFO = NO;
486496
SDKROOT = iphoneos;
497+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
487498
VALIDATE_PRODUCT = YES;
488499
};
489500
name = Release;
@@ -492,27 +503,29 @@
492503
isa = XCBuildConfiguration;
493504
baseConfigurationReference = 8D58A2F0C5337A96061BF02D /* Pods-EncryptedDATAStack_Example.debug.xcconfig */;
494505
buildSettings = {
506+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
495507
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
496508
INFOPLIST_FILE = EncryptedDATAStack/Info.plist;
497509
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
498510
MODULE_NAME = ExampleApp;
499511
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
500512
PRODUCT_NAME = "$(TARGET_NAME)";
501-
SWIFT_VERSION = 2.3;
513+
SWIFT_VERSION = 3.0;
502514
};
503515
name = Debug;
504516
};
505517
607FACF11AFB9204008FA782 /* Release */ = {
506518
isa = XCBuildConfiguration;
507519
baseConfigurationReference = B9462BC3DF1C280412EFDCBB /* Pods-EncryptedDATAStack_Example.release.xcconfig */;
508520
buildSettings = {
521+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
509522
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
510523
INFOPLIST_FILE = EncryptedDATAStack/Info.plist;
511524
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
512525
MODULE_NAME = ExampleApp;
513526
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
514527
PRODUCT_NAME = "$(TARGET_NAME)";
515-
SWIFT_VERSION = 2.3;
528+
SWIFT_VERSION = 3.0;
516529
};
517530
name = Release;
518531
};
@@ -532,7 +545,7 @@
532545
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
533546
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
534547
PRODUCT_NAME = "$(TARGET_NAME)";
535-
SWIFT_VERSION = 2.3;
548+
SWIFT_VERSION = 3.0;
536549
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/EncryptedDATAStack_Example.app/EncryptedDATAStack_Example";
537550
};
538551
name = Debug;
@@ -549,7 +562,7 @@
549562
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
550563
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
551564
PRODUCT_NAME = "$(TARGET_NAME)";
552-
SWIFT_VERSION = 2.3;
565+
SWIFT_VERSION = 3.0;
553566
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/EncryptedDATAStack_Example.app/EncryptedDATAStack_Example";
554567
};
555568
name = Release;
@@ -587,23 +600,23 @@
587600
/* End XCConfigurationList section */
588601

589602
/* Begin XCVersionGroup section */
590-
5B0418161DBAC35A0042CB03 /* Model.xcdatamodeld */ = {
603+
5B04181A1DBAC6A40042CB03 /* DemoSwift.xcdatamodeld */ = {
591604
isa = XCVersionGroup;
592605
children = (
593-
5B0418171DBAC35A0042CB03 /* Model.xcdatamodel */,
606+
5B04181B1DBAC6A40042CB03 /* DemoSwift.xcdatamodel */,
594607
);
595-
currentVersion = 5B0418171DBAC35A0042CB03 /* Model.xcdatamodel */;
596-
path = Model.xcdatamodeld;
608+
currentVersion = 5B04181B1DBAC6A40042CB03 /* DemoSwift.xcdatamodel */;
609+
path = DemoSwift.xcdatamodeld;
597610
sourceTree = "<group>";
598611
versionGroupType = wrapper.xcdatamodel;
599612
};
600-
5B04181A1DBAC6A40042CB03 /* DemoSwift.xcdatamodeld */ = {
613+
5B680FF11DC2141D009C9780 /* ModelGroup.xcdatamodeld */ = {
601614
isa = XCVersionGroup;
602615
children = (
603-
5B04181B1DBAC6A40042CB03 /* DemoSwift.xcdatamodel */,
616+
5B680FF21DC2141D009C9780 /* ModelGroup.xcdatamodel */,
604617
);
605-
currentVersion = 5B04181B1DBAC6A40042CB03 /* DemoSwift.xcdatamodel */;
606-
path = DemoSwift.xcdatamodeld;
618+
currentVersion = 5B680FF21DC2141D009C9780 /* ModelGroup.xcdatamodel */;
619+
path = ModelGroup.xcdatamodeld;
607620
sourceTree = "<group>";
608621
versionGroupType = wrapper.xcdatamodel;
609622
};

Example/EncryptedDATAStack.xcodeproj/xcshareddata/xcschemes/EncryptedDATAStack-Example.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0720"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Example/EncryptedDATAStack/AppDelegate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import EncryptedDATAStack
66
class AppDelegate: UIResponder, UIApplicationDelegate {
77

88
var window: UIWindow? = {
9-
let window = UIWindow(frame: UIScreen.mainScreen().bounds)
9+
let window = UIWindow(frame: UIScreen.main.bounds)
1010

1111
return window
1212
}()
@@ -17,13 +17,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1717
return dataStack
1818
}()
1919

20-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
20+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
2121
if let window = self.window {
2222
let viewController = ViewController(dataStack: self.dataStack)
2323
window.rootViewController = UINavigationController(rootViewController: viewController)
2424
window.makeKeyAndVisible()
2525
}
26-
26+
2727
return true
2828
}
2929
}

0 commit comments

Comments
 (0)