Skip to content

Commit

Permalink
Move modelContainer generation out of static methods (#1124)
Browse files Browse the repository at this point in the history
* chore(version): bump to 8.22.1

* fix(swiftData): avoid static references in Services
  • Loading branch information
Gio2018 authored Dec 2, 2024
1 parent 995fdae commit b4905c3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
48 changes: 24 additions & 24 deletions Pocket.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -1489,7 +1489,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
POCKET_API_BASE_URL = "https://api.getpocket.com/graphql";
Expand Down Expand Up @@ -1520,7 +1520,7 @@
"@executable_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro;
PRODUCT_NAME = Pocket;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1552,7 +1552,7 @@
"@executable_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro;
PRODUCT_NAME = Pocket;
PROVISIONING_PROFILE_SPECIFIER = "Bitrise com.ideashower.ReadItLaterPro";
Expand All @@ -1578,7 +1578,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.ideashower.ReadItLaterProAlphaNeue.Tests-iOS";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1604,7 +1604,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.ideashower.ReadItLaterProAlphaNeue.Tests-iOS";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1637,7 +1637,7 @@
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro.PushNotificationServiceExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1670,7 +1670,7 @@
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro.PushNotificationServiceExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Bitrise com.ideashower.ReadItLaterPro.PushNotifica";
Expand Down Expand Up @@ -1710,7 +1710,7 @@
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro.iMessageExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1750,7 +1750,7 @@
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro.iMessageExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1791,7 +1791,7 @@
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro.iMessageExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1825,7 +1825,7 @@
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro.PushNotificationStoryExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1857,7 +1857,7 @@
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro.PushNotificationStoryExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Bitrise com.ideashower.ReadItLaterPro.PushStory";
Expand Down Expand Up @@ -1927,7 +1927,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -1959,7 +1959,7 @@
"@executable_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro;
PRODUCT_NAME = Pocket;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1985,7 +1985,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.ideashower.ReadItLaterProAlphaNeue.Tests-iOS";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -2017,7 +2017,7 @@
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro.AddToPocketExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -2051,7 +2051,7 @@
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro.PushNotificationServiceExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -2083,7 +2083,7 @@
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro.PushNotificationStoryExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -2117,7 +2117,7 @@
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.ideashower.ReadItLaterPro.Widget-Extension";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -2150,7 +2150,7 @@
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.ideashower.ReadItLaterPro.Widget-Extension";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -2183,7 +2183,7 @@
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.ideashower.ReadItLaterPro.Widget-Extension";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Bitrise com.ideashower.ReadItLaterPro.Widget-Exten";
Expand Down Expand Up @@ -2217,7 +2217,7 @@
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro.AddToPocketExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -2251,7 +2251,7 @@
"@executable_path/../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 8.22.0;
MARKETING_VERSION = 8.22.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ideashower.ReadItLaterPro.AddToPocketExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Bitrise com.ideashower.ReadItLaterPro.AddToPocketE";
Expand Down
3 changes: 2 additions & 1 deletion PocketKit/Sources/PocketKit/Services.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ struct Services {
notificationCenter = .default
Log.breadcrumb(category: "SWiftUIHome", level: .debug, message: "Initializing data controller.")
// Init the Group ID for Swift Data
modelContainer = DataController.makeModelContainer(groupID: Keys.shared.groupID)
let dataController = DataController()
modelContainer = dataController.makeModelContainer(groupID: Keys.shared.groupID)
Log.breadcrumb(category: "SWiftUIHome", level: .debug, message: "Data controller initialized.")
persistentContainer = .init(storage: .shared, groupID: Keys.shared.groupID)
Log.breadcrumb(category: "SWiftUIHome", level: .debug, message: "Persistent container initialized.")
Expand Down
10 changes: 6 additions & 4 deletions PocketKit/Sources/Sync/SwiftData/DataController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
//

import Foundation
import SwiftData
@preconcurrency import SwiftData
import SharedPocketKit

public struct DataController: Sendable {
public static func makeModelContainer(groupID: String) -> ModelContainer {
public func makeModelContainer(groupID: String) -> ModelContainer {
Log.breadcrumb(category: "SWiftUIHome", level: .debug, message: "Start initializing shared model container.")
ArticleTransformer.register()
Log.breadcrumb(category: "SWiftUIHome", level: .debug, message: "Article transformer registered.")
Expand All @@ -21,14 +21,16 @@ public struct DataController: Sendable {
}
let url = appGroupContainer.appendingPathComponent("PocketModel.sqlite")
do {
return try ModelContainer(for: Self.schema, configurations: ModelConfiguration(url: url))
return try ModelContainer(for: self.schema, configurations: ModelConfiguration(url: url))
} catch {
Log.capture(message: "Could not create ModelContainer: \(error)")
fatalError("Could not create ModelContainer: \(error)")
}
}

private static let schema = Schema([
public init() {}

private let schema = Schema([
Author.self,
Sync.Collection.self,
CollectionAuthor.self,
Expand Down

0 comments on commit b4905c3

Please sign in to comment.