Skip to content

Commit 176c9a8

Browse files
committed
AINFRA-469 - Simplify Storage into a Swift package - Sources only
1 parent aa774ac commit 176c9a8

File tree

380 files changed

+148
-1634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

380 files changed

+148
-1634
lines changed

Storage/Storage.xcodeproj/xcshareddata/xcschemes/Storage.xcscheme renamed to Modules/.swiftpm/xcode/xcshareddata/xcschemes/Storage.xcscheme

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1620"
4-
version = "1.3">
3+
LastUpgradeVersion = "1640"
4+
version = "1.7">
55
<BuildAction
66
parallelizeBuildables = "YES"
7-
buildImplicitDependencies = "YES">
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
89
<BuildActionEntries>
910
<BuildActionEntry
1011
buildForTesting = "YES"
@@ -14,10 +15,10 @@
1415
buildForAnalyzing = "YES">
1516
<BuildableReference
1617
BuildableIdentifier = "primary"
17-
BlueprintIdentifier = "B54CA59820A4BBA500F38CD1"
18-
BuildableName = "Storage.framework"
18+
BlueprintIdentifier = "Storage"
19+
BuildableName = "Storage"
1920
BlueprintName = "Storage"
20-
ReferencedContainer = "container:Storage.xcodeproj">
21+
ReferencedContainer = "container:">
2122
</BuildableReference>
2223
</BuildActionEntry>
2324
</BuildActionEntries>
@@ -26,28 +27,8 @@
2627
buildConfiguration = "Debug"
2728
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2829
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
shouldUseLaunchSchemeArgsEnv = "YES">
30-
<MacroExpansion>
31-
<BuildableReference
32-
BuildableIdentifier = "primary"
33-
BlueprintIdentifier = "B54CA59820A4BBA500F38CD1"
34-
BuildableName = "Storage.framework"
35-
BlueprintName = "Storage"
36-
ReferencedContainer = "container:Storage.xcodeproj">
37-
</BuildableReference>
38-
</MacroExpansion>
39-
<Testables>
40-
<TestableReference
41-
skipped = "NO">
42-
<BuildableReference
43-
BuildableIdentifier = "primary"
44-
BlueprintIdentifier = "B54CA5A120A4BBA600F38CD1"
45-
BuildableName = "StorageTests.xctest"
46-
BlueprintName = "StorageTests"
47-
ReferencedContainer = "container:Storage.xcodeproj">
48-
</BuildableReference>
49-
</TestableReference>
50-
</Testables>
30+
shouldUseLaunchSchemeArgsEnv = "YES"
31+
shouldAutocreateTestPlan = "YES">
5132
</TestAction>
5233
<LaunchAction
5334
buildConfiguration = "Debug"
@@ -59,15 +40,6 @@
5940
debugDocumentVersioning = "YES"
6041
debugServiceExtension = "internal"
6142
allowLocationSimulation = "YES">
62-
<MacroExpansion>
63-
<BuildableReference
64-
BuildableIdentifier = "primary"
65-
BlueprintIdentifier = "B54CA59820A4BBA500F38CD1"
66-
BuildableName = "Storage.framework"
67-
BlueprintName = "Storage"
68-
ReferencedContainer = "container:Storage.xcodeproj">
69-
</BuildableReference>
70-
</MacroExpansion>
7143
</LaunchAction>
7244
<ProfileAction
7345
buildConfiguration = "Release"
@@ -78,10 +50,10 @@
7850
<MacroExpansion>
7951
<BuildableReference
8052
BuildableIdentifier = "primary"
81-
BlueprintIdentifier = "B54CA59820A4BBA500F38CD1"
82-
BuildableName = "Storage.framework"
53+
BlueprintIdentifier = "Storage"
54+
BuildableName = "Storage"
8355
BlueprintName = "Storage"
84-
ReferencedContainer = "container:Storage.xcodeproj">
56+
ReferencedContainer = "container:">
8557
</BuildableReference>
8658
</MacroExpansion>
8759
</ProfileAction>

