...i think i got icloud syncing working the first go?

This commit is contained in:
breadone 2024-07-10 11:01:38 +12:00
parent 2a7dadc939
commit f2de4ae7cc
No known key found for this signature in database
11 changed files with 91 additions and 37 deletions

View File

@ -21,7 +21,7 @@
46AD30D32C26559B00486C25 /* MainViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46AD30D22C26559B00486C25 /* MainViewPresenter.swift */; }; 46AD30D32C26559B00486C25 /* MainViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46AD30D22C26559B00486C25 /* MainViewPresenter.swift */; };
46AD30D52C26559D00486C25 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 46AD30D42C26559D00486C25 /* Assets.xcassets */; }; 46AD30D52C26559D00486C25 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 46AD30D42C26559D00486C25 /* Assets.xcassets */; };
46AD30D82C26559D00486C25 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 46AD30D72C26559D00486C25 /* Preview Assets.xcassets */; }; 46AD30D82C26559D00486C25 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 46AD30D72C26559D00486C25 /* Preview Assets.xcassets */; };
46AD30DB2C26559D00486C25 /* OnCuePresenter Watch App.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = 46AD30CE2C26559B00486C25 /* OnCuePresenter Watch App.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 46AD30DB2C26559D00486C25 /* OnCue.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = 46AD30CE2C26559B00486C25 /* OnCue.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
46AD30E22C2656CB00486C25 /* OCCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46AD30E12C2656CB00486C25 /* OCCard.swift */; }; 46AD30E22C2656CB00486C25 /* OCCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46AD30E12C2656CB00486C25 /* OCCard.swift */; };
46AD30E32C2656CB00486C25 /* OCCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46AD30E12C2656CB00486C25 /* OCCard.swift */; }; 46AD30E32C2656CB00486C25 /* OCCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46AD30E12C2656CB00486C25 /* OCCard.swift */; };
46AD30E52C2656D100486C25 /* OCProject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46AD30E42C2656D100486C25 /* OCProject.swift */; }; 46AD30E52C2656D100486C25 /* OCProject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46AD30E42C2656D100486C25 /* OCProject.swift */; };
@ -57,7 +57,7 @@
dstPath = "$(CONTENTS_FOLDER_PATH)/Watch"; dstPath = "$(CONTENTS_FOLDER_PATH)/Watch";
dstSubfolderSpec = 16; dstSubfolderSpec = 16;
files = ( files = (
46AD30DB2C26559D00486C25 /* OnCuePresenter Watch App.app in Embed Watch Content */, 46AD30DB2C26559D00486C25 /* OnCue.app in Embed Watch Content */,
); );
name = "Embed Watch Content"; name = "Embed Watch Content";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
@ -66,6 +66,7 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
460D7DF52C2AE788002B623C /* TimerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimerManager.swift; sourceTree = "<group>"; }; 460D7DF52C2AE788002B623C /* TimerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimerManager.swift; sourceTree = "<group>"; };
4614D4022C3DF680000799F5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
464787CA2C269CAF00A9C462 /* TeleprompterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TeleprompterView.swift; sourceTree = "<group>"; }; 464787CA2C269CAF00A9C462 /* TeleprompterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TeleprompterView.swift; sourceTree = "<group>"; };
46AD30B72C26557500486C25 /* OnCue.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OnCue.app; sourceTree = BUILT_PRODUCTS_DIR; }; 46AD30B72C26557500486C25 /* OnCue.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OnCue.app; sourceTree = BUILT_PRODUCTS_DIR; };
46AD30BA2C26557500486C25 /* OnCueApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnCueApp.swift; sourceTree = "<group>"; }; 46AD30BA2C26557500486C25 /* OnCueApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnCueApp.swift; sourceTree = "<group>"; };
@ -73,7 +74,7 @@
46AD30BE2C26557500486C25 /* Item.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Item.swift; sourceTree = "<group>"; }; 46AD30BE2C26557500486C25 /* Item.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Item.swift; sourceTree = "<group>"; };
46AD30C02C26557600486C25 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 46AD30C02C26557600486C25 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
46AD30C32C26557600486C25 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; }; 46AD30C32C26557600486C25 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
46AD30CE2C26559B00486C25 /* OnCuePresenter Watch App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "OnCuePresenter Watch App.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 46AD30CE2C26559B00486C25 /* OnCue.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OnCue.app; sourceTree = BUILT_PRODUCTS_DIR; };
46AD30D02C26559B00486C25 /* OnCuePresenterApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnCuePresenterApp.swift; sourceTree = "<group>"; }; 46AD30D02C26559B00486C25 /* OnCuePresenterApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnCuePresenterApp.swift; sourceTree = "<group>"; };
46AD30D22C26559B00486C25 /* MainViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewPresenter.swift; sourceTree = "<group>"; }; 46AD30D22C26559B00486C25 /* MainViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewPresenter.swift; sourceTree = "<group>"; };
46AD30D42C26559D00486C25 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 46AD30D42C26559D00486C25 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@ -126,7 +127,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
46AD30B72C26557500486C25 /* OnCue.app */, 46AD30B72C26557500486C25 /* OnCue.app */,
46AD30CE2C26559B00486C25 /* OnCuePresenter Watch App.app */, 46AD30CE2C26559B00486C25 /* OnCue.app */,
); );
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
@ -134,6 +135,7 @@
46AD30B92C26557500486C25 /* OnCue */ = { 46AD30B92C26557500486C25 /* OnCue */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
4614D4022C3DF680000799F5 /* Info.plist */,
46D3E1472C27FAFC0060722E /* OnCue.entitlements */, 46D3E1472C27FAFC0060722E /* OnCue.entitlements */,
46AD30BA2C26557500486C25 /* OnCueApp.swift */, 46AD30BA2C26557500486C25 /* OnCueApp.swift */,
46AD30E82C266AB900486C25 /* View */, 46AD30E82C266AB900486C25 /* View */,
@ -247,9 +249,9 @@
productReference = 46AD30B72C26557500486C25 /* OnCue.app */; productReference = 46AD30B72C26557500486C25 /* OnCue.app */;
productType = "com.apple.product-type.application"; productType = "com.apple.product-type.application";
}; };
46AD30CD2C26559B00486C25 /* OnCuePresenter Watch App */ = { 46AD30CD2C26559B00486C25 /* OnCuePresenter */ = {
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 46AD30DC2C26559D00486C25 /* Build configuration list for PBXNativeTarget "OnCuePresenter Watch App" */; buildConfigurationList = 46AD30DC2C26559D00486C25 /* Build configuration list for PBXNativeTarget "OnCuePresenter" */;
buildPhases = ( buildPhases = (
46AD30CA2C26559B00486C25 /* Sources */, 46AD30CA2C26559B00486C25 /* Sources */,
46AD30CB2C26559B00486C25 /* Frameworks */, 46AD30CB2C26559B00486C25 /* Frameworks */,
@ -259,9 +261,9 @@
); );
dependencies = ( dependencies = (
); );
name = "OnCuePresenter Watch App"; name = OnCuePresenter;
productName = "OnCuePresenter Watch App"; productName = "OnCuePresenter Watch App";
productReference = 46AD30CE2C26559B00486C25 /* OnCuePresenter Watch App.app */; productReference = 46AD30CE2C26559B00486C25 /* OnCue.app */;
productType = "com.apple.product-type.application"; productType = "com.apple.product-type.application";
}; };
/* End PBXNativeTarget section */ /* End PBXNativeTarget section */
@ -296,7 +298,7 @@
projectRoot = ""; projectRoot = "";
targets = ( targets = (
46AD30B62C26557500486C25 /* OnCue */, 46AD30B62C26557500486C25 /* OnCue */,
46AD30CD2C26559B00486C25 /* OnCuePresenter Watch App */, 46AD30CD2C26559B00486C25 /* OnCuePresenter */,
); );
}; };
/* End PBXProject section */ /* End PBXProject section */
@ -368,7 +370,7 @@
/* Begin PBXTargetDependency section */ /* Begin PBXTargetDependency section */
46AD30DA2C26559D00486C25 /* PBXTargetDependency */ = { 46AD30DA2C26559D00486C25 /* PBXTargetDependency */ = {
isa = PBXTargetDependency; isa = PBXTargetDependency;
target = 46AD30CD2C26559B00486C25 /* OnCuePresenter Watch App */; target = 46AD30CD2C26559B00486C25 /* OnCuePresenter */;
targetProxy = 46AD30D92C26559D00486C25 /* PBXContainerItemProxy */; targetProxy = 46AD30D92C26559D00486C25 /* PBXContainerItemProxy */;
}; };
/* End PBXTargetDependency section */ /* End PBXTargetDependency section */
@ -506,6 +508,7 @@
DEVELOPMENT_TEAM = 9MP5435PRF; DEVELOPMENT_TEAM = 9MP5435PRF;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = OnCue/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = OnCue; INFOPLIST_KEY_CFBundleDisplayName = OnCue;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
@ -542,6 +545,7 @@
DEVELOPMENT_TEAM = 9MP5435PRF; DEVELOPMENT_TEAM = 9MP5435PRF;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = OnCue/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = OnCue; INFOPLIST_KEY_CFBundleDisplayName = OnCue;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
@ -576,7 +580,6 @@
DEVELOPMENT_TEAM = 9MP5435PRF; DEVELOPMENT_TEAM = 9MP5435PRF;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_CFBundleDisplayName = OnCuePresenter;
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
INFOPLIST_KEY_WKCompanionAppBundleIdentifier = xyz.breadone.oncue; INFOPLIST_KEY_WKCompanionAppBundleIdentifier = xyz.breadone.oncue;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
@ -585,7 +588,7 @@
); );
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = xyz.breadone.oncue.watchkitapp; PRODUCT_BUNDLE_IDENTIFIER = xyz.breadone.oncue.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = OnCue;
SDKROOT = watchos; SDKROOT = watchos;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
@ -606,7 +609,6 @@
DEVELOPMENT_TEAM = 9MP5435PRF; DEVELOPMENT_TEAM = 9MP5435PRF;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_CFBundleDisplayName = OnCuePresenter;
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
INFOPLIST_KEY_WKCompanionAppBundleIdentifier = xyz.breadone.oncue; INFOPLIST_KEY_WKCompanionAppBundleIdentifier = xyz.breadone.oncue;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
@ -615,7 +617,7 @@
); );
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = xyz.breadone.oncue.watchkitapp; PRODUCT_BUNDLE_IDENTIFIER = xyz.breadone.oncue.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = OnCue;
SDKROOT = watchos; SDKROOT = watchos;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
@ -646,7 +648,7 @@
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release; defaultConfigurationName = Release;
}; };
46AD30DC2C26559D00486C25 /* Build configuration list for PBXNativeTarget "OnCuePresenter Watch App" */ = { 46AD30DC2C26559D00486C25 /* Build configuration list for PBXNativeTarget "OnCuePresenter" */ = {
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (
46AD30DD2C26559D00486C25 /* Debug */, 46AD30DD2C26559D00486C25 /* Debug */,

View File

@ -16,8 +16,8 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "46AD30CD2C26559B00486C25" BlueprintIdentifier = "46AD30CD2C26559B00486C25"
BuildableName = "OnCuePresenter Watch App.app" BuildableName = "OnCuePresenter.app"
BlueprintName = "OnCuePresenter Watch App" BlueprintName = "OnCuePresenter"
ReferencedContainer = "container:OnCue.xcodeproj"> ReferencedContainer = "container:OnCue.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildActionEntry> </BuildActionEntry>
@ -59,8 +59,8 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "46AD30CD2C26559B00486C25" BlueprintIdentifier = "46AD30CD2C26559B00486C25"
BuildableName = "OnCuePresenter Watch App.app" BuildableName = "OnCue.app"
BlueprintName = "OnCuePresenter Watch App" BlueprintName = "OnCuePresenter"
ReferencedContainer = "container:OnCue.xcodeproj"> ReferencedContainer = "container:OnCue.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>
@ -76,8 +76,8 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "46AD30CD2C26559B00486C25" BlueprintIdentifier = "46AD30CD2C26559B00486C25"
BuildableName = "OnCuePresenter Watch App.app" BuildableName = "OnCue.app"
BlueprintName = "OnCuePresenter Watch App" BlueprintName = "OnCuePresenter"
ReferencedContainer = "container:OnCue.xcodeproj"> ReferencedContainer = "container:OnCue.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>

10
OnCue/Info.plist Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
</dict>
</plist>

View File

@ -11,8 +11,9 @@ import SwiftData
@Model @Model
final class OCCard: Identifiable { final class OCCard: Identifiable {
let id = UUID() let id = UUID()
var content: String var content: String = ""
var index: Int var index: Int = 0
var parentProject: OCProject? = nil
init(content: String, index: Int) { init(content: String, index: Int) {
self.content = content self.content = content

View File

@ -7,14 +7,15 @@
import Foundation import Foundation
import SwiftData import SwiftData
import CloudKit
@Model @Model
final class OCProject { final class OCProject {
var name: String var name: String = "No Name"
var cards: [OCCard] var cards: [OCCard]? = []
let creationDate: Date let creationDate: Date = Date()
var lastEditedDate: Date var lastEditedDate: Date = Date()
var color: String var color: String = "ff7e30"
var script: String { var script: String {
var txt = "" var txt = ""
@ -24,7 +25,7 @@ final class OCProject {
var sortedCards: [OCCard] { var sortedCards: [OCCard] {
get { get {
return self.cards.sorted(by: { $0.index < $1.index }) return self.cards?.sorted(by: { $0.index < $1.index }) ?? []
} }
} }
@ -41,10 +42,10 @@ final class OCProject {
} }
func addCards(cards: OCCard...) { func addCards(cards: OCCard...) {
cards.forEach({ self.cards.append($0) }) cards.forEach({ self.cards?.append($0) })
} }
func removeCard(_ card: OCCard) { func removeCard(_ card: OCCard) {
self.cards.removeAll { $0.id == card.id } self.cards?.removeAll { $0.id == card.id }
} }
} }

View File

@ -1,5 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict/> <dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.xyz.breadone.oncue</string>
</array>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudKit</string>
</array>
</dict>
</plist> </plist>

View File

@ -7,6 +7,7 @@
import SwiftUI import SwiftUI
import SwiftData import SwiftData
import CoreData
@main @main
struct OnCueApp: App { struct OnCueApp: App {
@ -19,6 +20,34 @@ struct OnCueApp: App {
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
do { do {
// #if DEBUG
// // Use an autorelease pool to make sure Swift deallocates the persistent
// // container before setting up the SwiftData stack.
// try autoreleasepool {
// let desc = NSPersistentStoreDescription(url: modelConfiguration.url)
// let opts = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.xyz.breadone.oncue")
// desc.cloudKitContainerOptions = opts
// // Load the store synchronously so it completes before initializing the
// // CloudKit schema.
// desc.shouldAddStoreAsynchronously = false
// if let mom = NSManagedObjectModel.makeManagedObjectModel(for: [OCProject.self, OCCard.self]) {
// let container = NSPersistentCloudKitContainer(name: "OnCue", managedObjectModel: mom)
// container.persistentStoreDescriptions = [desc]
// container.loadPersistentStores {_, err in
// if let err {
// fatalError(err.localizedDescription)
// }
// }
// // Initialize the CloudKit schema after the store finishes loading.
// try container.initializeCloudKitSchema()
// // Remove and unload the store from the persistent container.
// if let store = container.persistentStoreCoordinator.persistentStores.first {
// try container.persistentStoreCoordinator.remove(store)
// }
// }
// }
// #endif
return try ModelContainer(for: schema, configurations: [modelConfiguration]) return try ModelContainer(for: schema, configurations: [modelConfiguration])
} catch { } catch {
fatalError("Could not create ModelContainer: \(error)") fatalError("Could not create ModelContainer: \(error)")

View File

@ -36,7 +36,7 @@ struct CardsView: View {
} }
} }
} header: { } header: {
Text("\(project.cards.count) \(project.cards.count == 1 ? "Card" : "Cards")") Text("\(project.cards?.count ?? 0) \(project.cards?.count ?? 0 == 1 ? "Card" : "Cards")")
} }
} }
@ -85,7 +85,7 @@ struct CardsView: View {
} }
let card = OCCard(content: txt, index: (project.sortedCards.last?.index ?? -1) + 1) // adds one to the index, unless there arent any cards in which case default to 0 let card = OCCard(content: txt, index: (project.sortedCards.last?.index ?? -1) + 1) // adds one to the index, unless there arent any cards in which case default to 0
project.cards.append(card) project.cards?.append(card)
try! ctx.save() try! ctx.save()
newCardText = "" newCardText = ""
} }

View File

@ -99,7 +99,7 @@ private struct ProjectListView: View {
.font(.title2) .font(.title2)
.foregroundStyle(Color(hex: project.color) ?? .white) .foregroundStyle(Color(hex: project.color) ?? .white)
} }
Text("\(project.cards.count) \(project.cards.count == 1 ? "Card" : "Cards")") Text("\(project.cards?.count ?? 0) \(project.cards?.count ?? 0 == 1 ? "Card" : "Cards")")
} }
} }
.padding(.vertical, 3) .padding(.vertical, 3)

View File

@ -12,7 +12,7 @@ struct CueCardViewPresenter: View {
var body: some View { var body: some View {
TabView() { TabView() {
ForEach(project.cards) { card in ForEach(project.cards ?? []) { card in
CueCardView(card: card) CueCardView(card: card)
} }
} }

View File

@ -27,7 +27,7 @@ struct MainViewPresenter: View {
.bold() .bold()
.font(.title2) .font(.title2)
.foregroundStyle(Color(hex: project.color) ?? .white) .foregroundStyle(Color(hex: project.color) ?? .white)
Text("\(project.cards.count) \(project.cards.count == 1 ? "Card" : "Cards")") Text("\(project.cards?.count ?? 0) \(project.cards?.count ?? 0 == 1 ? "Card" : "Cards")")
} }
} }
.padding(.vertical, 3) .padding(.vertical, 3)