Post

Replies

Boosts

Views

Activity

So many spam posts recently
... all talking about customer care numbers. Maybe Apple should make these Dev Forums just for signed-in Developers? If a Developer spams, they can be blocked. But if just anyone can register and post, they can spam, get banned, then start a new account. Or, Apple should implement some way of blocking the spam before it gets posted. I really don't understand what these spammers think they're getting out of doing this? Who is going to look through the forums and think, "Oh, a customer care number for something I've never heard of? I should phone that immediately!" Really does prove that spammers are dumb.
1
2
977
Sep ’22
How to refresh a View?
In my Watch app, the WatchDelegate class is the WCSession delegate and handles transferring data with the iOS app. When the delegate receives some data it stores it in the UserDefaults. When the Watch app is launched it reads the existing data stored in the defaults and creates the view. I have a WatchApp file which contains this: @main struct WatchApp: App { var body: some Scene { WindowGroup { if(getItems().count == 0) { NoEventsView() } else { ItemsListView(available: getItems()) } } } } As you can see, if there are no events in the defaults it shows the NoEventsView; and if there are some it shows the EventsListView. When the Watch delegate receives a change in the events, I need to refresh this view. The delegate can receive zero or more events. How on Earth do I do that? In iOS I could call a method to reload a table of data, or post a notification to another view controller to do that, but in the Watch and with SwiftUI there doesn't seem to be any obvious way of refreshing a view. Is there any way of telling the App struct to refresh, or a particular view? For example, if I extracted the if statement into its own "struct WhichView: View", could I tell that to refresh? I've read a LOT on the net these past few days on @State vars, @ObservedObject, @Published etc, but nothing I've seen works, or is far too weird and complex for my situation. I literally just want WatchApp or WhichView to redraw when I tell it to. How do I do that? Thanks.
4
1
2.4k
Aug ’22
More spam on these forums...
... and yet, Apple's staff think it's appropriate to post lame responses thanking them for their interest in the forums. Come on, guys! It's obvious spam! Mark it as such and delete it. It's not beyond your abilities to stop people posting the word "WhatsApp" plus a phone number. You already stop us posting certain web links, so you can do this. If you continue ignoring the spam problem, then these forums will become less and less useful. Why should I contribute my free time to help others when you won't even help us?
2
3
168
Apr ’25
Can't pin down how to show complications properly at different stages
I understand that complications in WidgetKit and watchOS 9 are different to the old ClockKit way, and I'm trying to populate the getSnapshot, getPlaceholder and getTimeline functions appropriately for the new method. I'm using dynamic intents, and I've got that working and providing a set of items I want the user to choose from, but at the various stages of selecting and adding a complication to the watch face, nothing I do seems to work properly on a device, and sometimes in the Simulator. On the Simulator: 1: 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. Are you only supposed to show ONE particular bit of data, like some dummy preview data or something? I can do that, but the complication picker then just looks really boring, with just the text below being different. I note that Apple's weather complications show different data. How did they do that? 2: You can see that once I pick an event it's displayed correctly in the Watch face edit screen: The "72d" circular complication is the "New York" event, and the rectangular one is correctly using the data for the "London Party!". 3: Once I've selected the events I want to use in those complications the edit screen shows them as totally blank, not even a placeholder. Which method gives us that preview? 4: Once I confirm the edits and return to the Watch face, the complications appear correctly: Note: This is all from the Simulator (apart from the image of Apple's Weather complications). This stuff barely works on a device. Half the time the complications are all placeholders, and half the time they're using the wrong data! If it works in the Simulator, it should work on the phone, or there is no point in giving us the Simulator if the results are different. So basically: Q1. How do I use different data in the complications picker? Q2. How do you get the previews to show when you're in edit mode? Q3. Does anyone know how to get print() statements to work when I'm running the Complications scheme? I could answer all these questions myself if I could output some debug info to the console, but all I see is the output from the Watch App target...
11
2
3.9k
Mar ’23
How to support foregroundColor (deprecated) and foregroundStyle in watchOS 9/10?
In my Watch app on watchOS 9 I was using .foregroundColor(myColour) to colour the text in a widgetLabel on a corner complication like this: let myColour: Color = functionThatReturnsAColorObjectConstructedLike Color.init(...) // green .widgetLabel { Text(myText) .foregroundColor(myColour) } It worked fine; the widget label was green. Now, in watchOS 10, I see that foregroundColor() is being deprecated in favour of foregroundStyle(), and I can use .foregroundStyle(.green), and - importantly - foregroundStyle() is only available on watchOS 10 and newer. myColour is calculated depending on some other info, so I can't just write .green, and when I use .foregroundStyle(myColour) the widget label comes out as white every time, even if I set myColour = .green. I think I have to use some sort of extension to pick the right combination, something like: extension View { func foregroundType(colour: Colour, style: any ShapeStyle) -> some THING? { if #available(watchOS 10.0, *) { return foregroundStyle(style) } else { return foregroundColor(colour) } } } // Usage let myStyle: any ShapeStyle = SOMETHING? ... .widgetLabel { Text(myText) .foregroundType(colour: myColour, style: myStyle) It doesn't work. I just can't figure out what should be returned, nor how to return it. Any ideas?
3
2
3.5k
Feb ’25
[WC] WCSession counterpart app not installed BUT IT IS!
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.
10
3
4.9k
Feb ’24
Partial fix for widgets & complications not showing correctly
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)
1
1
2.6k
Apr ’24
Unable to install iOS & watchOS app to iPhone, because of intents change
I've been happily building and deploying my app to my iPhone and Watch S8, and the app was ready to submit to App Store Connect last night. However, when archiving it I got an error saying that my DynamicEventSelectionIntent was in multiple extensions. It was, kind of. When I started working on the complications I copied the Widgets intents into the complications, and left the name the same, but they were not in multiple targets. It looks like the info plist only had one item in the IntentsSupported (because they're the same name), so I decided to rename them so I had a widget one and a complications one. The problem I have now is that I can't deploy to my iPhone and Watch anymore because I'm getting this error: This app contains a WatchKit app with one or more Siri Intents app extensions that declare IntentsSupported that are not declared in any of the companion app's Siri Intents app extensions. WatchKit Siri Intents extensions' IntentsSupported values must be a subset of the companion app's Siri Intents extensions' IntentsSupported values. All I've done is rename one intent, and locate every instance of it in the info plist files, and add the appropriate new one into the right places. Here's what I've got. Main App contains Widget and WidgetIntentHandler, plus Watch App, which contains Complications and ComplicationsIntentHandler. Target: Main app: (I've removed everything that has no bearing on extensions.) Target: Widget: Target: WidgetIntentHandler: Target: Watch App: Target: Complications: Target: ComplicationsIntentHandler: Please, can someone tell me what should and should not be in the various parts, as I've tried for 12 hours now and I cannot get this to deploy to my iPhone anymore :( Thanks.
12
1
2.3k
May ’25
SwiftUI is pressing both buttons in a List
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.
2
1
3.9k
Feb ’24
Complying with the EU's Digital Services Act: Trader status
According to this Apple page, if you make any money from your apps in the EU you have to provide your email address, phone number and address, and they will be displayed on your App Store page for all and sundry to see, use, and likely, abuse. I don't want anyone and everyone to know those details; they are private. I thought Apple was all about privacy? I understand they have to adhere to the DSA, but Apple hasn't raised a single objection to this. Apple has consistently said that not sharing a user's email address with a developer is a part of being in the App Store, i.e. Spotify can't contact someone who downloaded their app; but a user can now contact the developer? I barely make any money from my apps - not even enough to cover the annual developer program fee - but I keep developing to stay current. I cannot afford a PO Box or business address and phone number to shield me from this, so I'm likely to remove my apps from the EU market. You might think I'm being overly-cautious, or having a knee-jerk reaction, but these are my personal, private details, and they should not be available publicly just because I barely clear £1.50 a month from my apps.
1
1
774
Aug ’24
Content blocker not removing content
I have a content blocker that generally works correctly, but I need to block an element that has certain text in it. For example, <span id="theId">Some text</span> is easy enough to block because I can locate the id and block that, but what if there is no id, or the id is completely random? What if it's just <span>Some text</span>? How do I block that? Let's say this is my only content blocker rule: [ { "action": { "type": "css-display-none", "selector": ":has-text(/Some text/i)" }, "trigger": { "url-filter": ".*" } } ] No errors are seen when the rule is loaded, so it's syntactically correct, it just doesn't block the HTML. I gather this is because :has-text() works on attributes, not contents, so it works on alt, href, aria-label etc. but not on the contents of the element itself. How do I block Some text in my example above? Thanks!
2
1
628
Feb ’25
In-app purchases fail: "Password reuse" error?
I'm trying to implement my first in-app purchase, and I've created the IAP in App Store Connect, and created a sandbox account. When I open Settings > Developer in the iPhone Simulator, there is a "Sandbox Apple Account" option at the bottom. If I click the blue "Sign In" link I'm asked for the email and password, so I enter the correct credentials for the sandbox account. The "Sign In" text goes grey for a few seconds, then it goes blue again. It never changes to show that I'm signed in. Should it? (I think so.) Do I need to sign into the Simulator's Apple Account, too? (I don't think so.) Anyway, aside from that, in my app the IAP is listed and I have a button to purchase it. When I click it I'm asked for the email and password to sign into the Apple Account. I enter the correct sandbox email and password (they are definitely correct) and I see this in the Xcode console: Purchase did not return a transaction: Error Domain=ASDErrorDomain Code=530 "(null)" UserInfo={client-environment-type=Sandbox, NSUnderlyingError=0x600000d0c7b0 {Error Domain=AMSErrorDomain Code=100 "Authentication Failed The authentication failed." UserInfo={NSMultipleUnderlyingErrorsKey=( "Error Domain=AMSErrorDomain Code=2 \"Password reuse not available for account The account state does not support password reuse.\" UserInfo={NSDebugDescription=Password reuse not available for account The account state does not support password reuse., AMSDescription=Password reuse not available for account, AMSFailureReason=The account state does not support password reuse.}", "Error Domain=AMSErrorDomain Code=0 \"Authentication Failed Encountered an unrecognized authentication failure.\" UserInfo={NSDebugDescription=Authentication Failed Encountered an unrecognized authentication failure., AMSDescription=Authentication Failed, AMSFailureReason=Encountered an unrecognized authentication failure.}" ), AMSDescription=Authentication Failed, NSDebugDescription=Authentication Failed The authentication failed., AMSFailureReason=The authentication failed.}}} Why is it talking about password reuse? AFAIK, I have only one sandbox account for this app (and none for any of my other apps), and this is the only one of my apps that has an IAP. Any ideas on how to get an IAP working? Thanks!
4
1
2.0k
Jan ’25
Sandbox environment extremely unreliable
I have two sandbox users in App Store Connect, as I'm trying to test in-app purchases and Family Sharing. They're set up fine; I can make purchases in the app. The issue is that the refund request sheet in my app sometimes shows properly and lets me request a refund, but I'd say >80% of the time the sheet just shows "Cannot Connect" with a "Retry" button. Hitting that button doesn't ever result in the sheet showing the refund page. The only fix for this is to delete the app from the device, and restart the device. This has to be a joke, right? I need to be able to test this IAP, and the sandbox environment is useless most of the time. Why? Anyone experiencing this sort of issue?
1
1
499
Jan ’25
macOS 26 Tahoe beta 1 - Cannot login
A few days ago I installed beta 1 of macOS 26 Tahoe on a spare MacBook Pro 14-inch M4. Everything went well, and it looks okay (well, I don't like it at all, but hey-ho), and I shut it down. I started it up today, and it rejects my login password every time, then locks my account. When I click the link to "Restart and show password reset options" I'm asked for my Apple ID details, so I enter the correct email and password, then the MBP reboots and I'm back on the login screen with no indication that anything has changed. Guess I'm stuck now... FB18364657
4
1
643
Sep ’25
List rows disappearing when scrolling
I have a List containing ItemRow views based on an ItemDetails object. The content is provided by a model which pulls it from Core Data. When I scroll through the list one or two of the rows will disappear and reappear when I scroll back up. I have a feeling it's because the state is being lost? Here's some relevant info (only necessary parts of the files are provided): -- ModelData.swift: @Observable class ModelData { var allItems: [ItemDetails] = coreData.getAllItems() ... } -- ItemDetails.swift: struct ItemDetails: Identifiable, Hashable, Equatable { public let id: UUID = UUID() public var itemId: String // Also unique, but used for a different reason ... } -- MainApp.swift: let modelData: ModelData = ModelData() // Created as a global class SceneDelegate: UIResponder, UIWindowSceneDelegate { // Methods in here (and in lots of other places) use `modelData`, which is why it's a global } @main struct MainApp: App { var body: some Scene { WindowGroup { MainView() } } ... } -- MainView.swift: struct MainView: View { var body: some View { List { ForEach(modelData.allItems, id: \.id) { item in ItemRow(item) } } } } struct ItemRow: View, Equatable { var item: ItemDetails var body: some View { ... } static func == (lhs: Self, rhs: Self) -> Bool { lhs.item == rhs.item } } There's obviously more code in the app than that, but it's not relevant to the issue. I've tried: ItemRow(item).equatable() Wrapping ItemRow in an EquatableView Giving the List a unique id Using class ModelData: ObservableObject and @StateObject for modelData None made any difference. I'm using iOS/iPadOS 26.0.1, and I see it on my physical iPhone 17 Pro Max and iPad Pro 11-inch M4, but I don't see it in the equivalent simulators on those versions. The Simulator also doesn't exhibit this for versions 17.5 and 18.5, and I have no physical devices on 17.5/18.5 to check. Should I be doing as I currently am, where I create modelData as a global let so I can access it everywhere, or should I pass it through the view hierarchy as an Environment variable, like @Environment(ModelData.self) var modelData: ModelData? Bear in mind that some functions are outside of the view hierarchy and cannot access modelData if I do this. Various things like controllers that need access to values in modelData cannot get to it. Any ideas? Thanks.
2
0
131
Oct ’25