Skip to content

Commit a0d8f56

Browse files
committed
Removed CoreDataMigrationSourceModel
1 parent 81271e5 commit a0d8f56

File tree

8 files changed

+78
-107
lines changed

8 files changed

+78
-107
lines changed

CoreDataMigration-Example.xcodeproj/project.pbxproj

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 48;
6+
objectVersion = 54;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -375,8 +375,9 @@
375375
43AB8ADD1F66E6A5003153B3 /* Project object */ = {
376376
isa = PBXProject;
377377
attributes = {
378+
BuildIndependentTargetsInParallel = YES;
378379
LastSwiftUpdateCheck = 0900;
379-
LastUpgradeCheck = 0900;
380+
LastUpgradeCheck = 2630;
380381
ORGANIZATIONNAME = "William Boles";
381382
TargetAttributes = {
382383
43AB8AE41F66E6A5003153B3 = {
@@ -518,15 +519,18 @@
518519
CLANG_WARN_BOOL_CONVERSION = YES;
519520
CLANG_WARN_COMMA = YES;
520521
CLANG_WARN_CONSTANT_CONVERSION = YES;
522+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
521523
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
522524
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
523525
CLANG_WARN_EMPTY_BODY = YES;
524526
CLANG_WARN_ENUM_CONVERSION = YES;
525527
CLANG_WARN_INFINITE_RECURSION = YES;
526528
CLANG_WARN_INT_CONVERSION = YES;
527529
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
530+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
528531
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
529532
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
533+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
530534
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
531535
CLANG_WARN_STRICT_PROTOTYPES = YES;
532536
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -538,6 +542,7 @@
538542
DEBUG_INFORMATION_FORMAT = dwarf;
539543
ENABLE_STRICT_OBJC_MSGSEND = YES;
540544
ENABLE_TESTABILITY = YES;
545+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
541546
GCC_C_LANGUAGE_STANDARD = gnu11;
542547
GCC_DYNAMIC_NO_PIC = NO;
543548
GCC_NO_COMMON_BLOCKS = YES;
@@ -552,12 +557,14 @@
552557
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
553558
GCC_WARN_UNUSED_FUNCTION = YES;
554559
GCC_WARN_UNUSED_VARIABLE = YES;
555-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
560+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
556561
MTL_ENABLE_DEBUG_INFO = YES;
557562
ONLY_ACTIVE_ARCH = YES;
558563
SDKROOT = iphoneos;
564+
STRING_CATALOG_GENERATE_SYMBOLS = YES;
559565
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
560566
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
567+
SWIFT_VERSION = 5.0;
561568
};
562569
name = Debug;
563570
};
@@ -575,15 +582,18 @@
575582
CLANG_WARN_BOOL_CONVERSION = YES;
576583
CLANG_WARN_COMMA = YES;
577584
CLANG_WARN_CONSTANT_CONVERSION = YES;
585+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
578586
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
579587
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
580588
CLANG_WARN_EMPTY_BODY = YES;
581589
CLANG_WARN_ENUM_CONVERSION = YES;
582590
CLANG_WARN_INFINITE_RECURSION = YES;
583591
CLANG_WARN_INT_CONVERSION = YES;
584592
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
593+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
585594
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
586595
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
596+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
587597
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
588598
CLANG_WARN_STRICT_PROTOTYPES = YES;
589599
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -595,6 +605,7 @@
595605
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
596606
ENABLE_NS_ASSERTIONS = NO;
597607
ENABLE_STRICT_OBJC_MSGSEND = YES;
608+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
598609
GCC_C_LANGUAGE_STANDARD = gnu11;
599610
GCC_NO_COMMON_BLOCKS = YES;
600611
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -603,10 +614,13 @@
603614
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
604615
GCC_WARN_UNUSED_FUNCTION = YES;
605616
GCC_WARN_UNUSED_VARIABLE = YES;
606-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
617+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
607618
MTL_ENABLE_DEBUG_INFO = NO;
608619
SDKROOT = iphoneos;
609-
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
620+
STRING_CATALOG_GENERATE_SYMBOLS = YES;
621+
SWIFT_COMPILATION_MODE = wholemodule;
622+
SWIFT_OPTIMIZATION_LEVEL = "-O";
623+
SWIFT_VERSION = 5.0;
610624
VALIDATE_PRODUCT = YES;
611625
};
612626
name = Release;
@@ -617,12 +631,18 @@
617631
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
618632
CODE_SIGN_STYLE = Automatic;
619633
INFOPLIST_FILE = "CoreDataMigration-Example/Application/Info.plist";
620-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
621-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
634+
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
635+
LD_RUNPATH_SEARCH_PATHS = (
636+
"$(inherited)",
637+
"@executable_path/Frameworks",
638+
);
622639
PRODUCT_BUNDLE_IDENTIFIER = "com.williamboles.CoreDataMigration-Example";
623640
PRODUCT_NAME = "$(TARGET_NAME)";
624-
SWIFT_VERSION = 4.0;
625-
TARGETED_DEVICE_FAMILY = "1,2";
641+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
642+
SUPPORTS_MACCATALYST = NO;
643+
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
644+
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
645+
TARGETED_DEVICE_FAMILY = 1;
626646
};
627647
name = Debug;
628648
};
@@ -632,12 +652,18 @@
632652
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
633653
CODE_SIGN_STYLE = Automatic;
634654
INFOPLIST_FILE = "CoreDataMigration-Example/Application/Info.plist";
635-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
636-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
655+
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
656+
LD_RUNPATH_SEARCH_PATHS = (
657+
"$(inherited)",
658+
"@executable_path/Frameworks",
659+
);
637660
PRODUCT_BUNDLE_IDENTIFIER = "com.williamboles.CoreDataMigration-Example";
638661
PRODUCT_NAME = "$(TARGET_NAME)";
639-
SWIFT_VERSION = 4.0;
640-
TARGETED_DEVICE_FAMILY = "1,2";
662+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
663+
SUPPORTS_MACCATALYST = NO;
664+
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
665+
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
666+
TARGETED_DEVICE_FAMILY = 1;
641667
};
642668
name = Release;
643669
};
@@ -648,13 +674,21 @@
648674
CLANG_ENABLE_MODULES = YES;
649675
CODE_SIGN_STYLE = Automatic;
650676
INFOPLIST_FILE = "CoreDataMigration-ExampleTests/Info.plist";
651-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
677+
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
678+
LD_RUNPATH_SEARCH_PATHS = (
679+
"$(inherited)",
680+
"@executable_path/Frameworks",
681+
"@loader_path/Frameworks",
682+
);
652683
PRODUCT_BUNDLE_IDENTIFIER = "com.williamboles.CoreDataMigration-ExampleTests";
653684
PRODUCT_NAME = "$(TARGET_NAME)";
685+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
686+
SUPPORTS_MACCATALYST = NO;
687+
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
688+
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
654689
SWIFT_OBJC_BRIDGING_HEADER = "CoreDataMigration-ExampleTests/CoreDataMigration-ExampleTests-Bridging-Header.h";
655690
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
656-
SWIFT_VERSION = 4.0;
657-
TARGETED_DEVICE_FAMILY = "1,2";
691+
TARGETED_DEVICE_FAMILY = 1;
658692
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CoreDataMigration-Example.app/CoreDataMigration-Example";
659693
};
660694
name = Debug;
@@ -666,12 +700,20 @@
666700
CLANG_ENABLE_MODULES = YES;
667701
CODE_SIGN_STYLE = Automatic;
668702
INFOPLIST_FILE = "CoreDataMigration-ExampleTests/Info.plist";
669-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
703+
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
704+
LD_RUNPATH_SEARCH_PATHS = (
705+
"$(inherited)",
706+
"@executable_path/Frameworks",
707+
"@loader_path/Frameworks",
708+
);
670709
PRODUCT_BUNDLE_IDENTIFIER = "com.williamboles.CoreDataMigration-ExampleTests";
671710
PRODUCT_NAME = "$(TARGET_NAME)";
711+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
712+
SUPPORTS_MACCATALYST = NO;
713+
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
714+
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
672715
SWIFT_OBJC_BRIDGING_HEADER = "CoreDataMigration-ExampleTests/CoreDataMigration-ExampleTests-Bridging-Header.h";
673-
SWIFT_VERSION = 4.0;
674-
TARGETED_DEVICE_FAMILY = "1,2";
716+
TARGETED_DEVICE_FAMILY = 1;
675717
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CoreDataMigration-Example.app/CoreDataMigration-Example";
676718
};
677719
name = Release;

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

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0830"
3+
LastUpgradeVersion = "2630"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,8 +26,16 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
language = ""
3029
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<MacroExpansion>
31+
<BuildableReference
32+
BuildableIdentifier = "primary"
33+
BlueprintIdentifier = "43AB8AE41F66E6A5003153B3"
34+
BuildableName = "CoreDataMigration-Example.app"
35+
BlueprintName = "CoreDataMigration-Example"
36+
ReferencedContainer = "container:CoreDataMigration-Example.xcodeproj">
37+
</BuildableReference>
38+
</MacroExpansion>
3139
<Testables>
3240
<TestableReference
3341
skipped = "NO">
@@ -40,23 +48,11 @@
4048
</BuildableReference>
4149
</TestableReference>
4250
</Testables>
43-
<MacroExpansion>
44-
<BuildableReference
45-
BuildableIdentifier = "primary"
46-
BlueprintIdentifier = "43AB8AE41F66E6A5003153B3"
47-
BuildableName = "CoreDataMigration-Example.app"
48-
BlueprintName = "CoreDataMigration-Example"
49-
ReferencedContainer = "container:CoreDataMigration-Example.xcodeproj">
50-
</BuildableReference>
51-
</MacroExpansion>
52-
<AdditionalOptions>
53-
</AdditionalOptions>
5451
</TestAction>
5552
<LaunchAction
5653
buildConfiguration = "Debug"
5754
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5855
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59-
language = ""
6056
launchStyle = "0"
6157
useCustomWorkingDirectory = "NO"
6258
ignoresPersistentStateOnLaunch = "NO"
@@ -73,8 +69,6 @@
7369
ReferencedContainer = "container:CoreDataMigration-Example.xcodeproj">
7470
</BuildableReference>
7571
</BuildableProductRunnable>
76-
<AdditionalOptions>
77-
</AdditionalOptions>
7872
</LaunchAction>
7973
<ProfileAction
8074
buildConfiguration = "Release"

