Posts

Post not yet marked as solved
3 Replies
1.2k Views
I'm able to successfully send userdefaults from the phone to the watch using applicationContext and save those userdefaults to the app group I created. For the watch, I see all the userdefaults come in successfully and I'm able to use them in the WatchOS app. Once I created the complications for the watch app, I am using the same app group ID and I added that app group in the capabilities of the watch extension but when I try to use the same userdefault that I'm using for the watch, everything is nil. I'm not understanding what I'm doing wrong. How do I share userdefaults between the watch and complication? This is how I'm bringing in the userdefaults from the phone to the watch let defaults = UserDefaults(suiteName: K.appGroupID) if let value1 = applicationContext["lat"] as? Double { defaults?.setValue(value1, forKey: "lat") } if let value2 = applicationContext["lng"] as? Double { defaults?.setValue(value2, forKey: "lng") } ... I am able to use this exact function in the watch app, but in the complication, the userdefault is nil. let formatter = DateFormatter() formatter.timeStyle = .short formatter.timeZone = .current let defaultLoad = UserDefaults.init(suiteName: K.appGroupID) if defaultLoad!.bool(forKey: "timeFormat") == true { ... I tried to remove and re-add the app group but that didn't work either. I also created a separate app group for the watch and extension to use alone but still same issue.
Posted Last updated
.
Post not yet marked as solved
0 Replies
1.7k Views
After updating to the Xcode beta and build/running my app, I started to get an error on all my widgets "Please adopt containerBackground API" and I found a post that had a solution to accommodate iOS 14-16 import Foundation import SwiftUI extension View { @ViewBuilder func widgetBackground() -> some View { let gradient = LinearGradient(gradient: Gradient(colors: [Color("LightBlue"), Color("DarkBlue")]), startPoint: .topLeading, endPoint: .bottomTrailing) if #available(watchOS 10.0, iOSApplicationExtension 17.0, iOS 17.0, macOSApplicationExtension 14.0, *) { self.containerBackground(gradient, for: .widget) } else { self.background(gradient) } } } I add this to my ZStack for the widget and it does nothing. I still get the same error to adopt to containerBackground API. What am I doing wrong?
Posted Last updated
.
Post not yet marked as solved
3 Replies
493 Views
I have an app that supports English and Arabic. If a German user has Arabic in the languages for their iPhone, the app is switching to Arabic, since that language is one of their languages. How do I get it to only use the top most language (their most preferred language) they have set? So a German user that does not have English in their languages or maybe has it below Arabic, will still get English as their language
Posted Last updated
.
Post not yet marked as solved
1 Replies
413 Views
The details might be important for this issue. I have a Swift app, I added a new target, a WatchOS app which would obviously be using SwiftUI which wouldn't be using any storyboard I don't think but I get this error message. I'm not making any changes, I'm literally adding new target and trying to run the base default code that Xcode gives me. Here's my code (I included the error message I get when I run the watch app as well. @main //Thread 1: "Could not find a storyboard named 'Main' in bundle NSBundle </Users... struct Shia_WatchOS_Watch_AppApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } .padding() } } I also went into the Watch app target, selected the Info tab and found "Main storyboard file base name" was set to "Main". Even when I remove this it makes no difference, I still get that error.
Posted Last updated
.
Post not yet marked as solved
2 Replies
844 Views
When I set my iOS app’s language to Spanish for example, then when I reboot my phone, my home and Lock Screen widgets revert back to the phone’s language, which I have set to English. If I open the app it’s still set to Spanish so it’s correct within the app; only the home and Lock Screen widgets revert back to English. The only way to get it back to Spanish is by going to my app’s setting, and setting the preferred language to English then back to Spanish again.
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.8k Views
Below is my code. It has always worked fine. Now in iOS 15 it no longer plays the custom notification sound, it plays the default tri-tone sound when the notification fires. Everything else is working fine. let notificationContent = UNMutableNotificationContent() let customNotificationSound = defaults.string(forKey: "notificationSound") notificationContent.title = "Notification Title" notificationContent.subtitle = "Notification Subtitle" notificationContent.body = "Notification Body" notificationContent.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "\(customNotificationSound ?? "default").m4a")) notificationtriggerDate = Calendar.current.dateComponents([.day,.month,.year,.hour,.minute,.second,], from: notificationTriggerTime) let notificationtrigger = UNCalendarNotificationTrigger(dateMatching: notificationtriggerDate, repeats: false) let notificationrequest = UNNotificationRequest(identifier: UUID().uuidString, content: notificationContent, trigger: notificationtrigger) center.add(notificationrequest) { (error) in if error != nil { print(error as Any) } } }
Posted Last updated
.
Post not yet marked as solved
1 Replies
3k Views
So in the link below, I did what the best answer said and it worked except for one part. When I swipe back to a previous screen, the status bar will be all black, then when it completes the animation to go back, it finally takes on the color of the title bar. This never used to happen with iOS 14; the status bar would be the same color as the title bar... How do I get it back to the way it worked before? https://developer.apple.com/forums/thread/682420 let appearance = UINavigationBarAppearance() appearance.configureWithOpaqueBackground() appearance.backgroundColor = <your tint color> navigationBar.standardAppearance = appearance; navigationBar.scrollEdgeAppearance = navigationBar.standardAppearance
Posted Last updated
.