Post

Replies

Boosts

Views

Activity

Reply to Xcode version 14.2 crashes as soon as opened in mac os 15.0.1
Why do you want to use an earlier version of Xcode? And, why do you think such a version would function properly on a newer version of macOS? What is the actual reason you need Xcode 14.2? If you look on this page: https://developer.apple.com/support/xcode/ you'll see the various versions of Xcode and the SDKs it supports. I get the feeling you're looking for something that you think only existed in Xcode 14.2? Some conversion tool or something? Apple don't just put features in one version of Xcode, you know? Just open your project (or a copy of it) in the latest version of Xcode. You should be able to work with it in there. Besides, if you then wanted to release your app, you wouldn't be able to use Xcode 14.2 anyway, so I don't understand why you're going down this route...?
Dec ’24
Reply to Some colors are missing during first app launch
This is clearly something within your app, and not something we can really diagnose. Have you used a fresh Simulator and installed fresh onto there (from Xcode)? Does the issue happen when the Simulator is in Dark Mode when you first install it? If so, is the app registering the right colours in the various bits where you're supposed to set the colours of these buttons? Perhaps some of your code for the affected buttons would help us? But, please note, it's Christmas, so I'm not responding for a few days :)
Dec ’24
Reply to Cod radeem
Right, and how are we going to help you with that? You need to speak to the developer of the specific app you want to join the TestFlight beta for. We're just random developers who write apps for Apple's platforms, and we use these forums to ask for hints and tips on coding. We aren't the devs you're looking for. Merry Christmas.
Topic: Code Signing SubTopic: General
Dec ’24
Reply to Can't use Link in .systemLarge widget
Here's what prints to the log when I run the app: application: didFinishLaunchingWithOptions launchOptions = application: configurationForConnecting scene: willConnectTo session maybeOpenedFromWidget(): urlContexts = [] I go to the Home screen, and tap a small widget: .onOpenURL url.scheme = Optional("myscheme") url.path.description = E3C68269-EFB9-44EB-BD6F-430FADD4E6E7 scene: openURLContexts maybeOpenedFromWidget(): urlContexts = [<UIOpenURLContext: 0x600000365840; URL: myscheme://myhost/E3C68269-EFB9-44EB-BD6F-430FADD4E6E7; options: <UISceneOpenURLOptions: 0x600001805d00; sourceApp: (null); annotation: (null); openInPlace: NO; _eventAttribution: (null)>>] Launched from widget I go to the Home screen and tap a medium widget: url.scheme = Optional("myscheme") url.path.description = E7B8A9DB-A465-4AD9-99B3-DDCF054712A7 scene: openURLContexts maybeOpenedFromWidget(): urlContexts = [<UIOpenURLContext: 0x6000002e5960; URL: myscheme://myhost/E7B8A9DB-A465-4AD9-99B3-DDCF054712A7; options: <UISceneOpenURLOptions: 0x600001779540; sourceApp: (null); annotation: (null); openInPlace: NO; _eventAttribution: (null)>>] Launched from widget I go to the Home screen and tap a row in the large widget. The row does not go faint like it's supposed to, so the Link clearly isn't working. Nothing is printed in the log. EDIT: Oh, I just found out it's yet another bug from Apple ¯\_(ツ)_/¯ Please invest in some automated tests, guys!
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’24
Reply to How to draw emojis like the Lock Screen customisation?
Never mind, I figured it out, but it's too much code to post here. But, basically, you plonk an emoji somewhere on the screen, then put six more of them in six positions every 60º around the original one: 0º (top), 60º (top right), 120º (bottom right, 180º (bottom), 240º (bottom left), and 300º (top left). Figure out how the pattern should look, i.e. which of those six are the first character, which are the second, etc. up to seven characters or whatever limit you want. Use the Canvas { context, size in to draw the characters, then snapshot it: let uiImage = MyCanvasView(bgColour: Color.whatever, text: whateverText) .background(Color.whatever) .drawingGroup(opaque: true).snapshot()
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’24
Reply to arrays
This function you have is set up to receive an array of Doubles and let you refer to them as costa: func myfunc(costa: [Double]) { // some code } If you're calling the function like this: myfunc(costa: []) then you're passing in an empty array. [] means an empty array. If you want to pass in some values, you need them in the array, e.g.: myfunc(costa: [1.0, 2.1, 3.2, 4.3]) If you need to return an array of Doubles - or anything - you would use a function like this: func myfunc(costa: [Double]) -> [Double] { // some code return myArray // which would be an array of Doubles } A very useful feature of Swift is the ability to hide the name of the variable, so you don't have to enter it every time. Just put an underscore before the first variable name in the function's signature, i.e.: func myfunc(_ costa: [Double]) { // some code } This lets you access the array of Doubles in costa. To call it you would use: myfunc([1.0, 2.1, 3.2, 4.3]) A similar helpful feature is replacing the underscore with something else that makes sense when you read the function out loud. Consider this: func addFive(_ value: Int) -> Int { return value + 5 } You call it with: let total: Int = addFive(6) // 11 You can change the signature to something that makes more sense when read out loud: func addFive(to value: Int) -> Int { return value + 5 } You call it with: let total: Int = addFive(to: 6) // 11 Hope this helps. Also, just an FYI, you're writing in Swift when you do things like this. SwiftUI is for user interface stuff like Buttons, Text, Views, etc.
Dec ’24
Reply to Apple Air Pods Upgrade!
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. Please don't spam these forums with such posts.
Topic: Design SubTopic: General Tags:
Dec ’24
Reply to Why first View on my NavigationStack appears again when I switch branch?
The NavigationStack still exists because of this sequence of events: You've gone through all the steps in the onboarding and are at step .four. Then, when you click the End button, isFinished is set to true. steps still contains a value, and is not empty until you press the Restart button. If the whole view were refreshed at this point, then SwiftUI would likely not bother to regenerate the NavigationStack because isFinished is not false. As it is, SwiftUI has generated the entire view so that the instant you press Restart, the NavigationStack is present and ready and doesn't need to be generated. Thus, it's all smooth and lovely for your UI and users. As explained, the VStack is not actually displayed on-screen because SwiftUI knows it's not being displayed... yet, but it's there for when it's needed. That's what it looks like anyway. Like I said, raise a bug if you think it's a bug.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’24
Reply to Why first View on my NavigationStack appears again when I switch branch?
It's not really when it appears - as you can see in your example, because the Start text is not actually displayed again. It's when the View is added to the view cycle. So, as I said, the NavigationStack is displayed, you go through the steps, and then there's nothing for it to display but it is still in the view lifecycle until isFinished becomes true. That's why I said it's not really a bug, but you could raise it. Alternatively, someone else who knows what they're talking about could jump in 😃 However, you can use my own code to get around this... enum Step { case one case two case three case four } struct ContentView: View { @State private var isFinished: Bool = false @State private var steps: [Step] = [] var body: some View { if isFinished { Button("Restart") { steps = [] isFinished = false } } else { NavigationStack(path: $steps) { VStack { Text("Start") .onFirstAppear { print("onFirstAppear: start") } Button("Go to step 1") { steps.append(.one) } } .navigationDestination(for: Step.self) { step in switch step { case .one: Button("Go to step 2") { steps.append(.two) } .onFirstAppear { print("onFirstAppear: step 1") } case .two: Button("Go to step 3") { steps.append(.three) } .onFirstAppear { print("onFirstAppear: step 2") } case .three: Button("Go to step 4") { steps.append(.four) } .onFirstAppear { print("onFirstAppear: step 3") } case .four: Button("End") { isFinished = true } .onFirstAppear { print("onFirstAppear: end") } } } } .onFirstAppear { print("onFirstAppear: NavigationStack") } } } } #Preview { ContentView() } extension View { func onFirstAppear(perform: @escaping () -> Void) -> some View { modifier(OnFirstAppear(perform: perform)) } } private struct OnFirstAppear: ViewModifier { let perform: () -> Void @State private var firstTime = true func body(content: Content) -> some View { content.onAppear { if firstTime { firstTime = false perform() } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’24
Reply to Why first View on my NavigationStack appears again when I switch branch?
.onAppear { print("onAppear: start") } is attached to the VStack, so I'd expect that will be displayed regardless of the value in steps. However, even if you attached it instead to the Button inside that VStack I would think it is still displayed because it's in the view until isFinished becomes true. When you get to step four, press the End button and set steps = [], at that point the navigation stack has nothing in the switch statement so it's going to display the VStack, but then the view is redrawn because finished is now true. I'm not sure it's a bug, but you could raise it and Apple might be able to re-jig the inner workings so that part of your if statement is completely ignored when finished becomes true.
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:
Dec ’24
Reply to Xcode version 14.2 crashes as soon as opened in mac os 15.0.1
Why do you want to use an earlier version of Xcode? And, why do you think such a version would function properly on a newer version of macOS? What is the actual reason you need Xcode 14.2? If you look on this page: https://developer.apple.com/support/xcode/ you'll see the various versions of Xcode and the SDKs it supports. I get the feeling you're looking for something that you think only existed in Xcode 14.2? Some conversion tool or something? Apple don't just put features in one version of Xcode, you know? Just open your project (or a copy of it) in the latest version of Xcode. You should be able to work with it in there. Besides, if you then wanted to release your app, you wouldn't be able to use Xcode 14.2 anyway, so I don't understand why you're going down this route...?
Replies
Boosts
Views
Activity
Dec ’24
Reply to Some colors are missing during first app launch
This is clearly something within your app, and not something we can really diagnose. Have you used a fresh Simulator and installed fresh onto there (from Xcode)? Does the issue happen when the Simulator is in Dark Mode when you first install it? If so, is the app registering the right colours in the various bits where you're supposed to set the colours of these buttons? Perhaps some of your code for the affected buttons would help us? But, please note, it's Christmas, so I'm not responding for a few days :)
Replies
Boosts
Views
Activity
Dec ’24
Reply to Cod radeem
Right, and how are we going to help you with that? You need to speak to the developer of the specific app you want to join the TestFlight beta for. We're just random developers who write apps for Apple's platforms, and we use these forums to ask for hints and tips on coding. We aren't the devs you're looking for. Merry Christmas.
Topic: Code Signing SubTopic: General
Replies
Boosts
Views
Activity
Dec ’24
Reply to Apple support rejected my refund with ridiculous reason
You're in the wrong place for this. 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 Widget link broken by `.desaturated` image rendering mode
I've wasted hours today trying to figure out why my Links weren't working. Thanks, Apple. And, special thanks to the one guy you've got testing your software these days.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Can't use Link in .systemLarge widget
Here's what prints to the log when I run the app: application: didFinishLaunchingWithOptions launchOptions = application: configurationForConnecting scene: willConnectTo session maybeOpenedFromWidget(): urlContexts = [] I go to the Home screen, and tap a small widget: .onOpenURL url.scheme = Optional("myscheme") url.path.description = E3C68269-EFB9-44EB-BD6F-430FADD4E6E7 scene: openURLContexts maybeOpenedFromWidget(): urlContexts = [<UIOpenURLContext: 0x600000365840; URL: myscheme://myhost/E3C68269-EFB9-44EB-BD6F-430FADD4E6E7; options: <UISceneOpenURLOptions: 0x600001805d00; sourceApp: (null); annotation: (null); openInPlace: NO; _eventAttribution: (null)>>] Launched from widget I go to the Home screen and tap a medium widget: url.scheme = Optional("myscheme") url.path.description = E7B8A9DB-A465-4AD9-99B3-DDCF054712A7 scene: openURLContexts maybeOpenedFromWidget(): urlContexts = [<UIOpenURLContext: 0x6000002e5960; URL: myscheme://myhost/E7B8A9DB-A465-4AD9-99B3-DDCF054712A7; options: <UISceneOpenURLOptions: 0x600001779540; sourceApp: (null); annotation: (null); openInPlace: NO; _eventAttribution: (null)>>] Launched from widget I go to the Home screen and tap a row in the large widget. The row does not go faint like it's supposed to, so the Link clearly isn't working. Nothing is printed in the log. EDIT: Oh, I just found out it's yet another bug from Apple ¯\_(ツ)_/¯ Please invest in some automated tests, guys!
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Is there any way to get around this Xcode previews bug?
I've never had anything like this happen to me. Do any of the buttons below the preview make any difference? Zoom in/out, appearance customisations, etc.? Have you deleted the Xocde app completely and reinstalled?
Replies
Boosts
Views
Activity
Dec ’24
Reply to percentages
Look up String(format:). You'll want something like: String(format: "%.0f", 4.3333) // Returns "4"
Replies
Boosts
Views
Activity
Dec ’24
Reply to How to draw emojis like the Lock Screen customisation?
Never mind, I figured it out, but it's too much code to post here. But, basically, you plonk an emoji somewhere on the screen, then put six more of them in six positions every 60º around the original one: 0º (top), 60º (top right), 120º (bottom right, 180º (bottom), 240º (bottom left), and 300º (top left). Figure out how the pattern should look, i.e. which of those six are the first character, which are the second, etc. up to seven characters or whatever limit you want. Use the Canvas { context, size in to draw the characters, then snapshot it: let uiImage = MyCanvasView(bgColour: Color.whatever, text: whateverText) .background(Color.whatever) .drawingGroup(opaque: true).snapshot()
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to arrays
This function you have is set up to receive an array of Doubles and let you refer to them as costa: func myfunc(costa: [Double]) { // some code } If you're calling the function like this: myfunc(costa: []) then you're passing in an empty array. [] means an empty array. If you want to pass in some values, you need them in the array, e.g.: myfunc(costa: [1.0, 2.1, 3.2, 4.3]) If you need to return an array of Doubles - or anything - you would use a function like this: func myfunc(costa: [Double]) -> [Double] { // some code return myArray // which would be an array of Doubles } A very useful feature of Swift is the ability to hide the name of the variable, so you don't have to enter it every time. Just put an underscore before the first variable name in the function's signature, i.e.: func myfunc(_ costa: [Double]) { // some code } This lets you access the array of Doubles in costa. To call it you would use: myfunc([1.0, 2.1, 3.2, 4.3]) A similar helpful feature is replacing the underscore with something else that makes sense when you read the function out loud. Consider this: func addFive(_ value: Int) -> Int { return value + 5 } You call it with: let total: Int = addFive(6) // 11 You can change the signature to something that makes more sense when read out loud: func addFive(to value: Int) -> Int { return value + 5 } You call it with: let total: Int = addFive(to: 6) // 11 Hope this helps. Also, just an FYI, you're writing in Swift when you do things like this. SwiftUI is for user interface stuff like Buttons, Text, Views, etc.
Replies
Boosts
Views
Activity
Dec ’24
Reply to Apple Air Pods Upgrade!
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. Please don't spam these forums with such posts.
Topic: Design SubTopic: General Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Why first View on my NavigationStack appears again when I switch branch?
The NavigationStack still exists because of this sequence of events: You've gone through all the steps in the onboarding and are at step .four. Then, when you click the End button, isFinished is set to true. steps still contains a value, and is not empty until you press the Restart button. If the whole view were refreshed at this point, then SwiftUI would likely not bother to regenerate the NavigationStack because isFinished is not false. As it is, SwiftUI has generated the entire view so that the instant you press Restart, the NavigationStack is present and ready and doesn't need to be generated. Thus, it's all smooth and lovely for your UI and users. As explained, the VStack is not actually displayed on-screen because SwiftUI knows it's not being displayed... yet, but it's there for when it's needed. That's what it looks like anyway. Like I said, raise a bug if you think it's a bug.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Why first View on my NavigationStack appears again when I switch branch?
It's not really when it appears - as you can see in your example, because the Start text is not actually displayed again. It's when the View is added to the view cycle. So, as I said, the NavigationStack is displayed, you go through the steps, and then there's nothing for it to display but it is still in the view lifecycle until isFinished becomes true. That's why I said it's not really a bug, but you could raise it. Alternatively, someone else who knows what they're talking about could jump in 😃 However, you can use my own code to get around this... enum Step { case one case two case three case four } struct ContentView: View { @State private var isFinished: Bool = false @State private var steps: [Step] = [] var body: some View { if isFinished { Button("Restart") { steps = [] isFinished = false } } else { NavigationStack(path: $steps) { VStack { Text("Start") .onFirstAppear { print("onFirstAppear: start") } Button("Go to step 1") { steps.append(.one) } } .navigationDestination(for: Step.self) { step in switch step { case .one: Button("Go to step 2") { steps.append(.two) } .onFirstAppear { print("onFirstAppear: step 1") } case .two: Button("Go to step 3") { steps.append(.three) } .onFirstAppear { print("onFirstAppear: step 2") } case .three: Button("Go to step 4") { steps.append(.four) } .onFirstAppear { print("onFirstAppear: step 3") } case .four: Button("End") { isFinished = true } .onFirstAppear { print("onFirstAppear: end") } } } } .onFirstAppear { print("onFirstAppear: NavigationStack") } } } } #Preview { ContentView() } extension View { func onFirstAppear(perform: @escaping () -> Void) -> some View { modifier(OnFirstAppear(perform: perform)) } } private struct OnFirstAppear: ViewModifier { let perform: () -> Void @State private var firstTime = true func body(content: Content) -> some View { content.onAppear { if firstTime { firstTime = false perform() } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Why first View on my NavigationStack appears again when I switch branch?
.onAppear { print("onAppear: start") } is attached to the VStack, so I'd expect that will be displayed regardless of the value in steps. However, even if you attached it instead to the Button inside that VStack I would think it is still displayed because it's in the view until isFinished becomes true. When you get to step four, press the End button and set steps = [], at that point the navigation stack has nothing in the switch statement so it's going to display the VStack, but then the view is redrawn because finished is now true. I'm not sure it's a bug, but you could raise it and Apple might be able to re-jig the inner workings so that part of your if statement is completely ignored when finished becomes true.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
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