CoreDataMigration-Example/Application/AppDelegate.swift

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@ import UIKit
1010
import CoreData
1111

1212
class AppDelegate: UIResponder, UIApplicationDelegate {
13-
1413
var window: UIWindow?
1514

16-
// MARK: - AppLifecycle
17-
18-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
19-
15+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2016
CoreDataManager.shared.setup {
2117
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { // just for example purposes
2218
self.presentMainUI()
@@ -25,31 +21,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2521

2622
return true
2723
}
28-
29-
func applicationWillResignActive(_ application: UIApplication) {
30-
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
31-
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
32-
}
33-
34-
func applicationDidEnterBackground(_ application: UIApplication) {
35-
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
36-
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
37-
}
38-
39-
func applicationWillEnterForeground(_ application: UIApplication) {
40-
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
41-
}
42-
43-
func applicationDidBecomeActive(_ application: UIApplication) {
44-
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
45-
}
46-
47-
func applicationWillTerminate(_ application: UIApplication) {
48-
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
49-
// Saves changes in the application's managed object context before the application terminates.
50-
51-
try? CoreDataManager.shared.mainContext.save()
52-
}
5324

5425
// MARK: - Main
5526

@@ -58,4 +29,3 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5829
window?.rootViewController = mainStoryboard.instantiateInitialViewController()
5930
}
6031
}
61-

