Post

Replies

Boosts

Views

Activity

Toolbar and title disappear when interacting with view
Hello! I'm developing a Watch app, that's required to receive images from iPhone occasionally. Since the user will need their hands free, they have to inspect those images on Watch, which is why I added a rudimentary image viewer, allowing users to zoom in on images and pan around. As soon as the user pans or zooms, toolbar and title will disappear. This happens in simulator and on my colleague's Watch (A2376), but not on mine (A2356)! Tested both on watchOS 9.6.2 and 10.0.1. Here's a code excerpt: // View is presented on a sheet TabView(selection: $viewing) { ForEach(images) { reference in reference.img .resizable() .aspectRatio(contentMode: .fit) .scaleEffect(scale) .offset(offset + draggingOffset) .frame(width: screenSize.width, height: screenSize.height-1) .clipped() .id(reference.id) .gesture(panGesture, including: .gesture) .gesture(tapZoomGesture) .navigationTitle(viewerTitle) // .toolbar(content: { // ToolbarItem(placement: .cancellationAction) { // viewerToolbar // } // }) .focusable() .digitalCrownRotation(detent: $scale, from: 0.5, through: scaleMax, by: 0.1, sensitivity: .low, isContinuous: false, isHapticFeedbackEnabled: false, onIdle: { offset = stickyEdgeOffset }) } }
1
0
446
Oct ’23
Peculiar EXC_BAD_ACCESS, involving a Task
I had to update a simple piece of code, so it could be delayed by a few ms in some cases. This is how I tried to achieve that, by using a Task: class SomeClass { private var availableStuff : Set<Stuff> = [] func updateStuff(lookingFor prop: SomeProp, updatedThing: String, waiting: Duration = .zero) { Task { if waiting != .zero { try await Task.sleep(for: waiting) } if var stuff = availableStuff.first(where: { $0.prop == prop }) { stuff.thing = updatedThing // print(availableStuff) self.availableStuff.remove(stuff) self.availableStuff.insert(stuff) // BAD ACCESS here } } } } It did work before implementing the delay, but now it would crash at the insert statement (sometimes at remove). Naively, I put a print statement beforehand and to my surprise, this kept the crash from occurring at all! I switched on Address Sanitizer, now it doesn't crash, even w/o the print statement. Am I using the Task wrong, somehow? How can I further diagnose this, so it doesn't happen later in production? Or should I just leave the print in and hope for the best? Thanks!
1
0
914
Jul ’23
App Intents don't show on device, while they do in the simulator
Hello. I want to provide my users with some useful shortcuts and chose AppIntents to do so. I watched the relevant WWDC talks, read the documentation and I set up a few simple intents, adhering to AppIntent. I also created a AppShortcutsProvider to offer the most useful of my intents on installation. I did use \(.applicationName) within my phrases. Trying it out on the simulator, it works as intended (Ventura 13.3, Xcode 14.3, iOS 16.4). Wonderful! Now, building the same code for my hardware device (iPhone SE 3rd Gen, iOS 16.4) and trying it out on there, nothing shows up - neither the intents I want to add on install, nor the ones the user would have to select manually. I really have no idea why... On a side note: My app does have a Watch counterpart and I'd like to do the same there, but with intents specific to the Watch app. They don't even show up in the simulator, though. Any ideas what could've went wrong here? I'd appreciate it. Thanks!
3
0
2k
Apr ’23
WCSession not reachable despite active WKExtendedRuntimeSession
Hello. I'm developing an app that necessitates the Watch counterpart being available for Watch Connectivity live messages for periods of time, even when the screen is turned off. So what I did, is set up a WKExtendedRuntimeSession. I tried both "Self Care" and "Mindfulness" types, as those are supposed to keep the app running in foreground. WKExtendedRuntimeSessionDelegate.extendedRuntimeSessionDidStart confirms the session has started. According to documentation on WCSession.isReachable the Watch app should now be reachable, as long as the user doesn't close it: WatchKit extension. The iOS device is within range, so communication can occur and the WatchKit extension is running in the foreground, or is running with a high priority in the background (for example, during a workout session or when a complication is loading its initial timeline data). Still, as soon as I turn my wrist away, isReachable flips to false and messages aren't delivered. Any clues on this? Thanks!
1
0
1.4k
Jan ’23
OSLogStore on watchOS
Hello. I'm developing a tightly coupled watchOS/iOS app. The customer needs to be able to write logs to text files, from both apps, in a hassle-free way. So I want to retrieve entries using OSLogStore, which works just fine on iOS: let store = try OSLogStore(scope: .currentProcessIdentifier) let pos = store.position(timeIntervalSinceEnd: -seconds) let entries = try store .getEntries(with: [], at: pos, matching: nil) .compactMap { $0 as? OSLogEntryLog } .filter { $0.subsystem == Bundle.main.bundleIdentifier! } .map { "[\($0.date.formatted())] [\($0.category)] \($0.composedMessage)" } .joined(separator: "\n") I've tried the same code on watchOS, with and without the filtering, but it always returns 0 entries. I can't find anything relating to this behavior in the documentation. So... does it just not work? Using a Watch SE 44mm and running watchOS 8.5 Thanks!
2
0
895
Aug ’22
Settings-Watch.bundle not in sync
Hello. I want to be able to change settings for my Watch app on iPhone as well as from within the app. What I did: Create Settings-Watch.bundle, define groups and individual settings. Add App Groups capability for all 3 targets (iOS, WatchKit, WatchKit Extension) Add group group.com.my.appxyz to every target's App Group Add ApplicationGroupContainerIndentifier : "group.com.my.appxyz" on my Root.plist Now I can change settings for my Watch app on iPhone, great. Let's access those values from within the Watch app. Loading values: let settings = UserDefaults(suiteName: "group.com.my.appxyz") settings?.register(defaults: [ "something" : sameSensibleDefaultAsInRootPlist, ... ]) let something = settings?.string(forKey: "something") Saving values: settings?.set("newValue", forKey: "something") The changes I do on Watch are persisted and properly loaded between sessions, just as expected... Except they never reflect on the iPhone side of things and vice versa. I've reinstalled the app on the simulator and on real hardware - still doesn't work. Did I overlook something, perhaps? Thanks!
0
0
546
Aug ’22
Background mode for sustained networking
Hi. I've been developing an iOS-/watchOS-app that connects to an embedded device, using swift-nio-ssh. While the iOS app takes care of the connection and all related data-munching, it doesn't have much of an UI. The Watch app is there to control the device, exchanging WatchConnectivity messages with the iPhone - the user will need their hands free. As it stands, I have to keep the iPhone app active, because otherwise the connection will die within a few seconds. What the customer wants though, is to be able to do anything they please with their phone, while connected to the device: receive calls, answer messages, change settings, lock it, etc. Now that I've made myself familiar with APIs Apple offers for extended background runtime, none of them fit my use case. From what I've gathered, it could be possible to abuse Audio, VoIP or NetworkExtension background modes, but then the app wouldn't make it through review. Is there a way to get some kind of explicit approval for me doing the aforementioned (The app's supposed to be distributed in-house only through Apple Business Manager)? If so, what would be the best way to go about it? Any hints? Thanks for your time!
2
0
1.2k
Jul ’22