Post

Replies

Boosts

Views

Activity

Reply to Common blocks in Swift?
#define COM_OFFSET 12.5 is simply let COM_OFFSET = 12.5. It looks like you want a file of commonly-used values/constants. That's easy. Just create a new Swift file and put your declarations inside, e.g.: let COM_OFFSET = 12.5 // You don't have to give arrays an initial size, but don't make them a `let` because you can't then add anything to it // So, either create an empty array globally like this, and add entries somewhere else, like: var dates: [PCDate] = [] addToDates() func addToDates() { dates.append(Date.now) dates.append(Date.now.advanced(by: 60) } // Or you can create a function that populates it when you create it, e.g. var dates = initialiseDates() func initialiseDates() -> [Date] { var array: [Date] = [] for index in 1...3 { array.append(Date.now) } return array } For the class stuff, just read up on how to create classes in Swift, but it's very easy - and you should put classes in their own file, so: import Foundation class MyLogger { static let fileURL: URL = { FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "my.app.group")!.appendingPathComponent("main.log") }() ... Then you just create an instance of it like any other class, just like you did with var dates: [Date] = [] above, i.e. var logger: MyLogger.
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’24
Reply to Shortcut automation
What do you think we can do with this? You haven't bothered to say what you were doing, what automation you're trying to use or create. These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. Are you in the right place?
Dec ’24
Reply to Ford SYNC3 is not connecting with IOS 18.2
You're in the wrong place. These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. Your question is more of a product support one, so I'd suggest you ask it over at the Apple Support Forums. You could even go ahead and ask Ford if they're planning an update... Thanks.
Dec ’24
Reply to Refreshing widgets - policy and background tasks?
I've extensivley tested this over the past two days. I tried timelines spanning one day, with: 72 entries, every 20 minutes 36 entries, every 40 minutes 24 entries, every hour 12 entries, every 2 hours 6 entries, every 4 hours 3 entries, every 8 hours 2 entries, every 12 hours In every case, the policy is .atEnd, and in every case the timeline is not refreshed when it's supposed to be, which causes the widget to display the wrong timer values. Due to the inflexibility of Text(date, style: .timer), I need to write code that calculates the correct timer value but shows less than a day. For example, if it's 11am today and the event date is tomorrow at noon, there are 25 hours between the two dates and the standard .timer would show 25:00:00, which is not what I want. So, I calculate the next occurrence of noon, and the widget shows "1 day" with a timer of "1:00:00". Every timeline with a refresh policy of .atEnd caues the countdown timer to show the wrong values. I've got it logging to a file, and I can see that the countdown dates are completely correct in every case. The widget is never refreshed at the right time, so the timers always show the wrong values. The only way I've managed to get this to work is to have a timeline with one entry, and a refresh policy of .after(), i.e. let date = Date() let refreshDate = Calendar.autoupdatingCurrent.date(byAdding: .minute, value: 30, to: date)! Timeline(entries: entries, policy: .after(refreshDate)) There is clearly something wrong with .atEnd.
Topic: App & System Services SubTopic: General Tags:
Dec ’24
Reply to Mac M1 Unable to restore in DFU error
Okay, firstly, you have a MacBook Pro 2021 with an M1 chip, not a "Mac M1 Pro 2021". Do you have to use Apple Configurator? Can't you restore it in any other way? What have you tried? Oh, also, you're in the wrong place. These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. Your question is more of a product support one, so I'd suggest you ask it over at the Apple Support Forums. Thanks.
Dec ’24
Reply to I Need Help!
You're in the wrong place here. These are the Developer Forums, where developers of third-party apps ask for hints and tips on coding their own software. We're not Apple developers. Your link to that post from 2014 is the right place for you to ask this question. However, I'll give you a litle help. That post by Grant Bennet-Alder simply shows the Configuration.plist file being shown in Xcode. It is not necessary to have Xcode to edit that file. Also, when you say "root within xcode" you're misunderstanding what's being shown. Root is simply the root of the XML in that file, i.e. the base level of it. All data in an XML file - which is what a .plist file is, starts off in the root. You do not need to be in root mode to edit that file. Does this folder exist? /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/ If so, is there a Configuration.plist file in there? If so, edit it in any text editor you want, and change it as suggested. That folder exists on my macOS 15.1.1, but the Configuration.plist file is not there. It is possible that, over the years, this was renamed, as there are two other .plist files in my current folder: Info.plist and version.plist but they do not look like your example.
Topic: UI Frameworks SubTopic: AppKit
Dec ’24
Reply to SwiftUI charts, how do I align these X axis labels correctly?
Look at your image and imagine there's a blue column immediately to the right of every red column. Now, the x-axis labels look like they're in the centre of the two columns. So, is your chart supposed to have two columns for each value? If not, in this line: AxisMarks(position: .automatic, values: shownXValues) { val in can position: .automatic be changed to something else? Also, is .useAppFont() a SwiftUI thing, or something you've written yourself? I've never seen it before.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’24
Reply to Common blocks in Swift?
#define COM_OFFSET 12.5 is simply let COM_OFFSET = 12.5. It looks like you want a file of commonly-used values/constants. That's easy. Just create a new Swift file and put your declarations inside, e.g.: let COM_OFFSET = 12.5 // You don't have to give arrays an initial size, but don't make them a `let` because you can't then add anything to it // So, either create an empty array globally like this, and add entries somewhere else, like: var dates: [PCDate] = [] addToDates() func addToDates() { dates.append(Date.now) dates.append(Date.now.advanced(by: 60) } // Or you can create a function that populates it when you create it, e.g. var dates = initialiseDates() func initialiseDates() -> [Date] { var array: [Date] = [] for index in 1...3 { array.append(Date.now) } return array } For the class stuff, just read up on how to create classes in Swift, but it's very easy - and you should put classes in their own file, so: import Foundation class MyLogger { static let fileURL: URL = { FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "my.app.group")!.appendingPathComponent("main.log") }() ... Then you just create an instance of it like any other class, just like you did with var dates: [Date] = [] above, i.e. var logger: MyLogger.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Shortcut automation
What do you think we can do with this? You haven't bothered to say what you were doing, what automation you're trying to use or create. These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. Are you in the right place?
Replies
Boosts
Views
Activity
Dec ’24
Reply to Ford SYNC3 is not connecting with IOS 18.2
You're in the wrong place. These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. Your question is more of a product support one, so I'd suggest you ask it over at the Apple Support Forums. You could even go ahead and ask Ford if they're planning an update... Thanks.
Replies
Boosts
Views
Activity
Dec ’24
Reply to Refreshing widgets - policy and background tasks?
I've extensivley tested this over the past two days. I tried timelines spanning one day, with: 72 entries, every 20 minutes 36 entries, every 40 minutes 24 entries, every hour 12 entries, every 2 hours 6 entries, every 4 hours 3 entries, every 8 hours 2 entries, every 12 hours In every case, the policy is .atEnd, and in every case the timeline is not refreshed when it's supposed to be, which causes the widget to display the wrong timer values. Due to the inflexibility of Text(date, style: .timer), I need to write code that calculates the correct timer value but shows less than a day. For example, if it's 11am today and the event date is tomorrow at noon, there are 25 hours between the two dates and the standard .timer would show 25:00:00, which is not what I want. So, I calculate the next occurrence of noon, and the widget shows "1 day" with a timer of "1:00:00". Every timeline with a refresh policy of .atEnd caues the countdown timer to show the wrong values. I've got it logging to a file, and I can see that the countdown dates are completely correct in every case. The widget is never refreshed at the right time, so the timers always show the wrong values. The only way I've managed to get this to work is to have a timeline with one entry, and a refresh policy of .after(), i.e. let date = Date() let refreshDate = Calendar.autoupdatingCurrent.date(byAdding: .minute, value: 30, to: date)! Timeline(entries: entries, policy: .after(refreshDate)) There is clearly something wrong with .atEnd.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Mac M1 Unable to restore in DFU error
Okay, firstly, you have a MacBook Pro 2021 with an M1 chip, not a "Mac M1 Pro 2021". Do you have to use Apple Configurator? Can't you restore it in any other way? What have you tried? Oh, also, you're in the wrong place. These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. Your question is more of a product support one, so I'd suggest you ask it over at the Apple Support Forums. Thanks.
Replies
Boosts
Views
Activity
Dec ’24
Reply to Why can't I use Task in an iOS only package?
If you look at the Developer Documentation for Task it shows which versions it's available in. I see: iOS 13.0+ | iPadOS 13.0+ | Mac Catalyst 13.0+ | macOS 10.15+ | tvOS 13.0+ | visionOS 1.0+ | watchOS 6.0+ So yeah, macOS 15.0+. Is your app definitely only targeting iOS?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to I Need Help!
You're in the wrong place here. These are the Developer Forums, where developers of third-party apps ask for hints and tips on coding their own software. We're not Apple developers. Your link to that post from 2014 is the right place for you to ask this question. However, I'll give you a litle help. That post by Grant Bennet-Alder simply shows the Configuration.plist file being shown in Xcode. It is not necessary to have Xcode to edit that file. Also, when you say "root within xcode" you're misunderstanding what's being shown. Root is simply the root of the XML in that file, i.e. the base level of it. All data in an XML file - which is what a .plist file is, starts off in the root. You do not need to be in root mode to edit that file. Does this folder exist? /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/ If so, is there a Configuration.plist file in there? If so, edit it in any text editor you want, and change it as suggested. That folder exists on my macOS 15.1.1, but the Configuration.plist file is not there. It is possible that, over the years, this was renamed, as there are two other .plist files in my current folder: Info.plist and version.plist but they do not look like your example.
Topic: UI Frameworks SubTopic: AppKit
Replies
Boosts
Views
Activity
Dec ’24
Reply to SwiftUI charts, how do I align these X axis labels correctly?
Look at your image and imagine there's a blue column immediately to the right of every red column. Now, the x-axis labels look like they're in the centre of the two columns. So, is your chart supposed to have two columns for each value? If not, in this line: AxisMarks(position: .automatic, values: shownXValues) { val in can position: .automatic be changed to something else? Also, is .useAppFont() a SwiftUI thing, or something you've written yourself? I've never seen it before.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’24