CoreDataMigration-Example/CoreData/Migration/CoreDataMigrationModel.swift

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -167,26 +167,3 @@ class CoreDataMigrationModel {
167167
return compatibleMigrationModel
168168
}
169169
}
170-
171-
// MARK: - Source
172-
173-
class CoreDataMigrationSourceModel: CoreDataMigrationModel {
174-
175-
// MARK: - Init
176-
177-
init?(storeURL: URL) {
178-
guard let metadata = NSPersistentStoreCoordinator.metadata(at: storeURL) else {
179-
return nil
180-
}
181-
182-
let migrationVersionModel = CoreDataMigrationModel.all.first {
183-
$0.managedObjectModel().isConfiguration(withName: nil, compatibleWithStoreMetadata: metadata)
184-
}
185-
186-
guard migrationVersionModel != nil else {
187-
return nil
188-
}
189-
190-
super.init(version: migrationVersionModel!.version)
191-
}
192-
}

CoreDataMigration-Example/CoreData/Migration/CoreDataMigrator.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ class CoreDataMigrator {
4343
}
4444

4545
func migrateStore(from sourceURL: URL, to targetURL: URL, targetVersion: CoreDataMigrationModel) {
46-
guard let sourceMigrationModel = CoreDataMigrationSourceModel(storeURL: sourceURL as URL) else {
46+
guard let metadata = NSPersistentStoreCoordinator.metadata(at: sourceURL),
47+
let sourceMigrationModel = CoreDataMigrationModel.migrationModelCompatibleWithStoreMetadata(metadata) else {
4748
fatalError("Unknown store version at URL \(sourceURL)")
4849
}
49-
50+
5051
forceWALCheckpointingForStore(at: sourceURL)
51-
52+
5253
var currentURL = sourceURL
5354
let migrationSteps = sourceMigrationModel.migrationSteps(to: targetVersion)
5455

CoreDataMigration-Example/Extensions/UIColor/UIColor+Hex.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extension UIColor {
3030

3131
var color: UIColor? = nil
3232

33-
if hexColor.characters.count == 6 {
33+
if hexColor.count == 6 {
3434

3535
let scanner = Scanner(string: hexColor)
3636
var hexNumber: UInt64 = 0

CoreDataMigration-ExampleTests/Doubles/TestingAppDelegate.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ import CoreData
1212
@testable import CoreDataMigration_Example
1313

1414
class TestingAppDelegate: NSObject, UIApplicationDelegate {
15-
1615
var window: UIWindow?
1716

18-
// MARK: - AppLifecycle
19-
20-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2118

2219
//Just some house keeping
2320
if let storeURL = CoreDataManager().persistentContainer.persistentStoreDescriptions.first?.url {

CoreDataMigration-ExampleTests/Tests/CoreDataMigrationModelTests.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@ import CoreData
1313

1414
class CoreDataMigrationModelTests: XCTestCase {
1515

16-
// MARK: - Source
17-
18-
func test_sourceInit_validStoreURL() {
19-
let storeURL = Bundle(for: CoreDataMigrationModelTests.self).resourceURL!.appendingPathComponent("CoreDataMigration_Example_2.sqlite")
20-
let coreDataMigrationModel = CoreDataMigrationSourceModel(storeURL: storeURL)
21-
22-
XCTAssertNotNil(coreDataMigrationModel)
23-
XCTAssertEqual(coreDataMigrationModel!.version.name, "CoreDataMigration_Example 2")
24-
}
25-
2616
// MARK: - Steps
2717

2818
func test_migrationSteps_singleStep() {

0 commit comments

Comments
 (0)