From fd74b0dffc1abdf05b42095fb06f56dbc925034d Mon Sep 17 00:00:00 2001 From: SuzGupta Date: Fri, 28 Oct 2022 10:29:38 -0700 Subject: [PATCH 1/5] Partial implementation. Hardcoded preview & opening a category work (displaying TweetList). Helped needed with user configuration aspects. --- BrainMarksIntents/Info.plist | 24 +++ BrainMarksIntents/IntentHandler.swift | 28 +++ BrainMarksWidgets/BrainMarksWidgets.swift | 37 +++- .../LockScreenWidgetIntents.intentdefinition | 189 ++++++++++++++++++ brain-marks.xcodeproj/project.pbxproj | 154 +++++++++++++- .../Categories/Views/CategoryList.swift | 3 + brain-marks/Info.plist | 4 + 7 files changed, 436 insertions(+), 3 deletions(-) create mode 100644 BrainMarksIntents/Info.plist create mode 100644 BrainMarksIntents/IntentHandler.swift create mode 100644 BrainMarksWidgets/LockScreenWidgetIntents.intentdefinition diff --git a/BrainMarksIntents/Info.plist b/BrainMarksIntents/Info.plist new file mode 100644 index 0000000..ff3268a --- /dev/null +++ b/BrainMarksIntents/Info.plist @@ -0,0 +1,24 @@ + + + + + NSExtension + + NSExtensionAttributes + + IntentsRestrictedWhileLocked + + IntentsRestrictedWhileProtectedDataUnavailable + + IntentsSupported + + ConfigurationIntent + + + NSExtensionPointIdentifier + com.apple.intents-service + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).IntentHandler + + + diff --git a/BrainMarksIntents/IntentHandler.swift b/BrainMarksIntents/IntentHandler.swift new file mode 100644 index 0000000..b3e1a18 --- /dev/null +++ b/BrainMarksIntents/IntentHandler.swift @@ -0,0 +1,28 @@ +// +// IntentHandler.swift +// BrainMarksIntents +// +// Created by Susannah Skyer Gupta on 10/30/22. +// + +import Intents +import SwiftUI + +class IntentHandler: INExtension, ConfigurationIntentIntentHandling { + + @ObservedObject var viewModel = CategoryListViewModel() + + // based on https://github.com/chFlorian/StocksApp/blob/main/StocksAppIntents/IntentHandler.swift + + func provideTweetCategoryOptionsCollection(for intent: ConfigurationIntent, with completion: @escaping (INObjectCollection?, Error?) -> Void) { + + let categories: [TweetCategory] = viewModel.categories + + // Create a collection with the array of categories. + let collection = INObjectCollection(items: categories) + + // Call the completion handler, passing the collection. + completion(collection, nil) + } + +} diff --git a/BrainMarksWidgets/BrainMarksWidgets.swift b/BrainMarksWidgets/BrainMarksWidgets.swift index b22386b..32449e1 100644 --- a/BrainMarksWidgets/BrainMarksWidgets.swift +++ b/BrainMarksWidgets/BrainMarksWidgets.swift @@ -8,7 +8,7 @@ import WidgetKit import SwiftUI -struct Provider: TimelineProvider { +struct Provider: TimelineProvider, IntentTimelineProvider { func placeholder(in context: Context) -> SimpleEntry { SimpleEntry(date: Date()) } @@ -72,12 +72,28 @@ struct BrainMarksAddURLView : View { } } +struct BrainMarksLockScreenEntryView : View { + var entry: Provider.Entry + + var body: some View { + ZStack { + Circle().fill(Color.accentColor).opacity(0.75) +// Image(systemName: "gamecontroller") + Image(systemName: "\(entry.configuration.category.imageName)") + .font(.largeTitle) + } + // will need to pass which category to open as a URL parameter + .widgetURL(URL(string: "brainmarks://openCategory?entry.configuration.category")) + } +} + @main struct BrainMarksWidgetBundle: WidgetBundle { @WidgetBundleBuilder var body: some Widget { BrainMarksCreateCategory() BrainMarksAddURL() + BrainMarksLockScreenWidget() // more widgets can go here } } @@ -119,3 +135,22 @@ struct BrainMarksCreateCategory_Previews: PreviewProvider { .previewContext(WidgetPreviewContext(family: .systemSmall)) } } +struct BrainMarksLockScreenWidget: Widget { + let kind: String = "BrainMarksLockScreen" + + var body: some WidgetConfiguration { + IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in + BrainMarksLockScreenEntryView(entry: entry) + } + .configurationDisplayName("View Category") + .description("Quickly access a Brain Marks category") + .supportedFamilies([.accessoryCircular]) + } +} + +struct BrainMarksLockScreenWidget_Previews: PreviewProvider { + static var previews: some View { + BrainMarksLockScreenEntryView(entry: SimpleEntry(date: Date())) + .previewContext(WidgetPreviewContext(family: .accessoryCircular)) + } +} diff --git a/BrainMarksWidgets/LockScreenWidgetIntents.intentdefinition b/BrainMarksWidgets/LockScreenWidgetIntents.intentdefinition new file mode 100644 index 0000000..fc77aa7 --- /dev/null +++ b/BrainMarksWidgets/LockScreenWidgetIntents.intentdefinition @@ -0,0 +1,189 @@ + + + + + INEnums + + INIntentDefinitionModelVersion + 1.2 + INIntentDefinitionNamespace + cdlIWV + INIntentDefinitionSystemVersion + 21G115 + INIntentDefinitionToolsBuildVersion + 14A309 + INIntentDefinitionToolsVersion + 14.0 + INIntents + + + INIntentCategory + generic + INIntentDescriptionID + XQlAAM + INIntentEligibleForWidgets + + INIntentIneligibleForSuggestions + + INIntentLastParameterTag + 2 + INIntentName + Configuration + INIntentParameters + + + INIntentParameterConfigurable + + INIntentParameterCustomDisambiguation + + INIntentParameterDisplayName + Category + INIntentParameterDisplayNameID + 3UFcb7 + INIntentParameterDisplayPriority + 1 + INIntentParameterName + category + INIntentParameterObjectType + TweetCategory + INIntentParameterObjectTypeNamespace + cdlIWV + INIntentParameterPromptDialogs + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Configuration + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Primary + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogFormatString + There are ${count} options matching ‘${category}’. + INIntentParameterPromptDialogFormatStringID + ZQVkDG + INIntentParameterPromptDialogType + DisambiguationIntroduction + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogFormatString + Just to confirm, you wanted ‘${category}’? + INIntentParameterPromptDialogFormatStringID + uqP1bY + INIntentParameterPromptDialogType + Confirmation + + + INIntentParameterSupportsDynamicEnumeration + + INIntentParameterSupportsResolution + + INIntentParameterTag + 2 + INIntentParameterType + Object + + + INIntentResponse + + INIntentResponseCodes + + + INIntentResponseCodeName + success + INIntentResponseCodeSuccess + + + + INIntentResponseCodeName + failure + + + + INIntentTitle + SelectCategory + INIntentTitleID + APvYQX + INIntentType + Custom + INIntentVerb + Do + + + INTypes + + + INTypeDisplayName + Tweet Category + INTypeDisplayNameID + o7Cgn3 + INTypeLastPropertyTag + 100 + INTypeName + TweetCategory + INTypeProperties + + + INTypePropertyDefault + + INTypePropertyDisplayPriority + 1 + INTypePropertyName + identifier + INTypePropertyTag + 1 + INTypePropertyType + String + + + INTypePropertyDefault + + INTypePropertyDisplayPriority + 2 + INTypePropertyName + displayString + INTypePropertyTag + 2 + INTypePropertyType + String + + + INTypePropertyDefault + + INTypePropertyDisplayPriority + 3 + INTypePropertyName + pronunciationHint + INTypePropertyTag + 3 + INTypePropertyType + String + + + INTypePropertyDefault + + INTypePropertyDisplayPriority + 4 + INTypePropertyName + alternativeSpeakableMatches + INTypePropertySupportsMultipleValues + + INTypePropertyTag + 4 + INTypePropertyType + SpeakableString + + + + + + diff --git a/brain-marks.xcodeproj/project.pbxproj b/brain-marks.xcodeproj/project.pbxproj index d2323d1..6b28f46 100644 --- a/brain-marks.xcodeproj/project.pbxproj +++ b/brain-marks.xcodeproj/project.pbxproj @@ -8,6 +8,13 @@ /* Begin PBXBuildFile section */ 20636BDDDBEF4EAE9CCE9D9E /* amplifyconfiguration.json in Resources */ = {isa = PBXBuildFile; fileRef = ECA1CF04DB754255822691F2 /* amplifyconfiguration.json */; }; + 2A2B5DE8290F49180066D29A /* LockScreenWidgetIntents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 2A2B5DE7290F49180066D29A /* LockScreenWidgetIntents.intentdefinition */; }; + 2A2B5DE9290F49180066D29A /* LockScreenWidgetIntents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 2A2B5DE7290F49180066D29A /* LockScreenWidgetIntents.intentdefinition */; }; + 2A2B5DF0290F4BEF0066D29A /* Intents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A2B5DEF290F4BEF0066D29A /* Intents.framework */; }; + 2A2B5DF3290F4BEF0066D29A /* IntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A2B5DF2290F4BEF0066D29A /* IntentHandler.swift */; }; + 2A2B5DF7290F4BEF0066D29A /* BrainMarksIntents.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 2A2B5DEE290F4BEF0066D29A /* BrainMarksIntents.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 2A2B5DFB290F4C490066D29A /* LockScreenWidgetIntents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 2A2B5DE7290F49180066D29A /* LockScreenWidgetIntents.intentdefinition */; }; + 2A2B5DFC290F510C0066D29A /* IntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A2B5DF2290F4BEF0066D29A /* IntentHandler.swift */; }; 2A7C408128EFCC3600F73DF5 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A7C408028EFCC3600F73DF5 /* WidgetKit.framework */; }; 2A7C408328EFCC3600F73DF5 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A7C408228EFCC3600F73DF5 /* SwiftUI.framework */; }; 2A7C408628EFCC3600F73DF5 /* BrainMarksWidgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A7C408528EFCC3600F73DF5 /* BrainMarksWidgets.swift */; }; @@ -84,6 +91,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 2A2B5DF5290F4BEF0066D29A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = FFEBBB2E26223F75000F475F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 2A2B5DED290F4BEF0066D29A; + remoteInfo = BrainMarksIntents; + }; 2A7C408A28EFCC3700F73DF5 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = FFEBBB2E26223F75000F475F /* Project object */; @@ -114,6 +128,7 @@ dstPath = ""; dstSubfolderSpec = 13; files = ( + 2A2B5DF7290F4BEF0066D29A /* BrainMarksIntents.appex in Embed Foundation Extensions */, 2A7C408C28EFCC3700F73DF5 /* BrainMarksWidgetsExtension.appex in Embed Foundation Extensions */, ); name = "Embed Foundation Extensions"; @@ -125,6 +140,11 @@ 0AA54EDF3B34443CA9D530E5 /* AWSTweet.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = AWSTweet.swift; path = amplify/generated/models/AWSTweet.swift; sourceTree = ""; }; 14F5BDE61EAA4A2DB9030734 /* AmplifyModels.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = AmplifyModels.swift; path = amplify/generated/models/AmplifyModels.swift; sourceTree = ""; }; 1E886624D4EE4F64B9160A75 /* amplifytools.xcconfig */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = text.xcconfig; path = amplifytools.xcconfig; sourceTree = ""; }; + 2A2B5DE7290F49180066D29A /* LockScreenWidgetIntents.intentdefinition */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; path = LockScreenWidgetIntents.intentdefinition; sourceTree = ""; }; + 2A2B5DEE290F4BEF0066D29A /* BrainMarksIntents.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = BrainMarksIntents.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + 2A2B5DEF290F4BEF0066D29A /* Intents.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Intents.framework; path = System/Library/Frameworks/Intents.framework; sourceTree = SDKROOT; }; + 2A2B5DF2290F4BEF0066D29A /* IntentHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntentHandler.swift; sourceTree = ""; }; + 2A2B5DF4290F4BEF0066D29A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 2A7C407E28EFCC3600F73DF5 /* BrainMarksWidgetsExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = BrainMarksWidgetsExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 2A7C408028EFCC3600F73DF5 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; 2A7C408228EFCC3600F73DF5 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; @@ -208,6 +228,14 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 2A2B5DEB290F4BEF0066D29A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 2A2B5DF0290F4BEF0066D29A /* Intents.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 2A7C407B28EFCC3600F73DF5 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -244,11 +272,21 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 2A2B5DF1290F4BEF0066D29A /* BrainMarksIntents */ = { + isa = PBXGroup; + children = ( + 2A2B5DF2290F4BEF0066D29A /* IntentHandler.swift */, + 2A2B5DF4290F4BEF0066D29A /* Info.plist */, + ); + path = BrainMarksIntents; + sourceTree = ""; + }; 2A7C407F28EFCC3600F73DF5 /* Frameworks */ = { isa = PBXGroup; children = ( 2A7C408028EFCC3600F73DF5 /* WidgetKit.framework */, 2A7C408228EFCC3600F73DF5 /* SwiftUI.framework */, + 2A2B5DEF290F4BEF0066D29A /* Intents.framework */, ); name = Frameworks; sourceTree = ""; @@ -259,6 +297,7 @@ 2A7C408528EFCC3600F73DF5 /* BrainMarksWidgets.swift */, 2A7C408728EFCC3700F73DF5 /* Assets.xcassets */, 2A7C408928EFCC3700F73DF5 /* Info.plist */, + 2A2B5DE7290F49180066D29A /* LockScreenWidgetIntents.intentdefinition */, ); path = BrainMarksWidgets; sourceTree = ""; @@ -464,6 +503,7 @@ FFEBBB4A26223F7F000F475F /* brain-marksTests */, FFEBBB5526223F7F000F475F /* brain-marksUITests */, 2A7C408428EFCC3600F73DF5 /* BrainMarksWidgets */, + 2A2B5DF1290F4BEF0066D29A /* BrainMarksIntents */, 2A7C407F28EFCC3600F73DF5 /* Frameworks */, FFEBBB3726223F75000F475F /* Products */, ); @@ -476,6 +516,7 @@ FFEBBB4726223F7F000F475F /* brain-marksTests.xctest */, FFEBBB5226223F7F000F475F /* brain-marksUITests.xctest */, 2A7C407E28EFCC3600F73DF5 /* BrainMarksWidgetsExtension.appex */, + 2A2B5DEE290F4BEF0066D29A /* BrainMarksIntents.appex */, ); name = Products; sourceTree = ""; @@ -535,6 +576,23 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 2A2B5DED290F4BEF0066D29A /* BrainMarksIntents */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2A2B5DF8290F4BEF0066D29A /* Build configuration list for PBXNativeTarget "BrainMarksIntents" */; + buildPhases = ( + 2A2B5DEA290F4BEF0066D29A /* Sources */, + 2A2B5DEB290F4BEF0066D29A /* Frameworks */, + 2A2B5DEC290F4BEF0066D29A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = BrainMarksIntents; + productName = BrainMarksIntents; + productReference = 2A2B5DEE290F4BEF0066D29A /* BrainMarksIntents.appex */; + productType = "com.apple.product-type.app-extension"; + }; 2A7C407D28EFCC3600F73DF5 /* BrainMarksWidgetsExtension */ = { isa = PBXNativeTarget; buildConfigurationList = 2A7C409028EFCC3700F73DF5 /* Build configuration list for PBXNativeTarget "BrainMarksWidgetsExtension" */; @@ -566,6 +624,7 @@ ); dependencies = ( 2A7C408B28EFCC3700F73DF5 /* PBXTargetDependency */, + 2A2B5DF6290F4BEF0066D29A /* PBXTargetDependency */, ); name = "brain-marks"; packageProductDependencies = ( @@ -622,6 +681,9 @@ LastSwiftUpdateCheck = 1400; LastUpgradeCheck = 1320; TargetAttributes = { + 2A2B5DED290F4BEF0066D29A = { + CreatedOnToolsVersion = 14.0; + }; 2A7C407D28EFCC3600F73DF5 = { CreatedOnToolsVersion = 14.0; }; @@ -662,11 +724,19 @@ FFEBBB4626223F7F000F475F /* brain-marksTests */, FFEBBB5126223F7F000F475F /* brain-marksUITests */, 2A7C407D28EFCC3600F73DF5 /* BrainMarksWidgetsExtension */, + 2A2B5DED290F4BEF0066D29A /* BrainMarksIntents */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 2A2B5DEC290F4BEF0066D29A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 2A7C407C28EFCC3600F73DF5 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -741,11 +811,22 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 2A2B5DEA290F4BEF0066D29A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2A2B5DF3290F4BEF0066D29A /* IntentHandler.swift in Sources */, + 2A2B5DFB290F4C490066D29A /* LockScreenWidgetIntents.intentdefinition in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 2A7C407A28EFCC3600F73DF5 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 2A7C408628EFCC3600F73DF5 /* BrainMarksWidgets.swift in Sources */, + 2A2B5DFC290F510C0066D29A /* IntentHandler.swift in Sources */, + 2A2B5DE9290F49180066D29A /* LockScreenWidgetIntents.intentdefinition in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -796,6 +877,7 @@ DB64F8A727270A9B00361E86 /* ContributorProfileView.swift in Sources */, FF39431B262FCF4E00A3623B /* Includes.swift in Sources */, 91739DEB2622D2A7000F982A /* AddURLView.swift in Sources */, + 2A2B5DE8290F49180066D29A /* LockScreenWidgetIntents.intentdefinition in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -818,6 +900,11 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 2A2B5DF6290F4BEF0066D29A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 2A2B5DED290F4BEF0066D29A /* BrainMarksIntents */; + targetProxy = 2A2B5DF5290F4BEF0066D29A /* PBXContainerItemProxy */; + }; 2A7C408B28EFCC3700F73DF5 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 2A7C407D28EFCC3600F73DF5 /* BrainMarksWidgetsExtension */; @@ -858,6 +945,60 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 2A2B5DF9290F4BEF0066D29A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = Y535846H6P; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = BrainMarksIntents/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = BrainMarksIntents; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.mikaelacaron.brainmarks.BrainMarksIntents; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 2A2B5DFA290F4BEF0066D29A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = Y535846H6P; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = BrainMarksIntents/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = BrainMarksIntents; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.mikaelacaron.brainmarks.BrainMarksIntents; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; 2A7C408E28EFCC3700F73DF5 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1047,7 +1188,7 @@ DEVELOPMENT_TEAM = Y535846H6P; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = "brain-marks/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 14.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1071,7 +1212,7 @@ DEVELOPMENT_TEAM = Y535846H6P; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = "brain-marks/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 14.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1172,6 +1313,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 2A2B5DF8290F4BEF0066D29A /* Build configuration list for PBXNativeTarget "BrainMarksIntents" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2A2B5DF9290F4BEF0066D29A /* Debug */, + 2A2B5DFA290F4BEF0066D29A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 2A7C409028EFCC3700F73DF5 /* Build configuration list for PBXNativeTarget "BrainMarksWidgetsExtension" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/brain-marks/Categories/Views/CategoryList.swift b/brain-marks/Categories/Views/CategoryList.swift index 4b5cc27..10c7667 100644 --- a/brain-marks/Categories/Views/CategoryList.swift +++ b/brain-marks/Categories/Views/CategoryList.swift @@ -105,6 +105,9 @@ struct CategoryList: View { showingCategorySheet = true case "addTweet": showAddURLView = true + case "openCategory": + print("Test implementation displays TweetList for first saved category") + TweetList(category: viewModel.categories.first!) default: return } diff --git a/brain-marks/Info.plist b/brain-marks/Info.plist index 193eead..54a5519 100644 --- a/brain-marks/Info.plist +++ b/brain-marks/Info.plist @@ -165,6 +165,10 @@ 1 LSRequiresIPhoneOS + NSUserActivityTypes + + ConfigurationIntent + UIApplicationSceneManifest UIApplicationSupportsMultipleScenes From 78400564706d26f5c1e50d9cebd7ac44f19d18d9 Mon Sep 17 00:00:00 2001 From: SuzGupta Date: Wed, 2 Nov 2022 08:59:41 -0700 Subject: [PATCH 2/5] returning to static widget before pairing with Mark Powell --- BrainMarksIntents/Info.plist | 24 --- BrainMarksIntents/IntentHandler.swift | 28 --- BrainMarksWidgets/BrainMarksWidgets.swift | 9 +- .../LockScreenWidgetIntents.intentdefinition | 189 ------------------ brain-marks.xcodeproj/project.pbxproj | 148 -------------- 5 files changed, 4 insertions(+), 394 deletions(-) delete mode 100644 BrainMarksIntents/Info.plist delete mode 100644 BrainMarksIntents/IntentHandler.swift delete mode 100644 BrainMarksWidgets/LockScreenWidgetIntents.intentdefinition diff --git a/BrainMarksIntents/Info.plist b/BrainMarksIntents/Info.plist deleted file mode 100644 index ff3268a..0000000 --- a/BrainMarksIntents/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - NSExtension - - NSExtensionAttributes - - IntentsRestrictedWhileLocked - - IntentsRestrictedWhileProtectedDataUnavailable - - IntentsSupported - - ConfigurationIntent - - - NSExtensionPointIdentifier - com.apple.intents-service - NSExtensionPrincipalClass - $(PRODUCT_MODULE_NAME).IntentHandler - - - diff --git a/BrainMarksIntents/IntentHandler.swift b/BrainMarksIntents/IntentHandler.swift deleted file mode 100644 index b3e1a18..0000000 --- a/BrainMarksIntents/IntentHandler.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// IntentHandler.swift -// BrainMarksIntents -// -// Created by Susannah Skyer Gupta on 10/30/22. -// - -import Intents -import SwiftUI - -class IntentHandler: INExtension, ConfigurationIntentIntentHandling { - - @ObservedObject var viewModel = CategoryListViewModel() - - // based on https://github.com/chFlorian/StocksApp/blob/main/StocksAppIntents/IntentHandler.swift - - func provideTweetCategoryOptionsCollection(for intent: ConfigurationIntent, with completion: @escaping (INObjectCollection?, Error?) -> Void) { - - let categories: [TweetCategory] = viewModel.categories - - // Create a collection with the array of categories. - let collection = INObjectCollection(items: categories) - - // Call the completion handler, passing the collection. - completion(collection, nil) - } - -} diff --git a/BrainMarksWidgets/BrainMarksWidgets.swift b/BrainMarksWidgets/BrainMarksWidgets.swift index 32449e1..3665ba8 100644 --- a/BrainMarksWidgets/BrainMarksWidgets.swift +++ b/BrainMarksWidgets/BrainMarksWidgets.swift @@ -8,7 +8,7 @@ import WidgetKit import SwiftUI -struct Provider: TimelineProvider, IntentTimelineProvider { +struct Provider: TimelineProvider { func placeholder(in context: Context) -> SimpleEntry { SimpleEntry(date: Date()) } @@ -78,12 +78,11 @@ struct BrainMarksLockScreenEntryView : View { var body: some View { ZStack { Circle().fill(Color.accentColor).opacity(0.75) -// Image(systemName: "gamecontroller") - Image(systemName: "\(entry.configuration.category.imageName)") + Image(systemName: "gamecontroller") .font(.largeTitle) } // will need to pass which category to open as a URL parameter - .widgetURL(URL(string: "brainmarks://openCategory?entry.configuration.category")) + .widgetURL(URL(string: "brainmarks://openCategory")) } } @@ -139,7 +138,7 @@ struct BrainMarksLockScreenWidget: Widget { let kind: String = "BrainMarksLockScreen" var body: some WidgetConfiguration { - IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in + StaticConfiguration(kind: kind, provider: Provider()) { entry in BrainMarksLockScreenEntryView(entry: entry) } .configurationDisplayName("View Category") diff --git a/BrainMarksWidgets/LockScreenWidgetIntents.intentdefinition b/BrainMarksWidgets/LockScreenWidgetIntents.intentdefinition deleted file mode 100644 index fc77aa7..0000000 --- a/BrainMarksWidgets/LockScreenWidgetIntents.intentdefinition +++ /dev/null @@ -1,189 +0,0 @@ - - - - - INEnums - - INIntentDefinitionModelVersion - 1.2 - INIntentDefinitionNamespace - cdlIWV - INIntentDefinitionSystemVersion - 21G115 - INIntentDefinitionToolsBuildVersion - 14A309 - INIntentDefinitionToolsVersion - 14.0 - INIntents - - - INIntentCategory - generic - INIntentDescriptionID - XQlAAM - INIntentEligibleForWidgets - - INIntentIneligibleForSuggestions - - INIntentLastParameterTag - 2 - INIntentName - Configuration - INIntentParameters - - - INIntentParameterConfigurable - - INIntentParameterCustomDisambiguation - - INIntentParameterDisplayName - Category - INIntentParameterDisplayNameID - 3UFcb7 - INIntentParameterDisplayPriority - 1 - INIntentParameterName - category - INIntentParameterObjectType - TweetCategory - INIntentParameterObjectTypeNamespace - cdlIWV - INIntentParameterPromptDialogs - - - INIntentParameterPromptDialogCustom - - INIntentParameterPromptDialogType - Configuration - - - INIntentParameterPromptDialogCustom - - INIntentParameterPromptDialogType - Primary - - - INIntentParameterPromptDialogCustom - - INIntentParameterPromptDialogFormatString - There are ${count} options matching ‘${category}’. - INIntentParameterPromptDialogFormatStringID - ZQVkDG - INIntentParameterPromptDialogType - DisambiguationIntroduction - - - INIntentParameterPromptDialogCustom - - INIntentParameterPromptDialogFormatString - Just to confirm, you wanted ‘${category}’? - INIntentParameterPromptDialogFormatStringID - uqP1bY - INIntentParameterPromptDialogType - Confirmation - - - INIntentParameterSupportsDynamicEnumeration - - INIntentParameterSupportsResolution - - INIntentParameterTag - 2 - INIntentParameterType - Object - - - INIntentResponse - - INIntentResponseCodes - - - INIntentResponseCodeName - success - INIntentResponseCodeSuccess - - - - INIntentResponseCodeName - failure - - - - INIntentTitle - SelectCategory - INIntentTitleID - APvYQX - INIntentType - Custom - INIntentVerb - Do - - - INTypes - - - INTypeDisplayName - Tweet Category - INTypeDisplayNameID - o7Cgn3 - INTypeLastPropertyTag - 100 - INTypeName - TweetCategory - INTypeProperties - - - INTypePropertyDefault - - INTypePropertyDisplayPriority - 1 - INTypePropertyName - identifier - INTypePropertyTag - 1 - INTypePropertyType - String - - - INTypePropertyDefault - - INTypePropertyDisplayPriority - 2 - INTypePropertyName - displayString - INTypePropertyTag - 2 - INTypePropertyType - String - - - INTypePropertyDefault - - INTypePropertyDisplayPriority - 3 - INTypePropertyName - pronunciationHint - INTypePropertyTag - 3 - INTypePropertyType - String - - - INTypePropertyDefault - - INTypePropertyDisplayPriority - 4 - INTypePropertyName - alternativeSpeakableMatches - INTypePropertySupportsMultipleValues - - INTypePropertyTag - 4 - INTypePropertyType - SpeakableString - - - - - - diff --git a/brain-marks.xcodeproj/project.pbxproj b/brain-marks.xcodeproj/project.pbxproj index 6b28f46..3e02d6d 100644 --- a/brain-marks.xcodeproj/project.pbxproj +++ b/brain-marks.xcodeproj/project.pbxproj @@ -8,13 +8,6 @@ /* Begin PBXBuildFile section */ 20636BDDDBEF4EAE9CCE9D9E /* amplifyconfiguration.json in Resources */ = {isa = PBXBuildFile; fileRef = ECA1CF04DB754255822691F2 /* amplifyconfiguration.json */; }; - 2A2B5DE8290F49180066D29A /* LockScreenWidgetIntents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 2A2B5DE7290F49180066D29A /* LockScreenWidgetIntents.intentdefinition */; }; - 2A2B5DE9290F49180066D29A /* LockScreenWidgetIntents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 2A2B5DE7290F49180066D29A /* LockScreenWidgetIntents.intentdefinition */; }; - 2A2B5DF0290F4BEF0066D29A /* Intents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A2B5DEF290F4BEF0066D29A /* Intents.framework */; }; - 2A2B5DF3290F4BEF0066D29A /* IntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A2B5DF2290F4BEF0066D29A /* IntentHandler.swift */; }; - 2A2B5DF7290F4BEF0066D29A /* BrainMarksIntents.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 2A2B5DEE290F4BEF0066D29A /* BrainMarksIntents.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; - 2A2B5DFB290F4C490066D29A /* LockScreenWidgetIntents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 2A2B5DE7290F49180066D29A /* LockScreenWidgetIntents.intentdefinition */; }; - 2A2B5DFC290F510C0066D29A /* IntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A2B5DF2290F4BEF0066D29A /* IntentHandler.swift */; }; 2A7C408128EFCC3600F73DF5 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A7C408028EFCC3600F73DF5 /* WidgetKit.framework */; }; 2A7C408328EFCC3600F73DF5 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A7C408228EFCC3600F73DF5 /* SwiftUI.framework */; }; 2A7C408628EFCC3600F73DF5 /* BrainMarksWidgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A7C408528EFCC3600F73DF5 /* BrainMarksWidgets.swift */; }; @@ -91,13 +84,6 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 2A2B5DF5290F4BEF0066D29A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = FFEBBB2E26223F75000F475F /* Project object */; - proxyType = 1; - remoteGlobalIDString = 2A2B5DED290F4BEF0066D29A; - remoteInfo = BrainMarksIntents; - }; 2A7C408A28EFCC3700F73DF5 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = FFEBBB2E26223F75000F475F /* Project object */; @@ -128,7 +114,6 @@ dstPath = ""; dstSubfolderSpec = 13; files = ( - 2A2B5DF7290F4BEF0066D29A /* BrainMarksIntents.appex in Embed Foundation Extensions */, 2A7C408C28EFCC3700F73DF5 /* BrainMarksWidgetsExtension.appex in Embed Foundation Extensions */, ); name = "Embed Foundation Extensions"; @@ -140,11 +125,7 @@ 0AA54EDF3B34443CA9D530E5 /* AWSTweet.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = AWSTweet.swift; path = amplify/generated/models/AWSTweet.swift; sourceTree = ""; }; 14F5BDE61EAA4A2DB9030734 /* AmplifyModels.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = AmplifyModels.swift; path = amplify/generated/models/AmplifyModels.swift; sourceTree = ""; }; 1E886624D4EE4F64B9160A75 /* amplifytools.xcconfig */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = text.xcconfig; path = amplifytools.xcconfig; sourceTree = ""; }; - 2A2B5DE7290F49180066D29A /* LockScreenWidgetIntents.intentdefinition */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; path = LockScreenWidgetIntents.intentdefinition; sourceTree = ""; }; - 2A2B5DEE290F4BEF0066D29A /* BrainMarksIntents.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = BrainMarksIntents.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 2A2B5DEF290F4BEF0066D29A /* Intents.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Intents.framework; path = System/Library/Frameworks/Intents.framework; sourceTree = SDKROOT; }; - 2A2B5DF2290F4BEF0066D29A /* IntentHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntentHandler.swift; sourceTree = ""; }; - 2A2B5DF4290F4BEF0066D29A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 2A7C407E28EFCC3600F73DF5 /* BrainMarksWidgetsExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = BrainMarksWidgetsExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 2A7C408028EFCC3600F73DF5 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; 2A7C408228EFCC3600F73DF5 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; @@ -228,14 +209,6 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 2A2B5DEB290F4BEF0066D29A /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 2A2B5DF0290F4BEF0066D29A /* Intents.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 2A7C407B28EFCC3600F73DF5 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -272,15 +245,6 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 2A2B5DF1290F4BEF0066D29A /* BrainMarksIntents */ = { - isa = PBXGroup; - children = ( - 2A2B5DF2290F4BEF0066D29A /* IntentHandler.swift */, - 2A2B5DF4290F4BEF0066D29A /* Info.plist */, - ); - path = BrainMarksIntents; - sourceTree = ""; - }; 2A7C407F28EFCC3600F73DF5 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -297,7 +261,6 @@ 2A7C408528EFCC3600F73DF5 /* BrainMarksWidgets.swift */, 2A7C408728EFCC3700F73DF5 /* Assets.xcassets */, 2A7C408928EFCC3700F73DF5 /* Info.plist */, - 2A2B5DE7290F49180066D29A /* LockScreenWidgetIntents.intentdefinition */, ); path = BrainMarksWidgets; sourceTree = ""; @@ -503,7 +466,6 @@ FFEBBB4A26223F7F000F475F /* brain-marksTests */, FFEBBB5526223F7F000F475F /* brain-marksUITests */, 2A7C408428EFCC3600F73DF5 /* BrainMarksWidgets */, - 2A2B5DF1290F4BEF0066D29A /* BrainMarksIntents */, 2A7C407F28EFCC3600F73DF5 /* Frameworks */, FFEBBB3726223F75000F475F /* Products */, ); @@ -516,7 +478,6 @@ FFEBBB4726223F7F000F475F /* brain-marksTests.xctest */, FFEBBB5226223F7F000F475F /* brain-marksUITests.xctest */, 2A7C407E28EFCC3600F73DF5 /* BrainMarksWidgetsExtension.appex */, - 2A2B5DEE290F4BEF0066D29A /* BrainMarksIntents.appex */, ); name = Products; sourceTree = ""; @@ -576,23 +537,6 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 2A2B5DED290F4BEF0066D29A /* BrainMarksIntents */ = { - isa = PBXNativeTarget; - buildConfigurationList = 2A2B5DF8290F4BEF0066D29A /* Build configuration list for PBXNativeTarget "BrainMarksIntents" */; - buildPhases = ( - 2A2B5DEA290F4BEF0066D29A /* Sources */, - 2A2B5DEB290F4BEF0066D29A /* Frameworks */, - 2A2B5DEC290F4BEF0066D29A /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = BrainMarksIntents; - productName = BrainMarksIntents; - productReference = 2A2B5DEE290F4BEF0066D29A /* BrainMarksIntents.appex */; - productType = "com.apple.product-type.app-extension"; - }; 2A7C407D28EFCC3600F73DF5 /* BrainMarksWidgetsExtension */ = { isa = PBXNativeTarget; buildConfigurationList = 2A7C409028EFCC3700F73DF5 /* Build configuration list for PBXNativeTarget "BrainMarksWidgetsExtension" */; @@ -624,7 +568,6 @@ ); dependencies = ( 2A7C408B28EFCC3700F73DF5 /* PBXTargetDependency */, - 2A2B5DF6290F4BEF0066D29A /* PBXTargetDependency */, ); name = "brain-marks"; packageProductDependencies = ( @@ -681,9 +624,6 @@ LastSwiftUpdateCheck = 1400; LastUpgradeCheck = 1320; TargetAttributes = { - 2A2B5DED290F4BEF0066D29A = { - CreatedOnToolsVersion = 14.0; - }; 2A7C407D28EFCC3600F73DF5 = { CreatedOnToolsVersion = 14.0; }; @@ -724,19 +664,11 @@ FFEBBB4626223F7F000F475F /* brain-marksTests */, FFEBBB5126223F7F000F475F /* brain-marksUITests */, 2A7C407D28EFCC3600F73DF5 /* BrainMarksWidgetsExtension */, - 2A2B5DED290F4BEF0066D29A /* BrainMarksIntents */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - 2A2B5DEC290F4BEF0066D29A /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; 2A7C407C28EFCC3600F73DF5 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -811,22 +743,11 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - 2A2B5DEA290F4BEF0066D29A /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 2A2B5DF3290F4BEF0066D29A /* IntentHandler.swift in Sources */, - 2A2B5DFB290F4C490066D29A /* LockScreenWidgetIntents.intentdefinition in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 2A7C407A28EFCC3600F73DF5 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 2A7C408628EFCC3600F73DF5 /* BrainMarksWidgets.swift in Sources */, - 2A2B5DFC290F510C0066D29A /* IntentHandler.swift in Sources */, - 2A2B5DE9290F49180066D29A /* LockScreenWidgetIntents.intentdefinition in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -877,7 +798,6 @@ DB64F8A727270A9B00361E86 /* ContributorProfileView.swift in Sources */, FF39431B262FCF4E00A3623B /* Includes.swift in Sources */, 91739DEB2622D2A7000F982A /* AddURLView.swift in Sources */, - 2A2B5DE8290F49180066D29A /* LockScreenWidgetIntents.intentdefinition in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -900,11 +820,6 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 2A2B5DF6290F4BEF0066D29A /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 2A2B5DED290F4BEF0066D29A /* BrainMarksIntents */; - targetProxy = 2A2B5DF5290F4BEF0066D29A /* PBXContainerItemProxy */; - }; 2A7C408B28EFCC3700F73DF5 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 2A7C407D28EFCC3600F73DF5 /* BrainMarksWidgetsExtension */; @@ -945,60 +860,6 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ - 2A2B5DF9290F4BEF0066D29A /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = Y535846H6P; - GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_FILE = BrainMarksIntents/Info.plist; - INFOPLIST_KEY_CFBundleDisplayName = BrainMarksIntents; - INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@executable_path/../../Frameworks", - ); - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.mikaelacaron.brainmarks.BrainMarksIntents; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 2A2B5DFA290F4BEF0066D29A /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = Y535846H6P; - GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_FILE = BrainMarksIntents/Info.plist; - INFOPLIST_KEY_CFBundleDisplayName = BrainMarksIntents; - INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@executable_path/../../Frameworks", - ); - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.mikaelacaron.brainmarks.BrainMarksIntents; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; 2A7C408E28EFCC3700F73DF5 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1313,15 +1174,6 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 2A2B5DF8290F4BEF0066D29A /* Build configuration list for PBXNativeTarget "BrainMarksIntents" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2A2B5DF9290F4BEF0066D29A /* Debug */, - 2A2B5DFA290F4BEF0066D29A /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; 2A7C409028EFCC3700F73DF5 /* Build configuration list for PBXNativeTarget "BrainMarksWidgetsExtension" */ = { isa = XCConfigurationList; buildConfigurations = ( From c03a0a03b4e09604923dc3fb48c72b1275f4a86f Mon Sep 17 00:00:00 2001 From: SuzGupta Date: Wed, 2 Nov 2022 11:51:28 -0700 Subject: [PATCH 3/5] Work done with Mark Powell: added App Group, encoded categories into a JSON file and stored in App Group, starting to decode into widget but realized we need a new model that's not dependent on Amplify, since that will go away. --- BrainMarksWidgets/BrainMarksWidgets.swift | 17 +++++++- brain-marks.xcodeproj/project.pbxproj | 40 +++++++++++-------- .../Categories/CategoryListViewModel.swift | 23 +++++++++++ brain-marks/brain-marks.entitlements | 10 +++++ 4 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 brain-marks/brain-marks.entitlements diff --git a/BrainMarksWidgets/BrainMarksWidgets.swift b/BrainMarksWidgets/BrainMarksWidgets.swift index 3665ba8..5ce4f44 100644 --- a/BrainMarksWidgets/BrainMarksWidgets.swift +++ b/BrainMarksWidgets/BrainMarksWidgets.swift @@ -35,7 +35,22 @@ struct Provider: TimelineProvider { } struct SimpleEntry: TimelineEntry { - let date: Date + let date: Date + func readContainer() { + guard let URL = FileManager.default.containerURL( + forSecurityApplicationGroupIdentifier: "group.com.suzgupta.brainmarks" + ) else { + return + } + let decoder = JSONDecoder() + if let codeData = try? Data(contentsOf: URL) { + do { + contents = try decoder.decode([AWSCategory].self, from: codeData) + } catch { + print("Error: Can't decode contents") + } + } + } } struct BrainMarksCreateCategoryEntryView : View { diff --git a/brain-marks.xcodeproj/project.pbxproj b/brain-marks.xcodeproj/project.pbxproj index 3e02d6d..e791f98 100644 --- a/brain-marks.xcodeproj/project.pbxproj +++ b/brain-marks.xcodeproj/project.pbxproj @@ -13,6 +13,8 @@ 2A7C408628EFCC3600F73DF5 /* BrainMarksWidgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A7C408528EFCC3600F73DF5 /* BrainMarksWidgets.swift */; }; 2A7C408828EFCC3700F73DF5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2A7C408728EFCC3700F73DF5 /* Assets.xcassets */; }; 2A7C408C28EFCC3700F73DF5 /* BrainMarksWidgetsExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 2A7C407E28EFCC3600F73DF5 /* BrainMarksWidgetsExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 2AA58B622912E6A900BF551D /* AWSCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63D0518628EF45A382F08352 /* AWSCategory.swift */; }; + 2AA58B632912E6D300BF551D /* AWSTweet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA54EDF3B34443CA9D530E5 /* AWSTweet.swift */; }; 45B4425428EF5AC800FB0B27 /* AppIconSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45B4425328EF5AC800FB0B27 /* AppIconSettings.swift */; }; 45B4426628EF5EA300FB0B27 /* 8 Rainbow.png in Resources */ = {isa = PBXBuildFile; fileRef = 45B4425628EF5EA300FB0B27 /* 8 Rainbow.png */; }; 45B4426828EF5EA300FB0B27 /* 4 Beach.png in Resources */ = {isa = PBXBuildFile; fileRef = 45B4425828EF5EA300FB0B27 /* 4 Beach.png */; }; @@ -132,6 +134,7 @@ 2A7C408528EFCC3600F73DF5 /* BrainMarksWidgets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrainMarksWidgets.swift; sourceTree = ""; }; 2A7C408728EFCC3700F73DF5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 2A7C408928EFCC3700F73DF5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 2AE728C32912DB6900785853 /* brain-marks.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "brain-marks.entitlements"; sourceTree = ""; }; 45B4425328EF5AC800FB0B27 /* AppIconSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIconSettings.swift; sourceTree = ""; }; 45B4425628EF5EA300FB0B27 /* 8 Rainbow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "8 Rainbow.png"; sourceTree = ""; }; 45B4425828EF5EA300FB0B27 /* 4 Beach.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "4 Beach.png"; sourceTree = ""; }; @@ -485,6 +488,7 @@ FFEBBB3826223F75000F475F /* brain-marks */ = { isa = PBXGroup; children = ( + 2AE728C32912DB6900785853 /* brain-marks.entitlements */, FF3942FF262E847000A3623B /* Add */, FF39430E262E863000A3623B /* AmplifyModelExtensions */, FF39432A262FD05700A3623B /* Categories */, @@ -747,7 +751,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 2AA58B632912E6D300BF551D /* AWSTweet.swift in Sources */, 2A7C408628EFCC3600F73DF5 /* BrainMarksWidgets.swift in Sources */, + 2AA58B622912E6A900BF551D /* AWSCategory.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -868,7 +874,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = BrainMarksWidgets/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = BrainMarksWidgets; @@ -880,7 +886,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.1; - PRODUCT_BUNDLE_IDENTIFIER = com.mikaelacaron.brainmarks.BrainMarksWidgets; + PRODUCT_BUNDLE_IDENTIFIER = com.suzgupta.brainmarks.BrainMarksWidgets; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; @@ -897,7 +903,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = BrainMarksWidgets/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = BrainMarksWidgets; @@ -909,7 +915,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.1; - PRODUCT_BUNDLE_IDENTIFIER = com.mikaelacaron.brainmarks.BrainMarksWidgets; + PRODUCT_BUNDLE_IDENTIFIER = com.suzgupta.brainmarks.BrainMarksWidgets; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; @@ -1044,9 +1050,10 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = "brain-marks/brain-marks.entitlements"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"brain-marks/Preview Content\""; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = "brain-marks/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 16.0; @@ -1055,7 +1062,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.1; - PRODUCT_BUNDLE_IDENTIFIER = com.mikaelacaron.brainmarks; + PRODUCT_BUNDLE_IDENTIFIER = com.suzgupta.brainmarks; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1068,9 +1075,10 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = "brain-marks/brain-marks.entitlements"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"brain-marks/Preview Content\""; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = "brain-marks/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 16.0; @@ -1079,7 +1087,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.1; - PRODUCT_BUNDLE_IDENTIFIER = com.mikaelacaron.brainmarks; + PRODUCT_BUNDLE_IDENTIFIER = com.suzgupta.brainmarks; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; @@ -1093,7 +1101,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; INFOPLIST_FILE = "brain-marksTests/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -1101,7 +1109,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.mikaelacaron.brain-marksTests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.suzgupta.brain-marksTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1115,7 +1123,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; INFOPLIST_FILE = "brain-marksTests/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -1123,7 +1131,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.mikaelacaron.brain-marksTests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.suzgupta.brain-marksTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1136,14 +1144,14 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; INFOPLIST_FILE = "brain-marksUITests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.mikaelacaron.brain-marksUITests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.suzgupta.brain-marksUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1156,14 +1164,14 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; INFOPLIST_FILE = "brain-marksUITests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.mikaelacaron.brain-marksUITests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.suzgupta.brain-marksUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/brain-marks/Categories/CategoryListViewModel.swift b/brain-marks/Categories/CategoryListViewModel.swift index fba0ee5..fe53c9d 100644 --- a/brain-marks/Categories/CategoryListViewModel.swift +++ b/brain-marks/Categories/CategoryListViewModel.swift @@ -18,6 +18,27 @@ final class CategoryListViewModel: ObservableObject { init() { getCategoryOrder() } + + func writeToContainer() { + guard let URL = FileManager.default.containerURL( + forSecurityApplicationGroupIdentifier: "group.com.suzgupta.brainmarks" + ) else { + return + } + let widgetContents = categories + let archiveURL = URL + .appendingPathComponent("categories.json") + print(">>> \(archiveURL)") + let encoder = JSONEncoder() + if let dataToSave = try? encoder.encode(widgetContents) { + do { + try dataToSave.write(to: archiveURL) + } catch { + print("Error: Can't write contents") + return + } + } + } func getCategories() { categories = [] @@ -26,7 +47,9 @@ final class CategoryListViewModel: ObservableObject { case .success(let categories): DispatchQueue.main.async { self.categories = self.sortCategories(categories) + self.writeToContainer() } + case .failure(let error): Logger.dataStore.error("Error fetching categories: \(error)") } diff --git a/brain-marks/brain-marks.entitlements b/brain-marks/brain-marks.entitlements new file mode 100644 index 0000000..1815d24 --- /dev/null +++ b/brain-marks/brain-marks.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.com.suzgupta.brainmarks + + + From d4203cbfdf7e1afef6278425adcf3d15d83ca955 Mon Sep 17 00:00:00 2001 From: SuzGupta Date: Fri, 4 Nov 2022 17:29:15 -0700 Subject: [PATCH 4/5] added two local models to remove dependency on AWS in widget when I want to decode JSON that's now in app group file. not sure yet how to work with this. --- BrainMarksWidgets/BrainMarksWidgets.swift | 5 ++- LocalCategoryModel.swift | 27 ++++++++++++ brain-marks.xcodeproj/project.pbxproj | 16 +++++-- .../AWSTweet+Extension.swift | 1 - brain-marks/Categories/LocalTweetModel.swift | 43 +++++++++++++++++++ 5 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 LocalCategoryModel.swift create mode 100644 brain-marks/Categories/LocalTweetModel.swift diff --git a/BrainMarksWidgets/BrainMarksWidgets.swift b/BrainMarksWidgets/BrainMarksWidgets.swift index 5ce4f44..b654460 100644 --- a/BrainMarksWidgets/BrainMarksWidgets.swift +++ b/BrainMarksWidgets/BrainMarksWidgets.swift @@ -45,7 +45,8 @@ struct SimpleEntry: TimelineEntry { let decoder = JSONDecoder() if let codeData = try? Data(contentsOf: URL) { do { - contents = try decoder.decode([AWSCategory].self, from: codeData) + let contents = try decoder.decode([LocalCategory].self, from: codeData) + print(contents) } catch { print("Error: Can't decode contents") } @@ -57,7 +58,7 @@ struct BrainMarksCreateCategoryEntryView : View { var entry: Provider.Entry var body: some View { - + ZStack { Image("littleLogo") .resizable() diff --git a/LocalCategoryModel.swift b/LocalCategoryModel.swift new file mode 100644 index 0000000..d8424cc --- /dev/null +++ b/LocalCategoryModel.swift @@ -0,0 +1,27 @@ +// +// LocalCategoryModel.swift +// brain-marks +// +// Created by Susannah Skyer Gupta on 11/4/22. +// + +import Foundation + +public struct LocalCategory: Codable { + public let id: String + public var name: String + public var imageName: String? + public var tweets: [LocalTweet]? + public var categoryThumbnail: String? + + public init(id: String = UUID().uuidString, + name: String, + imageName: String? = "folder", + tweets: [LocalTweet] = [] + ) { + self.id = id + self.name = name + self.imageName = imageName + self.tweets = tweets + } +} diff --git a/brain-marks.xcodeproj/project.pbxproj b/brain-marks.xcodeproj/project.pbxproj index e791f98..e941260 100644 --- a/brain-marks.xcodeproj/project.pbxproj +++ b/brain-marks.xcodeproj/project.pbxproj @@ -8,13 +8,15 @@ /* Begin PBXBuildFile section */ 20636BDDDBEF4EAE9CCE9D9E /* amplifyconfiguration.json in Resources */ = {isa = PBXBuildFile; fileRef = ECA1CF04DB754255822691F2 /* amplifyconfiguration.json */; }; + 2A41044B29156A4F00EFB98B /* LocalCategoryModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A41044A29156A4F00EFB98B /* LocalCategoryModel.swift */; }; + 2A41044C29156A4F00EFB98B /* LocalCategoryModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A41044A29156A4F00EFB98B /* LocalCategoryModel.swift */; }; + 2A41044E29156BB600EFB98B /* LocalTweetModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A41044D29156BB600EFB98B /* LocalTweetModel.swift */; }; + 2A41044F29156BB600EFB98B /* LocalTweetModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A41044D29156BB600EFB98B /* LocalTweetModel.swift */; }; 2A7C408128EFCC3600F73DF5 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A7C408028EFCC3600F73DF5 /* WidgetKit.framework */; }; 2A7C408328EFCC3600F73DF5 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A7C408228EFCC3600F73DF5 /* SwiftUI.framework */; }; 2A7C408628EFCC3600F73DF5 /* BrainMarksWidgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A7C408528EFCC3600F73DF5 /* BrainMarksWidgets.swift */; }; 2A7C408828EFCC3700F73DF5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2A7C408728EFCC3700F73DF5 /* Assets.xcassets */; }; 2A7C408C28EFCC3700F73DF5 /* BrainMarksWidgetsExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 2A7C407E28EFCC3600F73DF5 /* BrainMarksWidgetsExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; - 2AA58B622912E6A900BF551D /* AWSCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63D0518628EF45A382F08352 /* AWSCategory.swift */; }; - 2AA58B632912E6D300BF551D /* AWSTweet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA54EDF3B34443CA9D530E5 /* AWSTweet.swift */; }; 45B4425428EF5AC800FB0B27 /* AppIconSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45B4425328EF5AC800FB0B27 /* AppIconSettings.swift */; }; 45B4426628EF5EA300FB0B27 /* 8 Rainbow.png in Resources */ = {isa = PBXBuildFile; fileRef = 45B4425628EF5EA300FB0B27 /* 8 Rainbow.png */; }; 45B4426828EF5EA300FB0B27 /* 4 Beach.png in Resources */ = {isa = PBXBuildFile; fileRef = 45B4425828EF5EA300FB0B27 /* 4 Beach.png */; }; @@ -128,6 +130,8 @@ 14F5BDE61EAA4A2DB9030734 /* AmplifyModels.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = AmplifyModels.swift; path = amplify/generated/models/AmplifyModels.swift; sourceTree = ""; }; 1E886624D4EE4F64B9160A75 /* amplifytools.xcconfig */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = text.xcconfig; path = amplifytools.xcconfig; sourceTree = ""; }; 2A2B5DEF290F4BEF0066D29A /* Intents.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Intents.framework; path = System/Library/Frameworks/Intents.framework; sourceTree = SDKROOT; }; + 2A41044A29156A4F00EFB98B /* LocalCategoryModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalCategoryModel.swift; sourceTree = SOURCE_ROOT; }; + 2A41044D29156BB600EFB98B /* LocalTweetModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalTweetModel.swift; sourceTree = ""; }; 2A7C407E28EFCC3600F73DF5 /* BrainMarksWidgetsExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = BrainMarksWidgetsExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 2A7C408028EFCC3600F73DF5 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; 2A7C408228EFCC3600F73DF5 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; @@ -414,6 +418,8 @@ FF39432A262FD05700A3623B /* Categories */ = { isa = PBXGroup; children = ( + 2A41044A29156A4F00EFB98B /* LocalCategoryModel.swift */, + 2A41044D29156BB600EFB98B /* LocalTweetModel.swift */, FF39432C262FD07D00A3623B /* Views */, FF6DCBF12623530400EC366F /* CategoryListViewModel.swift */, 940E3C61272648310038D6AC /* CategorySheetViewModel.swift */, @@ -751,9 +757,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2AA58B632912E6D300BF551D /* AWSTweet.swift in Sources */, + 2A41044C29156A4F00EFB98B /* LocalCategoryModel.swift in Sources */, 2A7C408628EFCC3600F73DF5 /* BrainMarksWidgets.swift in Sources */, - 2AA58B622912E6A900BF551D /* AWSCategory.swift in Sources */, + 2A41044F29156BB600EFB98B /* LocalTweetModel.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -770,6 +776,7 @@ FFCB1097263E31D400544309 /* ReturnedTweet.swift in Sources */, DBF50B55272467CF000D8B25 /* SettingsView.swift in Sources */, 5F118BE728EC0BE9003E15F2 /* Logger+Ext.swift in Sources */, + 2A41044B29156A4F00EFB98B /* LocalCategoryModel.swift in Sources */, FF21986F269FE57D00FFB406 /* AsyncImage.swift in Sources */, D3D5E0E5271C811E00752DCD /* InfoViewModel.swift in Sources */, FFEB1B5826A9F9C300682C37 /* Alert.swift in Sources */, @@ -779,6 +786,7 @@ DB64F8A52726BD5D00361E86 /* Contributor.swift in Sources */, A2F449912622829D00725FEA /* CategoryList.swift in Sources */, 896E0E3B28EEE03E009994F4 /* RequestBuilder.swift in Sources */, + 2A41044E29156BB600EFB98B /* LocalTweetModel.swift in Sources */, A2F4498C2622802B00725FEA /* CategoryRow.swift in Sources */, FF5990692622DD61004DF328 /* DataStoreManager.swift in Sources */, FFCB1099263E3E2D00544309 /* CategorySheetView.swift in Sources */, diff --git a/brain-marks/AmplifyModelExtensions/AWSTweet+Extension.swift b/brain-marks/AmplifyModelExtensions/AWSTweet+Extension.swift index 6939155..2b6ee3e 100644 --- a/brain-marks/AmplifyModelExtensions/AWSTweet+Extension.swift +++ b/brain-marks/AmplifyModelExtensions/AWSTweet+Extension.swift @@ -81,4 +81,3 @@ extension AWSTweet { userVerified: false) ] } - diff --git a/brain-marks/Categories/LocalTweetModel.swift b/brain-marks/Categories/LocalTweetModel.swift new file mode 100644 index 0000000..bf2b272 --- /dev/null +++ b/brain-marks/Categories/LocalTweetModel.swift @@ -0,0 +1,43 @@ +// +// LocalTweetModel.swift +// brain-marks +// +// Created by Susannah Skyer Gupta on 11/4/22. +// + +import Foundation + +public struct LocalTweet: Codable { + public let id: String + public var tweetID: String + public var text: String? + public var timeStamp: String? + public var authorName: String? + public var authorUsername: String? + public var profileImageURL: String? + public var photosURL: [String]? + public var category: LocalCategory? + public var userVerified: Bool? + + public init(id: String = UUID().uuidString, + tweetID: String, + text: String? = nil, + timeStamp: String? = nil, + authorName: String? = nil, + authorUsername: String? = nil, + profileImageURL: String? = nil, + photosURL: [String]? = [], + category: LocalCategory? = nil, + userVerified: Bool? = nil) { + self.id = id + self.tweetID = tweetID + self.text = text + self.timeStamp = timeStamp + self.authorName = authorName + self.authorUsername = authorUsername + self.profileImageURL = profileImageURL + self.photosURL = photosURL + self.category = category + self.userVerified = userVerified + } +} From 0daaa0c6acc45db58cf18017b961b61d62614ff9 Mon Sep 17 00:00:00 2001 From: SuzGupta Date: Thu, 17 Nov 2022 17:21:12 -0700 Subject: [PATCH 5/5] debugging session w Mark Powell confirming widget can now read JSON from App Group --- BrainMarksWidgets/BrainMarksWidgets.swift | 8 +++++++- BrainMarksWidgetsExtension.entitlements | 10 ++++++++++ brain-marks.xcodeproj/project.pbxproj | 4 ++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 BrainMarksWidgetsExtension.entitlements diff --git a/BrainMarksWidgets/BrainMarksWidgets.swift b/BrainMarksWidgets/BrainMarksWidgets.swift index b654460..4e5ac55 100644 --- a/BrainMarksWidgets/BrainMarksWidgets.swift +++ b/BrainMarksWidgets/BrainMarksWidgets.swift @@ -7,6 +7,7 @@ import WidgetKit import SwiftUI +import Intents struct Provider: TimelineProvider { func placeholder(in context: Context) -> SimpleEntry { @@ -19,6 +20,7 @@ struct Provider: TimelineProvider { } func getTimeline(in context: Context, completion: @escaping (Timeline) -> Void) { + var entries: [SimpleEntry] = [] // Generate a timeline consisting of five entries an hour apart, starting from the current date. @@ -43,7 +45,7 @@ struct SimpleEntry: TimelineEntry { return } let decoder = JSONDecoder() - if let codeData = try? Data(contentsOf: URL) { + if let codeData = try? Data(contentsOf: URL.appendingPathComponent("categories.json")) { do { let contents = try decoder.decode([LocalCategory].self, from: codeData) print(contents) @@ -97,6 +99,10 @@ struct BrainMarksLockScreenEntryView : View { Image(systemName: "gamecontroller") .font(.largeTitle) } + .onAppear() { + let entry = SimpleEntry(date: Date()) + entry.readContainer() + } // will need to pass which category to open as a URL parameter .widgetURL(URL(string: "brainmarks://openCategory")) } diff --git a/BrainMarksWidgetsExtension.entitlements b/BrainMarksWidgetsExtension.entitlements new file mode 100644 index 0000000..1815d24 --- /dev/null +++ b/BrainMarksWidgetsExtension.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.com.suzgupta.brainmarks + + + diff --git a/brain-marks.xcodeproj/project.pbxproj b/brain-marks.xcodeproj/project.pbxproj index e941260..cf94e66 100644 --- a/brain-marks.xcodeproj/project.pbxproj +++ b/brain-marks.xcodeproj/project.pbxproj @@ -130,6 +130,7 @@ 14F5BDE61EAA4A2DB9030734 /* AmplifyModels.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = AmplifyModels.swift; path = amplify/generated/models/AmplifyModels.swift; sourceTree = ""; }; 1E886624D4EE4F64B9160A75 /* amplifytools.xcconfig */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = text.xcconfig; path = amplifytools.xcconfig; sourceTree = ""; }; 2A2B5DEF290F4BEF0066D29A /* Intents.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Intents.framework; path = System/Library/Frameworks/Intents.framework; sourceTree = SDKROOT; }; + 2A2DD2BB2926FCAD00FB71C9 /* BrainMarksWidgetsExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = BrainMarksWidgetsExtension.entitlements; sourceTree = ""; }; 2A41044A29156A4F00EFB98B /* LocalCategoryModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalCategoryModel.swift; sourceTree = SOURCE_ROOT; }; 2A41044D29156BB600EFB98B /* LocalTweetModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalTweetModel.swift; sourceTree = ""; }; 2A7C407E28EFCC3600F73DF5 /* BrainMarksWidgetsExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = BrainMarksWidgetsExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -469,6 +470,7 @@ FFEBBB2D26223F75000F475F = { isa = PBXGroup; children = ( + 2A2DD2BB2926FCAD00FB71C9 /* BrainMarksWidgetsExtension.entitlements */, 6940242370A54E53B82BF75C /* AmplifyModels */, 6D7FDBA2D37342B39C7F1C69 /* AmplifyConfig */, FFEBBB3826223F75000F475F /* brain-marks */, @@ -880,6 +882,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_ENTITLEMENTS = BrainMarksWidgetsExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = N76WE33BQK; @@ -909,6 +912,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_ENTITLEMENTS = BrainMarksWidgetsExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = N76WE33BQK;