Post not yet marked as solved
I'm working on an app that has the following structure:
MyApp
MyWidgetExtension
MyWatchKitApp
-- MyWatchKitAppExtension
---- MyWatchKitAppWidgetExtension
Both MyWidgetExtension and MyWatchKitAppWidgetExtension were developed using a shared MyWidgetBundle defined as follows:
@main
struct MyWidgetBundle : WidgetBundle
However, I'm running into an issue when attempting to run this on devices with iOS 14. I get an error stating "App extensions must define either NSExtensionMainStoryboard or NSExtensionPrincipalClass keys in the NSExtension dictionary in their Info.plist."
Interestingly, if I remove MyWatchKitAppWidgetExtension, the app installs just fine. But, if I add NSExtensionPrincipalClass or NSExtensionMainStoryboard, when I try to distribute the app to TestFlight, I receive an error stating "Unexpected key NSExtensionPrincipalClass found in extension Info.plist".
I'm at a loss as to how to resolve this issue. Does anyone have any suggestions or insights?
Post not yet marked as solved
Hey,
I am currently trying to add deeplink handling from tapping on push notifications in my watchOS application with a SwiftUI lifecycle.
I already have deeplinking working with several onOpenURL modifiers throughout the app for the iOS version. What I wanted to do, is whenever I receive a push notification I construct an URL and then utilise the onOpenURL view modifier to handle the deeplink.
I currently struggle to understand if this is possible at all.
I have the following setup
@main
struct WatchApp: App {
@WKApplicationDelegateAdaptor var appDelegate: WatchAppDelegate
// MARK: - Body
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
class WatchAppDelegate: NSObject, WKApplicationDelegate, ObservableObject {
func applicationDidFinishLaunching() {
UNUserNotificationCenter.current().delegate = self
}
}
extension WatchAppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
// handle the push notification
}
}
I do receive the the notification as expected in userNotificationCenter(center:, didReceive:) but from there on I didn't find a way bring this information into my app. On iOS I do leverage UIApplication.shared.open(url:) but this is obviously not available on watchOS.
What is the official guidance of handling watchOS deep links with SwiftUI lifecycle from tapping of push notifications ?
Currently the onOpenURL modifiers are placed on several views, so it would be nice if there is a way to trigger them from a central place.
Would be really appreciated if someone knows a way on how to do it :)
Post not yet marked as solved
I am creating a watch app that keeps track of the amount of time a user has been asleep for and then updates a game using an API in real time if they surpass another user's sleep time. They select who they want to surpass so the app knows the target time they want to sleep for. I know this probably sounds silly, it's not the final iteration of what I want to build but I know I will need this functionality.
So I need this watch app to be able to update the game if they surpass the opponent while the user is sleeping. I don't think this is possible without using extended runtime sessions so that it can run in the background and check to see how long the user has been asleep for after the watch locks.
As far as I know the extended runtime sessions only last for 30 minutes though. My current plan to deal with this is to reschedule the session using session.start(at: )
I am currently thinking about doing it like this:
User selects opponent and goes to bed
App gets the amount of time the user needs to sleep for to surpass opponent, "sleepTime"
App schedules an extended runtime session to activate sleepTime seconds in the future
sleepTime seconds in the future the session activates and the app checks to see how long the user has actually slept since they went to bed.
If the user has slept less than the sleepTime needed to surpass the opponent the app will reschedule the extended runtime session for sleepTime - amountSleptSoFar == "sleepRemaining" seconds, in the future.
sleepRemaining seconds in the future the session will activate and check to see how long the user has actually slept for again.
If the user has slept less than the time needed to surpass the opponent then the session is rescheduled like before
If the user has slept more than the time needed to surpass the opponent then the app uses an API to update the game.
It is important that the game is updated as soon as the user surpasses an opponent and I don't want to set up a database to store sleep information and then update the game using the database data as soon as the database is updated.
Does this seem like an okay approach? And more importantly is it possible to do? From what I've read and implemented so far it seems possible but please let me know if I'm missing something. The one thing I'm unsure about is if I can use session.start(at: ) when the app is not currently open. If I can't reschedule using that then how else could I do what I need to do?
Post not yet marked as solved
I am wondering if it is possible for a watch app to play a haptic alert when it receives a background notification.
I want to send the user a haptic alert if a value in a database reaches a certain threshold.
Post not yet marked as solved
Hi,
Is it possible to turn on airplane mode on watchOS using swift? or possible to know the state of airplane mode?
thank you
Post not yet marked as solved
I'm having a weird issue. I have a watch app which communicates with the phone using a WCSessionDelegate.
if the phone app is open everything works fine, but if the app is closed, when the watch sends a message, my app is woken from the background, after which onAppear() is called in my app which causes a swiftData query to run.
Calling any swiftdata function from a backgrounded app causes it to immediately crash with the following stack trace. Any ideas what im doing wrong? or a better way to trigger my code instead of onAppear, so it won't be called when my watch wakes my app from the background?
.onAppear {
reloadData()
}
private func reloadData() {
let fetch = FetchDescriptor<SavedServer>(
predicate: nil,
sortBy: [.init(\.displayOrder)]
)
guard let results = try? modelContext.fetch(fetch) else {
self.rows = []
return
}
self.rows = results
}
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Incident Identifier: 057999AF-7840-410E-B3EE-29082C5AED00
CrashReporter Key: 28AF2AA0-4626-9964-9664-36077DAF4E1A
Hardware Model: MacBookPro18,2
Process: MC Status [68915]
Path: /Users/USER/Library/Developer/CoreSimulator/Devices/C61698BA-C4CA-4DD9-B824-DBF57AC65090/data/Containers/Bundle/Application/A685371C-9174-4CF7-9E99-D573310CC3E5/MC Status.app/MC Status
Identifier: com.shemeshapps.MinecraftServerStatus
Version: 2.0 (1)
Code Type: ARM-64 (Native)
Role: Non UI
Parent Process: launchd_sim [55432]
Coalition: com.apple.CoreSimulator.SimDevice.C61698BA-C4CA-4DD9-B824-DBF57AC65090 [164301]
Responsible Process: SimulatorTrampoline [53834]
OS Version: macOS 13.4.1 (22F82)
Release Type: User
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x18046589c __exceptionPreprocess + 160
1 libobjc.A.dylib 0x18005c09c objc_exception_throw + 56
2 CoreData 0x184989b94 -[NSFetchRequest(_NSInternalMethods) _incrementInUseCounter] + 0
3 CoreData 0x1849aa99c -[NSManagedObjectContext executeRequest:error:] + 164
4 CoreData 0x1848fe250 NSManagedObjectContext.fetch<A>(_:) + 80
5 SwiftData 0x1a89b7ad8 ModelContext.fetch<A>(_:) + 124
6 SwiftData 0x1a89c48c0 dispatch thunk of ModelContext.fetch<A>(_:) + 20
7 MC Status 0x102530ef4 MainAppContentView.reloadData(forceRefresh:) + 752 (MainAppContentView.swift:112)
8 MC Status 0x102533540 closure #2 in MainAppContentView.body.getter + 44 (MainAppContentView.swift:78)
9 SwiftUI 0x108a0b7a0 0x107b8c000 + 15202208
10 SwiftUI 0x108a0b7bc 0x107b8c000 + 15202236
11 SwiftUI 0x108a0b7a0 0x107b8c000 + 15202208
12 SwiftUI 0x108fdce70 0x107b8c000 + 21302896
13 SwiftUI 0x108fd6ec0 0x107b8c000 + 21278400
14 SwiftUI 0x1081edb24 0x107b8c000 + 6691620
15 SwiftUI 0x10928d650 0x107b8c000 + 24122960
16 libdispatch.dylib 0x1801424f4 _dispatch_call_block_and_release + 24
17 libdispatch.dylib 0x180143d3c _dispatch_client_callout + 16
18 libdispatch.dylib 0x180152b24 _dispatch_main_queue_drain + 1272
19 libdispatch.dylib 0x18015261c _dispatch_main_queue_callback_4CF + 40
20 CoreFoundation 0x1803c61b4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
21 CoreFoundation 0x1803c08cc __CFRunLoopRun + 1936
22 CoreFoundation 0x1803bfd28 CFRunLoopRunSpecific + 572
23 GraphicsServices 0x189864bc0 GSEventRunModal + 160
24 UIKitCore 0x103b30208 -[UIApplication _run] + 868
25 UIKitCore 0x103b33e80 UIApplicationMain + 124
26 SwiftUI 0x108a10524 0x107b8c000 + 15222052
27 SwiftUI 0x108a103c4 0x107b8c000 + 15221700
28 SwiftUI 0x108722088 0x107b8c000 + 12148872
29 MC Status 0x102506d30 static MCStatusApp.$main() + 40
30 MC Status 0x102506de0 main + 12 (MCStatusApp.swift:12)
31 dyld_sim 0x1028fd558 start_sim + 20
32 dyld 0x1026b1f28 start + 2236
33 ??? 0x3c15800000000000 ???
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x102f1cfa8 __pthread_kill + 8
1 libsystem_pthread.dylib 0x10285712c pthread_kill + 256
2 libsystem_c.dylib 0x1801375ec abort + 104
3 libc++abi.dylib 0x180263c78 abort_message + 128
4 libc++abi.dylib 0x180255198 demangling_terminate_handler() + 300
5 libobjc.A.dylib 0x180037bf0 _objc_terminate() + 124
6 libc++abi.dylib 0x180263150 std::__terminate(void (*)()) + 12
7 libc++abi.dylib 0x180263100 std::terminate() + 52
8 libdispatch.dylib 0x180143d50 _dispatch_client_callout + 36
9 libdispatch.dylib 0x180152b24 _dispatch_main_queue_drain + 1272
10 libdispatch.dylib 0x18015261c _dispatch_main_queue_callback_4CF + 40
11 CoreFoundation 0x1803c61b4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
12 CoreFoundation 0x1803c08cc __CFRunLoopRun + 1936
13 CoreFoundation 0x1803bfd28 CFRunLoopRunSpecific + 572
14 GraphicsServices 0x189864bc0 GSEventRunModal + 160
15 UIKitCore 0x103b30208 -[UIApplication _run] + 868
16 UIKitCore 0x103b33e80 UIApplicationMain + 124
17 SwiftUI 0x108a10524 0x107b8c000 + 15222052
18 SwiftUI 0x108a103c4 0x107b8c000 + 15221700
19 SwiftUI 0x108722088 0x107b8c000 + 12148872
20 MC Status 0x102506d30 static MCStatusApp.$main() + 40
21 MC Status 0x102506de0 main + 12 (MCStatusApp.swift:12)
22 dyld_sim 0x1028fd558 start_sim + 20
23 dyld 0x1026b1f28 start + 2236
Post not yet marked as solved
Hello everyone,
I'm a complete beginner when it comes to programming and have been learning Swift for the past 2-3 months. I'm in the process of writing my very first project, an Apple Watch app for Tesla owners.
So far, I've managed to complete the UI aspect of the app and have recently begun diving into the coding part. However, I find myself a bit lost when it comes to connecting my app to the unofficial Tesla API.
On top of that, I'm also wondering if integrating Core Data is necessary for this kind of project?
If anyone could help me by providing a clear roadmap, it would greatly accelerate my research and learning process. Any tips, tutorials, or resources you could point me toward would be immensely helpful.
Thanks in advance for your assistance!
Best Regards
Sasan
Post not yet marked as solved
I have just released a new version of my watch app, which requires watchOS 8 and is therefore not usable by series 2 and older watches.
Is there any way that users with those watches can get the previous version of the app? The new version of the iOS app runs on their phones but the watchOS app will not run on their watches, so they need to use the old version of both.
Thanks in advance.
Post not yet marked as solved
For some reason I am not receiving HKQuantityTypeIdentifierDistanceSwimming samples when using the watchOS 10 beta (8). The same code works fine on watchOS 9 but not on watchOS 10.
I have tried specifically enabling them in the collection types for the live builder and /or starting a query for them, but neither approach is causing any samples to be returned to the app.
Is this a known issue? Has something changed for swimming in watchOS 10?
Thanks in advance.
Post not yet marked as solved
I am writing a watchOS app where I have some audio files that I want to play at various points. I am using AVAudioPlayer. It all works in the simulator and it also works if I have Air Pods connected to my watch via Bluetooth. However I get no sound if there isn't a paired set of earphones. In the case of no earphones I would like the sounds to play from the physical watch speaker. I can't seem to find any documentation on how to cause that to happen.
Any hints or tips are appreciated.
Hello,
Have an iOS App with (extensionless) Watch App. Watch App is not a stand alone app.
Watch App appears in the "Frameworks, Libraries & Embedded content" section of the iOS App Target.
Nevertheless, I have to manually launch a build of the Watch App before building the iOS app if I want the build to succeed.
Is there a way to automatize build in cascade (at least for release scheme and for "Archiving" ?
I have a stand-alone watchOS app that starts a WKExtendedRuntimeSession and a 1-second repeating timer when a button is pressed. No CPU-intensive stuff happens during this extended (background) time.
On watchOS 9, this worked perfectly until I stopped it again (or after the hour I get out of a Mindfulness Session Type has passed, and the extended runtime session expires). The screen could go dark, and the timer would keep running.
On watchOS 10, I get about 50 seconds when the screen goes dark, and then the timer just stops. No delegate methods are called (i.e. no "extendedRuntimeSession...willExpire()" or "...didInvalidateWith()" is called), though. Also, the scenePhase does not change at this point, it remains at inactive. The execution just stops. When I tap the watch to turn the screen back on, the timer resumes as if nothing happened.
Does anybody know what's going on here? Has something changed in WKExtendedRuntimeSessions in watchOS 10, or is it a bug?
I tried removing the timer and changing it to a recursive DispatchAsync.main.asyncAfter block, but it yielded the same result.
My watch app records workouts including health (with HKWorkoutSession) and location data.The watch app is on the App Store and runs without any problems since long time.
I updated my own Watch Ultra to watchOS10 and my app does not properly work anymore. Everything works with the exception that the app does not receive any CLLocationManager data on the physical device. On the simulator it works perfectly. I tried several devices in the simulator and they all work.
Also I de-coupled the watch from the phone, deleted the watch completely and re-installed it.
My app's target is watchOS9, I tried it with watchOS10 and the problems are the same
CLLocationManager has correct and valid permissions
CLLocationManager is setup like this:
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.allowsBackgroundLocationUpdates = true
locationManager.activityType = .fitness
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = kCLDistanceFilterNone
locationManager.startUpdatingLocation()
CLLocationManager's delegate is listening to:
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error)
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
The CLLocationManager is starting and correctly giving feedback on 'didFailWithError' and on 'didChangeAuthorization'. Nothing that tells me that something is wrong and points to a problem.
No data is sent to didUpdateLocations. The function is never ever called. Of course I'm outside with my watch and the GPS signal is strong and I wait long enough.
My app is adding the recorded workout to Apple Fitness app (my app uses HKWorkoutSession) and even though my own app does not receive any CLLocationManager data, the workout that it sent to Apple Fitness includes all the CLLocationManager data. It really seems like being a problem with my app only.
Does someone have an idea or knows of a same problem?
Thomas
Post not yet marked as solved
I use the widget as a complication. Inside the widget, I have a Label and Image. I use SF symbols for the image. It should be possible to set the image colour in the code. I tried .tint() and .foregroundStyle(). I think my colour should be visible when selecting Multicolor tint varian. How to set an accent colour for an SF symbol inside a widget? Is anyone else having issues with this? My image just renders white on a black background.
watchOS 10
Xcode 15 RC
I don't see upload option for the App Store connect, can only export .ipa.
Also having issues with Transporter, pasting error message here.
Could not create a temporary .itmsp package for the app "Redacted.ipa".
Unable to determine app platform for
'Undefined' software type.
Is anyone else facing the same issue? I am using Xcode 15.
Post not yet marked as solved
I'm student from Korea. I'm interested in apple things.
I have several questions about Apple Watch sensors such as ECG(Electrocardiogram), Heart rate, Oxygen Saturation, breath rate, atrial fibrillation(afib) and so on.
First of all, Can I use these sensors all day long? with no limit?
I'm planning to develop some healthcare application using Apple Watch with sensors.
I can't find examples of using sensors 24/7.
And Second, If I can use the sensors all day long, can I execute the app in background?
Finally, If I can execute the app in background, can I activate the sensors in background?
Thank you for your help.
I have tried searching developer guide, and searching the GitHub.
Post not yet marked as solved
I use setTitle() to display a custom text on the top left corner (aligned to the clock) of a controller. But after upgrading to watchOS 10, the title is displayed on the right, under the clock, pushing all the design down.
Is there a workaround to make the title behave as it did on older versions?
I have an app running on WatchOS. How many BLE peripherals can my app connect to at the same time?
If the number of peripheral objects is limited in some way, is the limit imposed on each instance of CBCentralManager? Or is the limit imposed on each app?
I have a use case that would require four BLE peripheral connections. Is tis possible?
I have another use case that would require 6 BLE peripheral connections. Is this possible?
Post not yet marked as solved
Hello,
I'd love to know if there's a way to prevent people from sharing my custom .watchface files.
I know it's easy to share them, what I want to know is if there's any way to prevent it (such as licensing my creations or any way I couldn't think of).
Thank you!
Are we able to create our own watch face to our application. We have ios app and watch app, need to create watch face with few app data's like heart rate, steps count, etc on the watch face.
But I fount some answers like it is not possible to create a watch face. Possible to create watch face for Apple Watch?
Are developers allowed to publish watch faces?
I have found a website Facer(https://www.facer.io/creator) where they are offering customizing options and generating .watchface from their website. What approach they are following?