Posts

Post not yet marked as solved
1 Replies
1.9k Views
I recently raised this post explaining how I couldn't seem to get watchOS 9 complications to work, and I've figured out a partial fix. The original post details the issues with complications - and some are still valid - but this fix applies to both my complications and Home Screen / Lock Screen widgets. I was following the various WWDC 2020/2022 videos and the Emoji Rangers sample code, adding bits here and there, and assuming they were completely valid. Sadly, this bit of code in the widget's dynamic intents IntentTimelineProvider getTimeline really just banjaxed everything: // Create entries for one day, 15 minutes apart let currentDate = Date() for minuteOffset in stride(from: 0, to: 60 * 60 * 24, by: 15) { let entryDate = Calendar.current.date(byAdding: .minute, value: minuteOffset, to: currentDate)! entries.append(EventEntry(date: entryDate, event: event)) } If I remove that, and generate a different timeline with specific dates and times (for example: now, in 10 mins, in 2 hours, in a day, etc.) the complications appear correctly, as do Home Screen and Lock Screen widgets. The outstanding issues with complications are: The previews all use the same data, but getSnapshot() is supposed to return the data specific to that event from the configuration, i.e. if let theId = configuration.event?.identifier. "Christmas" is correct, but "Gallery Opening" is using Christmas's data. Once I've selected the event I want to use in a complication the edit screen shows it as totally blank, not even a placeholder: I hope this little fix works for you guys. And, if you know how to fix the above issues, let me know. (iOS 16.1 beta 1, Xcode 14.1 beta 1)
Posted
by darkpaw.
Last updated
.
Post not yet marked as solved
1 Replies
332 Views
iOS app with Home Screen and Lock Screen widgets written in Swift/SwiftUI. I've never been able to get widgets to work properly. It's more pronounced on Lock Screen widgets, so let's try that method first... The app stores data in Core Data as an Event. They're read into my model and stored as WidgetEventDetails structs: struct WidgetEventDetails: AppEntity, Identifiable, Hashable { public var eventId: String public var name: String public var date: Date public var id: String { eventId } This all works absolutely fine in the iOS app, and each one is unique based on the eventId. When I go to add a Lock Screen widget, I customise the Lock Screen, tap in the section to add a widget, and my widgets appear correctly and are selectable: (bottom right, says "1y 28w 1d") So, I tap it and it appears in the widgets section: But it appears as "17w 6d", which is a different event entirely. Notice how the one in the selectable widgets has changed to "15w 5d", and the one I tapped (1y 28w 1d) is nowhere to be seen. So, I tap the one in the top row (17w 6d) to select an event, and this appears, suggesting that the event is the "Edinburgh & Glasgow 2024-02" event: But that event is actually only a day away (1d), so that's not the one I selected at all. I tap the list and see these events: I select "Las Vegas 2024", which is 17w 3d away, and this is shown: 17w 6d is a different event, not Las Vegas 2024. So, I tap it again and see this. The "Loading" text appears for ages, but occasionally does show the full list, as before: I select "Edinburgh & Glasgow 2024-02" which is 1d away, and I see this again: So, I resign myself to hoping it'll just figure itself out, and I tap "Done": "17w 6d" again :( I finish customising, and exit the customisation screen. I show the Lock Screen, and I see this: Why doesn't this work? Here's the code: @main struct WidgetExtensionBundle: WidgetBundle { @WidgetBundleBuilder var body: some Widget { WidgetExtension() } } struct WidgetExtension: Widget { var body: some WidgetConfiguration { AppIntentConfiguration(kind: kWidgetKind, intent: WidgetEventIntent.self, provider: WidgetEventTimelineProvider()) { entry in WidgetEntry(entry: entry) .environment(modelData) } .configurationDisplayName(NSLocalizedString("AddingWidget_Title", comment: "Adding the Widget")) .description(NSLocalizedString("AddingWidget_Description", comment: "Adding the Widget")) .supportedFamilies([.accessoryCircular, .accessoryInline, .accessoryRectangular, .systemSmall, .systemMedium]) .contentMarginsDisabled() } } struct WidgetEventIntent: WidgetConfigurationIntent { static let title: LocalizedStringResource = "AddingWidget_Title" static let description = IntentDescription(LocalizedStringResource("AddingWidget_Description")) @Parameter(title: LocalizedStringResource("Event")) var event: WidgetEventDetails? init(event: WidgetEventDetails? = nil) { self.event = event } init() {} static var parameterSummary: some ParameterSummary { Summary { \.$event } } } struct EventQuery: EntityQuery, Sendable { func entities(for identifiers: [WidgetEventDetails.ID]) async throws -> [WidgetEventDetails] { modelData.availableEvents.filter { identifiers.contains($0.id) } // availableEvents is just [WidgetEventDetails] } func suggestedEntities() async throws -> [WidgetEventDetails] { return modelData.availableEvents.filter { $0.type == kEventTypeStandard } } } If you think it's the TimelineProvider causing it, I can provide that code, too.
Posted
by darkpaw.
Last updated
.
Post marked as solved
2 Replies
196 Views
Hi all. I've spent six hours today trying to resize images from the Photos Library on the iPhone Simulator, but no matter what I try - and I've tried everything on StackOverflow - I always get a white line at the bottom of the image, even when trying the suggestions that specifically say "this one even gets rid of the white line!" This is just one of the many attempts: let image: UIImage = <whatever> let size = CGSize(width: 800, height: 600) guard let data = resizeImage(image: image, size: size, scale: 1).jpegData(compressionQuality: 0.75) ?? image.pngData() else { return false } func resizeImage(image: UIImage, size: CGSize, scale: CGFloat) -> UIImage { let availableRect = AVFoundation.AVMakeRect(aspectRatio: image.size, insideRect: .init(origin: .zero, size: maxSize)) let targetSize = availableRect.size let format = UIGraphicsImageRendererFormat() format.scale = scale let renderer = UIGraphicsImageRenderer(size: targetSize, format: format) let resized = renderer.image { (context) in image.draw(in: CGRect(origin: .zero, size: targetSize)) } return resized } I've read that image.draw(in:) adds that white line because it's using non-integer values and the background of a JPEG is white, so I floor()d and round()ed the size values, but I always get the white line. I just can't seem to get it to work. Does anyone have a working function that will resize one of the JPEG images included in the Simulator without putting that white line down there? Note: The pink/purple flowers image always resizes and comes back upside down, and the only difference I can see in the six images included in the Simulator is that that one is HEIF while all the others are JPEG. I'll also need any function to handle HEIF/HEIC, too, I guess... This is on Xcode 15.0.1 (15A507) with Simulator iOS 17.0.1. I've also tried it on a real device (iPhone 15 Pro Max, iOS 17.4) and the same thing happens, so it's not like the Simulator images are banjaxed in some way.
Posted
by darkpaw.
Last updated
.
Post marked as solved
1 Replies
345 Views
Hey all. I've been rewriting my Objective-C app in SwiftUI (it's going well, thanks!) and I'm hitting this issue that I thought I'd solved ages ago. I have version 5.1 of my original ObjC app using version 11 of the Core Data model. I've created a new version 12, added a couple of new attributes, and created a mapping model from 11 to 12. The fields I've added are booleans, and I've set them to have a default value of NO so that new entries will automatically get NO, but there are existing records that don't have that field at all, and I'd like them to also get NO (or YES, depending on something in the other fields, but I haven't figured out how to do that yet). This is how Core Data is set up in the new Swift target: public extension URL { // Returns a URL for the given app group and database pointing to the sqlite database static func storeURL(for appGroup: String, databaseName: String) -> URL { guard let fileContainer = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroup)?.appending(path: kCoreDataFolder) else { logger.error("Shared file container could not be created.") fatalError("CoreData: Shared file container could not be created.") } return fileContainer.appendingPathComponent("\(kCoreDataModel)") } } // MARK: - Persistence Controller struct CoreData { static let shared = CoreData() let container: NSPersistentContainer init() { let storeURL = URL.storeURL(for: kAppGroup, databaseName: kCoreDataModel) let storeDescription = NSPersistentStoreDescription(url: storeURL) container = NSPersistentContainer(name: kCoreDataModel) container.persistentStoreDescriptions = [storeDescription] container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { logger.error("Failed to initialise Managed Object Model from url: \(storeURL), with error: \(error), \(error.userInfo)") fatalError("CoreData: Failed to initialise Managed Object Model from url: \(storeURL), with error: \(error), \(error.userInfo)") } }) container.viewContext.automaticallyMergesChangesFromParent = true } When I run the old app on the Simulator it adds some demo data (using model v11), and the app functions properly. If I then install the new version - using v12 - it fails with a Core Data error because it couldn't migrate the data. (Apologies, I cannot get the exact error at the moment as I'm part-way through redoing some other stuff and the app won't build.) I've read somewhere that "When we use the NSPersistentContainer class to create and manage the Core Data stack, we don't need to do any additional setup work, the lightweight migration is automatically activated for us." But if that's the case, why does my app crash? I'll try and get the exact error for you... How do I implement lightweight migration in Swift? This page suggests creating a persistent coordinator and adding a couple of options, but I can't quite figure out how to do that with the code I already have, and each time I try it seems to beat the original store so I keep going back to the above code because it works.
Posted
by darkpaw.
Last updated
.
Post marked as solved
2 Replies
582 Views
I have a List which acts like a form where you can enter values. It uses a custom View struct SectionArea to separate the various sections and cut down on code duplication, like this: List { SectionArea(title: "Section One", height: 176, horizontalPadding: 0, roundCorners: (0, 0, 0, 0)) { VStack { Button { print("Pressed Button One") fullScreenViewChoice = .optionOne showSubView.toggle() } label: { HStack { Text("Button One") Spacer() Image(systemName: "chevron.right") } } .frame(height: 40) Divider() Button { print("Pressed Button Two") fullScreenViewChoice = .optionTwo showSubView.toggle() } label: { HStack { Text("Button Two") Spacer() Image(systemName: "chevron.right") } } .frame(height: 40) Divider() } } } .listStyle(.plain) .listRowSpacing(0) It works fine, but regardless of which button I press it always acts as though both buttons have been pressed. Say I press Button One, the console will display: Pressed Button One Pressed Button Two Can someone tell me where I'm going wrong here, please? Thanks! EDIT: Actually, it doesn't look like it's because of the SectionArea struct, because I've taken the code from there and wrapped it around the content directly, rather than using that struct, and it still does it. I've removed everything and just put this: List { VStack { ButtonOne ButtonTwo } } It still presses both buttons.
Posted
by darkpaw.
Last updated
.
Post marked as solved
9 Replies
3.2k Views
Right, this is getting on my nerves now. iOS app installed on iPhone via Xcode. Watch app installed on Watch via Xcode. Both apps are running and are in the foreground. iOS app launches on iPhone and reports: WCSession.isSupported = YES theDelegate.session.isPaired = YES theDelegate.session.watchAppInstalled = NO theDelegate.session.activationState = Activated I press a button in the Watch app. It reports: session == activated and reachable iOS app delegate receives a message from the Watch app: didReceiveMessage (from Watch): message = {     action = giveMeUpdatedItems; } The apps must be installed on the devices in order for the Watch app to have used sendMessage (which is only available if the session is reachable, which it is). iOS app delegate passes that through as a notification to another bit of code that collates the info and sends it back to the Watch app. watchNotificationUpdateData; userInfo = {     action = giveMeUpdatedItems; } That bit of code in the iOS app checks whether we can send data to the Watch app, and doesn't send the data because: WCSession.isSupported = YES theDelegate.session.isPaired = YES theDelegate.session.watchAppInstalled = NO theDelegate.session.activationState = Activated If I remove the check for watchAppInstalled, I get this: Error sending Watch application context: Watch app is not installed. {     NSLocalizedDescription = "Watch app is not installed.";     NSLocalizedRecoverySuggestion = "Install the Watch app."; } I've deleted and reinstalled the app on both devices countless times. I've rebooted the devices, plus the Mac. I've reinstalled Xcode. I've cleaned builds. I've deleted DerivedData. And still it says the companion app isn't installed.
Posted
by darkpaw.
Last updated
.
Post not yet marked as solved
0 Replies
252 Views
I have an iOS app that's written in Objective-C, uses Core Data, and has a number of SwiftUI targets (Widgets, Watch app). I'd like to convert the main app to SwiftUI and keep access to the data in the Core Data stack, but move to SwiftData immediately. Since I'm doing a lot of rewriting, it makes sense to leap ahead rather than have to rewrite it in a year or two. Effort isn't an issue; I'm a tenacious SOB ;) But I have no idea how to do this, and can't find any examples on the net of this particular scenario. All I can find is how to start using SwiftData instead of Core Data in an app that's already written in Swift. So, how do I go about the migration without losing data? I guess I'll need to add a new Swift/SwiftUI target for the main app, but then how do I migrate the Core Data store over? In ObjC there's a lot of messing with stacks and the actual location of the model in the filesystem, but I doubt this is necessary in the new way of doing things? Any help would be appreciated. Thanks!
Posted
by darkpaw.
Last updated
.
Post not yet marked as solved
0 Replies
375 Views
I have a countdown/up timer in a widget, and I want to format the timer to something more readable than the default that Text.init(myDate, style: .timer) provides. The default outputs a timer for just the hours in the date range. So, for example, a timer of 1 week, 5 hours, 12 minutes and 45 seconds will appear as 173:12:45 (which is 7 * 24 + 5 = 173) - not very user-friendly. An ideal output would be 1 week 05:12:45. Is there any way of doing that? I've tried a number of different ways using TimeInterval, DateInterval, and modding (%) values - like modding the hours count by 168 to get a number of weeks - but they're pretty much useless when there are never a set number of days or weeks in a year due to leap years. It would be great if you would provide actual code examples rather than saying to use a certain API, as I could very easily go down a rabbit hole like I have with TimeInterval and DateInterval. Thanks!
Posted
by darkpaw.
Last updated
.
Post not yet marked as solved
2 Replies
455 Views
I have a Home Screen widget that contains a timer counting down to a specific date. In this image you can see the date calculations: eventDate: 25th Dec 2023 at 09:00:00 entryDate(Date.now): This is just showing you the date in the first SimpleEntry for the widget. getTimeRemaining(entryDate): This shows the number of seconds from the entryDate to the eventDate, figures out how many days there are ("43 days"), and how many hours:mins:secs to the event time, so "10:48:52". Then there's a second entry, entryDate2, that's one hour later, and the values are appropriately calculated. When I create the timeline entries, I add them for: Now (1 entry) Now plus one hour to a week away (one entry per hour = 167 entries) Event date (1 entry) Event date plus one hour to a week later (one entry per hour = 167 entries) Each SimpleEntry entry contains a dictionary with the relevant timer details, and that's what the widget uses to determine what to display in the timer. SwiftUI lacks any useful formatting for a timer. Even the developer docs state: "Example output: 36:59:01". Who wants to see a timer with 36 hours on it? I want it to say "1 day 12:59:01", so I munge the numbers about and grab the separate parts, converting 36:59:01 into "1 day" and "12:59:01". You can see that in the image above. When the entry date of the timeline is reached and the widget is redrawn, it uses the entry containing the dictionary saying it should display "43 days" and the countdown timer should be 10:48:52, then an hour later the dictionary says it's 43 days 9:48:52, etc. The issue is that the widgets, even though they're supposed to have entries at each hour, will always end up displaying something like "29:17:09". The timeline has an entry at every hour, so it should be using the right values. I've checked, and the right values are in the dictionary, so why does the timer keep getting out of sync? I could cut out a massive amount of my widget code if only Text.init(date, style: .timer) would allow some proper formatting.
Posted
by darkpaw.
Last updated
.
Post not yet marked as solved
4 Replies
2.6k Views
Sorry for the length of this post, and all the questions. I have an iOS app written in Objective-C (too big to convert to Swift right now), and I successfully added a WatchKit app and WatchKit Extension some years ago. I also added Home Screen widgets when iOS 14 was released. With the iOS 16 betas I'd like to support Lock Screen widgets, and have also decided to move the WatchKit app/extension to SwiftUI. User journey: MyApp is launched and an item with an image is created. This item is stored in Core Data and its image is stored in a directory in the app's documents directory. A version of it is stored in NSUserDefaults in a shared app group. The user adds a Home Screen widget to show that item. Its data is pulled from the defaults, and the image is loaded from the document's directory. The user installs the Watch app and launches it. The Watch app looks inside the user defaults to retrieve the item. The iOS app sends the image to the Watch and the Watch app stores it locally (it's a small image, taking up barely a few Kb). This all works fine right now. Currently I have these targets: MyApp = main iOS app. MyApp WatchKit = Watch app storyboards and asset catalogs. MyApp WatchKit Extension = code to update the Watch interface. MyApp Widget = Home Screen widgets. MyApp IntentHandler = dynamic intents handler for the Home Screen widgets. Q1. Where do I put the code for the Lock Screen widgets? I figure these go into the My App Widget target because they're widgets and appear on the iPhone? In this video (https://developer.apple.com/videos/play/wwdc2022/10050) at 07:00 it tells you to duplicate the existing Widget target, change the bundle, change it to run on watchOS and embed it in your existing Watch App. As my original Watch App is written in Objective-C (MyApp WatchKit Extension, above) I can't/shouldn't do that, so... Q2. I think I have to create a new MyApp Watch App target, and perform the video steps on that target? I can create the views for that app, no problem. Most people update to the latest watchOS, and it's only now that watchOS 9 won't support Watch Series 3. Q3. Do I need to keep MyApp WatchKit and MyApp WatchKit Extension around? I can support older versions of watchOS if it helps my users, but they'll probably want to use the new version of watchOS, right? Can you install both versions of the app on your Watch (with watchOS 9), or does the new Swift app override the old WatchKit extension? Q4. Once I've designed the new Watch App's views in SwiftUI to replace the old WatchKit extension, where do I put the code for the complications that are being replaced? The WWDC 2022 videos (above, and a couple linked to on that page) have confused me a bit. Do I put complications views in the new MyApp Watch App target along with the other views that replace the old Watch app, or in MyApp Widget? Q5. The MyApp Widget target contains a bunch of code (WidgetUtils.swift) that populates the Home Screen widgets (and the new Lock Screen widgets), and it would fit right into the new MyApp Watch App target. Can I share that code between the two app targets just by adding WidgetUtils.swift to both target's membership? MyApp sends small images to the current MyApp WatchKit Extension. There's no code in the existing WidgetUtils.swift to handle file transfers because the images for the Home Screen widgets are pulled from the iOS app, so I need to write that in Swift for the new MyApp Watch App. The logic is already there in the old target, but I can't see any sort of equivalent to the WatchKit extension delegate where I currently handle the file transfers. Q6. Where does that go in MyApp Watch App? The existing MyApp WatchKit Extension occasionally asks MyApp for some new data. This is all done in the extension delegate which wakes up the iOS app and updates the NSUserDefaults which the extension then reads from. Q7. How do you do that in MyApp Watch App? Don't be afraid to be verbose in your responses. The more detail the better! Thank you in advance.
Posted
by darkpaw.
Last updated
.
Post marked as solved
2 Replies
376 Views
I want to add a large widget to my app, but it doesn't make sense to simply expand the information that's displayed in a small or medium widget to fill up the space of a large widget. Let's say I have a bunch of events in my app, and the user can add a small/medium widget to their Home Screen and choose which one of their events the widget shows. This is fine and works well, but for a large widget I want to have a totally different experience. I want to display the next four upcoming events in a list. These events are set by the order they're going to occur (date-wise) so you can't really pick which four you want to display, so I don't want to be able to edit the widget. However, if I add such a widget you can still hold down and edit the widget to select an event. Also - and I'm not sure why it does this - when you hold down and edit the widget, it displays the title and description that are assigned to my small/medium AppIntentConfiguration widget, and not the title and description that are provided to the large StaticConfiguration widget, i.e.: struct WidgetExtension: Widget // Small/medium dynamic widget { var body: some WidgetConfiguration { AppIntentConfiguration( kind: kWidgetKind, intent: WidgetEventIntent.self, provider: WidgetEventTimelineProvider() ) { entry in WidgetEntry(entry: entry) } .configurationDisplayName(smallMediumTitle). // This and the line below... .description(NSLocalizedString(smallMediumDescription) // are seen when editing the large widget .supportedFamilies([.systemSmall, .systemMedium]) } } struct WidgetExtension_Large: Widget // Large static widget { var body: some WidgetConfiguration { StaticConfiguration( kind: kWidgetKind, provider: WidgetEventTimelineProvider_Large() ) { entry in WidgetEntry_Large(entry: entry) } .configurationDisplayName(largeTitle) .description(largeDescription) .supportedFamilies([.systemLarge]) } } If it's not possible to have a non-editable widget, it might be more fun to let the user select four events themselves, so I'd need to change the large widget to an AppIntentConfiguration widget, but what would the four parameters look like? Currently, I have this for the small/medium widget that lets you select one event: @Parameter(title: "Event") var event: WidgetEventDetails? init(event: WidgetEventDetails? = nil) { self.event = event } init() { } static var parameterSummary: some ParameterSummary { Summary { \.$event } } How would I change it to select four events? It might be helpful to only be able to select a second event if a first one has been chosen, and a third if a first & second have been chosen etc. Any ideas? Thanks.
Posted
by darkpaw.
Last updated
.
Post not yet marked as solved
2 Replies
493 Views
Just finalising some work on my app update, and it seems that when you go to select an item to show in a complication, when you select your app in the list, the subsequent list only shows 15 of your items. If a user of my app has transferred 20 items to their Watch, they can't select five of them to be shown in a complication. Is that right? If that's a hard limit then I need to be able to separate them out into bunches of 15 items, or maybe have them display under A-E, F-J etc. Does this have to be done as a separate Widget in the WidgetBundle? And how do I do that? Given that I currently have one widget in that bundle that should show everything (20 items), how would I split it out to show an "A-E" widget with those items beginning with A...E? Do I have to have an A-E widget with its own set of data?
Posted
by darkpaw.
Last updated
.
Post marked as solved
2 Replies
505 Views
Here's my WidgetConfigurationIntent: WidgetEventDetails is a struct conforming to AppEntity, Identifiable, Hashable. It contains all the data needed to show in a widget. Here's my placeholder, snapshot, timeline etc.: When I go to add a widget to my iPhone Home Screen I choose my app, and the small and medium widgets are displayed, and they use the data from the placeholder function correctly, i.e. a random set of data (an 'event') is returned and seen in the widget picker. I select a widget and it appears on the Home Screen, but it's now just a placeholder view, and it stays like that forever. If I hold down and edit the widget, there's no selected event, as in, I might've picked "Christmas" from the widget picker but when it gets added to the Home Screen that link is lost. So, I edit the widget and go to choose any event, and this appears for ages: When it finally displays the list of events I pick one and the widget looks this forever: I can't see what I'm doing wrong. Any ideas? If you need any more of the code, please just ask. I'm getting really frustrated with this stuff and just want it to work. I get so far with it, it all goes well, then something happens and it just breaks. And it's not my coding as I'm using git and can can go back to previous commits where stuff was working, only to find it doesn't. I'm glad iOS 17 now has this "State of Mind" logging 'cos it shows exactly how I feel developing for iOS! 🥸
Posted
by darkpaw.
Last updated
.
Post marked as solved
2 Replies
673 Views
Current project structure: Main iOS app (targets iOS 17). Widget Extension (targets iOS 17). Watch app (targets watchOS 10). Complications Extension (a Widget Extension, targets watchOS 10). I did have the complications embedded within the Watch app, but you cannot have two @mains in the same target so the complications are in their own WidgetKit extension. Sadly, when you add a WidgetKit extension to your project, Xcode ALWAYS sets it as an iOS widget extension; it doesn't give you the choice to make it a watchOS extension so you have to figure it out yourself. Now, I'm hitting an issue where the main iOS app works fine, the iOS widgets work fine, the Watch app runs fine, but the complications dot show up anywhere. I can't preview them in Xcode because it says various things like: This app was not built to support this device family; app is compatible with ( 1,2 ) but this device supports ( 4 } I can't find any information on what goes where in the build settings. Can someone tell me how each bit of the project should look in the build settings, please? (There's no information anywhere in Apple's developer documentation - which is a bit weird. They've released Xcode and they have no information on the various bits. And why doesn't Xcode set up a WidgetKit extension properly when you add it? Must we all do this manually, Apple?)
Posted
by darkpaw.
Last updated
.
Post marked as solved
1 Replies
649 Views
I've had to rewrite my app to get widgets working properly, and I've got this project structure: Main iOS app: Bundle identifier = com.me.myapp Contains: Widget Extension: Bundle identifier = com.me.myapp.widgets Targets iOS 17 Provides widgets to iOS Watch app: Bundle identifier = com.me.myapp.watchapp Contains: Complications Extension (a Widget Extension): Bundle identifier = com.me.myapp.watchapp.complications Targets watchOS 10 Provides widgets to watchOS On the Signing & Capabilities tab in Xcode 15, all four targets have: Provisioning Profile: Xcode Managed Profile Signing Certificate: Apple Development: My team App Groups: all use the same one: group.com.me.myapp I can build and deploy to a physical iPhone and Apple Watch, but the Watch app doesn't seem to be able to access the shared Core Data, which should be in the shared app group container. When running the main iOS app, the store location is: file:///private/var/mobile/Containers/Shared/AppGroup/189E5907-E6E4-4790-833F-06944E4FF5FF/data-model/TheDataModel When running the widget extension, the store location is: file:///private/var/mobile/Containers/Shared/AppGroup/189E5907-E6E4-4790-833F-06944E4FF5FF/data-model/TheDataModel When I run the Watch app, the store location is different: file:///private/var/mobile/Containers/Shared/AppGroup/55381E6D-410E-4322-93BA-64BD1933909E/data-model/TheDataModel How do I get the Watch app to see the Core Data store from the main app? Do I have to replicate the store to that location every time something changes in the main app? Or do I have to go back to sending massive data sets as dictionaries/data via WatchConnectivity?
Posted
by darkpaw.
Last updated
.