Modules/Package.swift

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ let package = Package(
2727
name: "Networking",
2828
targets: ["Networking"]
2929
),
30+
.library(
31+
name: "Storage",
32+
targets: ["Storage"]
33+
),
3034
.library(
3135
name: "TestKit",
3236
targets: ["TestKit"]
@@ -118,6 +122,15 @@ let package = Package(
118122
.product(name: "KeychainAccess", package: "KeychainAccess"),
119123
]
120124
),
125+
.target(
126+
name: "Storage",
127+
dependencies: [
128+
"Codegen",
129+
"WooFoundation"
130+
],
131+
exclude: ["Model/Migrations.md"],
132+
resources: [.process("Resources")]
133+
),
121134
.target(
122135
name: "TestKit",
123136
dependencies: ["Difference", "Nimble"]
@@ -204,7 +217,6 @@ enum XcodeTargetNames {
204217
static let hardwareTests = "HardwareTests"
205218
static let networkingTests = "NetworkingTests"
206219
static let notificationExtension = "NotificationExtension"
207-
static let storage = "Storage"
208220
static let storageTests = "StorageTests"
209221
static let storeWidgetsExtension = "StoreWidgetsExtension"
210222
static let uiTestsFoundation = "UITestsFoundation"
@@ -227,7 +239,6 @@ enum XcodeSupport {
227239
XcodeTargetNames.hardwareTests,
228240
XcodeTargetNames.networkingTests,
229241
XcodeTargetNames.notificationExtension,
230-
XcodeTargetNames.storage,
231242
XcodeTargetNames.storageTests,
232243
XcodeTargetNames.storeWidgetsExtension,
233244
XcodeTargetNames.uiTestsFoundation,
@@ -283,13 +294,12 @@ enum XcodeSupport {
283294
.product(name: "KeychainAccess", package: "KeychainAccess"),
284295
]
285296
),
286-
.xcodeTarget(
287-
XcodeTargetNames.storage,
288-
dependencies: ["Codegen", "WooFoundation"]
289-
),
290297
.xcodeTarget(
291298
XcodeTargetNames.storageTests,
292-
dependencies: ["TestKit", XcodeTargetNames.storage.asDependency]
299+
dependencies: [
300+
"Storage",
301+
"TestKit"
302+
]
293303
),
294304
.xcodeTarget(
295305
XcodeTargetNames.storeWidgetsExtension,
@@ -313,6 +323,7 @@ enum XcodeSupport {
313323
"Codegen",
314324
"Experiments",
315325
"Networking",
326+
"Storage",
316327
"WooFoundation",
317328
"WordPressShared",
318329
"WordPressUI",
@@ -403,6 +414,7 @@ enum XcodeSupport {
403414
dependencies: [
404415
"Codegen",
405416
"Networking",
417+
"Storage",
406418
"WooFoundation",
407419
"WordPressShared",
408420
.product(name: "Alamofire", package: "Alamofire"),
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
project:
2-
file: ../../../../../Storage/Storage.xcodeproj
3-
target:
4-
name: Storage
1+
sources:
2+
include:
3+
- ../../../../../Modules/Sources/Storage/
54
templates:
65
- Models+Copiable.swifttemplate
7-
output: ../../../../../Storage/Storage/Model/Copiable/
6+
output: ../../../../../Modules/Sources/Storage/Model/Copiable/
7+
args:
8+
moduleName: Storage
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Foundation
2+
3+
extension Bundle {
4+
static var storage: Bundle {
5+
#if DEBUG
6+
// Workaround for https://forums.swift.org/t/swift-5-3-swiftpm-resources-in-tests-uses-wrong-bundle-path/37051
7+
if let testBundlePath = ProcessInfo.processInfo.environment["XCTestBundlePath"],
8+
let bundle = Bundle(path: "\(testBundlePath)/Modules_Storage.bundle") {
9+
return bundle
10+
}
11+
#endif
12+
return Bundle.module
13+
14+
}
15+
}
File renamed without changes.

Storage/Storage/CoreData/CoreDataIterativeMigrator.swift renamed to Modules/Sources/Storage/CoreData/CoreDataIterativeMigrator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private extension CoreDataIterativeMigrator {
146146
}
147147

148148
func model(for metadata: [String: Any]) throws -> NSManagedObjectModel {
149-
let bundle = Bundle(for: CoreDataManager.self)
149+
let bundle = Bundle.storage
150150
guard let sourceModel = NSManagedObjectModel.mergedModel(from: [bundle], forStoreMetadata: metadata) else {
151151
let description = "Failed to find source model for metadata: \(metadata)"
152152
throw NSError(domain: "IterativeMigrator", code: 100, userInfo: [NSLocalizedDescriptionKey: description])

Storage/Storage/CoreData/CoreDataManager.swift renamed to Modules/Sources/Storage/CoreData/CoreDataManager.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22
import CoreData
3+
import UIKit
34
import WooFoundation
45

56

@@ -36,7 +37,7 @@ public final class CoreDataManager: StorageManagerType {
3637
if let modelsInventory {
3738
inventory = modelsInventory
3839
} else {
39-
inventory = try .from(packageName: name, bundle: Bundle(for: type(of: self)))
40+
inventory = try .from(packageName: name, bundle: .storage)
4041
}
4142
} catch {
4243
// We'll throw a fatalError() because we can't really proceed without a
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)