Post

Replies

Boosts

Views

Activity

Reply to iPhone Camera opening unexpectedly
You should probably raise this as a bug in the usual way. It won't really get progressed if it's only posted in these Developer Forums. You need to raise each issue you find separately at https://feedbackassistant.apple.com/ You can post the FB numbers here if you want, so that others can link to them.
Nov ’24
Reply to Mac os 15, breaking Citrix VPN
This page on Citrix's website doesn't mention macOS 15 as a supported version, so it seems you'll have to wait for Citrix to release a compatible version, and I'd suggest you contact them: https://docs.citrix.com/en-us/citrix-secure-private-access/service/spa-csa-for-client-server-apps.html
Oct ’24
Reply to Wind Compass swift UI
No problem. Just remember not to redraw the entire view when you change the degrees. You only need to change the rotationEffect of the compass marker arrow (and whatever text you put in the VStack) when the value changes.
Topic: Design SubTopic: General Tags:
Oct ’24
Reply to Wind Compass swift UI
Something like this? This is what I wrote and use in my own app, so if you use it, please make it look a little different... or I'll sue 😉 import SwiftUI struct ContentView: View { var body: some View { let windDegrees = 255.0 let frameSize = 240.0 ZStack { LinearGradient(gradient: Gradient(colors: [Color.init(red: 91.0/255.0, green: 100.0/255.0, blue: 157.0/255.0), Color.init(red: 125.0/255.0, green: 108.0/255.0, blue: 142.0/255.0)]), startPoint: .top, endPoint: .bottom) ZStack { Circle() .opacity(0.1) Image("compassMarker") .resizable() .scaledToFit() .frame(width: 10, height: 100) .rotationEffect(Angle(degrees: windDegrees - 180)) .shadow(color: .black.opacity(0.6), radius: 1, x: 1, y: 1) Circle() .fill(.black.opacity(0.15)) .frame(width: frameSize/2, height: frameSize/2) VStack { Text(convertWindDirectionToCompassPoint(windDegrees)) .font(.system(size: 18, weight: .bold)) .foregroundStyle(.white) .shadow(color: .black.opacity(0.6), radius: 1, x: 1, y: 1) Text("\(String(format: "%.0f", windDegrees))º") .font(.system(size: 12)) .foregroundStyle(.white) .lineLimit(1) .minimumScaleFactor(0.6) .shadow(color: .black.opacity(0.6), radius: 1, x: 1, y: 1) } ForEach(CompassMarker.markers(), id: \.self) { marker in CompassMarkerView(marker: marker, compassDegress: 0) } } .frame(width: frameSize, height: frameSize) } .ignoresSafeArea() } struct CompassMarker: Hashable { let degrees: Double let label: String init(degrees: Double, label: String = "") { self.degrees = degrees self.label = label } static func markers() -> [CompassMarker] { return [ CompassMarker(degrees: 0, label: "N"), CompassMarker(degrees: 30), CompassMarker(degrees: 60), CompassMarker(degrees: 90, label: "E"), CompassMarker(degrees: 120), CompassMarker(degrees: 150), CompassMarker(degrees: 180, label: "S"), CompassMarker(degrees: 210), CompassMarker(degrees: 240), CompassMarker(degrees: 270, label: "W"), CompassMarker(degrees: 300), CompassMarker(degrees: 330) ] } func degreeText() -> String { return String(format: "%.0f", self.degrees) } } struct CompassMarkerView: View { let marker: CompassMarker let compassDegress: Double var body: some View { VStack { Capsule() .frame(width: 2, height: self.capsuleHeight()) .foregroundStyle(Color.white) .opacity(0.6) .padding(.bottom, self.capsulePadding()) Text(marker.label) .font(.system(size: 16, weight: .bold)) .foregroundStyle(Color.white) .opacity(0.6) .rotationEffect(self.textAngle()) Spacer(minLength: 97) } .rotationEffect(Angle(degrees: marker.degrees)) } private func capsuleHeight() -> CGFloat { return (marker.label != "" ? 8 : 12) } private func capsulePadding() -> CGFloat { return (marker.label != "" ? -12 : -6) } private func textAngle() -> Angle { return Angle(degrees: -self.compassDegress - self.marker.degrees) } } func convertWindDirectionToCompassPoint(_ degrees: Double) -> String { var degrees_: Double = fmod(degrees, 360.0) var point: String = "" if(degrees_ > 360) { degrees_ = degrees_.truncatingRemainder(dividingBy: 360) } if((degrees_ >= 0.0 && degrees_ <= 11.25) || (degrees_ > 348.75 && degrees_ <= 360.0)) { point = "N" } if(degrees_ > 11.25 && degrees_ <= 33.75) { point = "NNE" } if(degrees_ > 33.75 && degrees_ <= 56.25) { point = "NE" } if(degrees_ > 56.25 && degrees_ <= 78.75) { point = "ENE" } if(degrees_ > 78.75 && degrees_ <= 101.25) { point = "E" } if(degrees_ > 101.25 && degrees_ <= 123.75) { point = "ESE" } if(degrees_ > 123.75 && degrees_ <= 146.25) { point = "SE" } if(degrees_ > 146.25 && degrees_ <= 168.75) { point = "SSE" } if(degrees_ > 168.75 && degrees_ <= 191.25) { point = "S" } if(degrees_ > 191.25 && degrees_ <= 213.75) { point = "SSW" } if(degrees_ > 213.75 && degrees_ <= 236.25) { point = "SW" } if(degrees_ > 236.25 && degrees_ <= 258.75) { point = "WSW" } if(degrees_ > 258.75 && degrees_ <= 281.25) { point = "W" } if(degrees_ > 281.25 && degrees_ <= 303.75) { point = "WNW" } if(degrees_ > 303.75 && degrees_ <= 326.25) { point = "NW" } if(degrees_ > 326.25 && degrees_ <= 348.75) { point = "NNW" } return point } } #Preview { ContentView() } Pass in your windDegrees (line 5) as a Double. Oh, and here's an image for the compassMarker arrow: The size of the compass is constrained by the frameSize so if you change it you'll need to alter the arrow image. You also don't need to show the degrees and 'WSW' text (for example), and can easily put your own text in the VStack.
Topic: Design SubTopic: General Tags:
Oct ’24
Reply to Equal width buttons in VStack
SwiftUI draws the button as wide as it needs to be for the title. It's up to you to tell it how wide the button should be. I do this by creating and applying a new ButtonStyle, like this: import SwiftUI struct ContentView: View { var body: some View { VStack(alignment: .center) { Button("Short", action: {}) .buttonStyle(MyButtonStyle(bgColor: .gray, fgColor: .white)) Button("Long title", action: {}) .buttonStyle(MyButtonStyle(bgColor: .yellow, fgColor: .black)) Button("A longer button title", action: {}) .buttonStyle(MyButtonStyle(bgColor: .green, fgColor: .white)) Button("A much, much, much longer button title", action: {}) .buttonStyle(MyButtonStyle(bgColor: .blue, fgColor: .white)) } } } struct MyButtonStyle: ButtonStyle { var bgColor: Color? var fgColor: Color? func makeBody(configuration: Configuration) -> some View { configuration.label .font(.headline) .bold() .allowsTightening(true) .lineLimit(2) .frame(width: 200, height: 60) .background(bgColor ?? .gray) .foregroundStyle(fgColor ?? .white) .clipShape(RoundedRectangle(cornerRadius: 16)) } } #Preview { ContentView() } That example gives you this: Note that you can change the number of lines in the button by changing .lineLimit().
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’24
Reply to iPhone Camera opening unexpectedly
You should probably raise this as a bug in the usual way. It won't really get progressed if it's only posted in these Developer Forums. You need to raise each issue you find separately at https://feedbackassistant.apple.com/ You can post the FB numbers here if you want, so that others can link to them.
Replies
Boosts
Views
Activity
Nov ’24
Reply to The Right Side of my MacBook is Unclickable!
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
Oct ’24
Reply to Mac os 15, breaking Citrix VPN
This page on Citrix's website doesn't mention macOS 15 as a supported version, so it seems you'll have to wait for Citrix to release a compatible version, and I'd suggest you contact them: https://docs.citrix.com/en-us/citrix-secure-private-access/service/spa-csa-for-client-server-apps.html
Replies
Boosts
Views
Activity
Oct ’24
Reply to WhatsApp is incorrectly adding a number as suffix to device name in the list of Linked devices
Not really an issue for us third-party app developers. You should get in touch with WhatsApp.
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
Oct ’24
Reply to Wind Compass swift UI
No problem. Just remember not to redraw the entire view when you change the degrees. You only need to change the rotationEffect of the compass marker arrow (and whatever text you put in the VStack) when the value changes.
Topic: Design SubTopic: General Tags:
Replies
Boosts
Views
Activity
Oct ’24
Reply to Wind Compass swift UI
Something like this? This is what I wrote and use in my own app, so if you use it, please make it look a little different... or I'll sue 😉 import SwiftUI struct ContentView: View { var body: some View { let windDegrees = 255.0 let frameSize = 240.0 ZStack { LinearGradient(gradient: Gradient(colors: [Color.init(red: 91.0/255.0, green: 100.0/255.0, blue: 157.0/255.0), Color.init(red: 125.0/255.0, green: 108.0/255.0, blue: 142.0/255.0)]), startPoint: .top, endPoint: .bottom) ZStack { Circle() .opacity(0.1) Image("compassMarker") .resizable() .scaledToFit() .frame(width: 10, height: 100) .rotationEffect(Angle(degrees: windDegrees - 180)) .shadow(color: .black.opacity(0.6), radius: 1, x: 1, y: 1) Circle() .fill(.black.opacity(0.15)) .frame(width: frameSize/2, height: frameSize/2) VStack { Text(convertWindDirectionToCompassPoint(windDegrees)) .font(.system(size: 18, weight: .bold)) .foregroundStyle(.white) .shadow(color: .black.opacity(0.6), radius: 1, x: 1, y: 1) Text("\(String(format: "%.0f", windDegrees))º") .font(.system(size: 12)) .foregroundStyle(.white) .lineLimit(1) .minimumScaleFactor(0.6) .shadow(color: .black.opacity(0.6), radius: 1, x: 1, y: 1) } ForEach(CompassMarker.markers(), id: \.self) { marker in CompassMarkerView(marker: marker, compassDegress: 0) } } .frame(width: frameSize, height: frameSize) } .ignoresSafeArea() } struct CompassMarker: Hashable { let degrees: Double let label: String init(degrees: Double, label: String = "") { self.degrees = degrees self.label = label } static func markers() -> [CompassMarker] { return [ CompassMarker(degrees: 0, label: "N"), CompassMarker(degrees: 30), CompassMarker(degrees: 60), CompassMarker(degrees: 90, label: "E"), CompassMarker(degrees: 120), CompassMarker(degrees: 150), CompassMarker(degrees: 180, label: "S"), CompassMarker(degrees: 210), CompassMarker(degrees: 240), CompassMarker(degrees: 270, label: "W"), CompassMarker(degrees: 300), CompassMarker(degrees: 330) ] } func degreeText() -> String { return String(format: "%.0f", self.degrees) } } struct CompassMarkerView: View { let marker: CompassMarker let compassDegress: Double var body: some View { VStack { Capsule() .frame(width: 2, height: self.capsuleHeight()) .foregroundStyle(Color.white) .opacity(0.6) .padding(.bottom, self.capsulePadding()) Text(marker.label) .font(.system(size: 16, weight: .bold)) .foregroundStyle(Color.white) .opacity(0.6) .rotationEffect(self.textAngle()) Spacer(minLength: 97) } .rotationEffect(Angle(degrees: marker.degrees)) } private func capsuleHeight() -> CGFloat { return (marker.label != "" ? 8 : 12) } private func capsulePadding() -> CGFloat { return (marker.label != "" ? -12 : -6) } private func textAngle() -> Angle { return Angle(degrees: -self.compassDegress - self.marker.degrees) } } func convertWindDirectionToCompassPoint(_ degrees: Double) -> String { var degrees_: Double = fmod(degrees, 360.0) var point: String = "" if(degrees_ > 360) { degrees_ = degrees_.truncatingRemainder(dividingBy: 360) } if((degrees_ >= 0.0 && degrees_ <= 11.25) || (degrees_ > 348.75 && degrees_ <= 360.0)) { point = "N" } if(degrees_ > 11.25 && degrees_ <= 33.75) { point = "NNE" } if(degrees_ > 33.75 && degrees_ <= 56.25) { point = "NE" } if(degrees_ > 56.25 && degrees_ <= 78.75) { point = "ENE" } if(degrees_ > 78.75 && degrees_ <= 101.25) { point = "E" } if(degrees_ > 101.25 && degrees_ <= 123.75) { point = "ESE" } if(degrees_ > 123.75 && degrees_ <= 146.25) { point = "SE" } if(degrees_ > 146.25 && degrees_ <= 168.75) { point = "SSE" } if(degrees_ > 168.75 && degrees_ <= 191.25) { point = "S" } if(degrees_ > 191.25 && degrees_ <= 213.75) { point = "SSW" } if(degrees_ > 213.75 && degrees_ <= 236.25) { point = "SW" } if(degrees_ > 236.25 && degrees_ <= 258.75) { point = "WSW" } if(degrees_ > 258.75 && degrees_ <= 281.25) { point = "W" } if(degrees_ > 281.25 && degrees_ <= 303.75) { point = "WNW" } if(degrees_ > 303.75 && degrees_ <= 326.25) { point = "NW" } if(degrees_ > 326.25 && degrees_ <= 348.75) { point = "NNW" } return point } } #Preview { ContentView() } Pass in your windDegrees (line 5) as a Double. Oh, and here's an image for the compassMarker arrow: The size of the compass is constrained by the frameSize so if you change it you'll need to alter the arrow image. You also don't need to show the degrees and 'WSW' text (for example), and can easily put your own text in the VStack.
Topic: Design SubTopic: General Tags:
Replies
Boosts
Views
Activity
Oct ’24
Reply to I can’t understand this SwiftUI compile error.
I've had this a few times, but the message says the compiler is unable to type-check it in a reasonable time, which AFAIK - is why you can't see where the error is: it took too long to figure it out.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’24
Reply to Apple Time Machine Sequoia 15.0.1
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.
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
Oct ’24
Reply to Conditionally compile newer API with older XCode
Hang on, maybe I misunderstood this. Can you use something like the respondsToSelector? I have no idea if it's there in Swift 5/6, but this SO page gives an example of how to use it: https://stackoverflow.com/questions/24167791/what-is-the-swift-equivalent-of-respondstoselector
Replies
Boosts
Views
Activity
Oct ’24
Reply to Critical Bug in iOS 18.1 RC and watchOS 11.1 RC - WidgetKit Complications Not Syncing
Raise this in the usual way, as a Feedback report, then post the FB number here.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’24
Reply to Equal width buttons in VStack
SwiftUI draws the button as wide as it needs to be for the title. It's up to you to tell it how wide the button should be. I do this by creating and applying a new ButtonStyle, like this: import SwiftUI struct ContentView: View { var body: some View { VStack(alignment: .center) { Button("Short", action: {}) .buttonStyle(MyButtonStyle(bgColor: .gray, fgColor: .white)) Button("Long title", action: {}) .buttonStyle(MyButtonStyle(bgColor: .yellow, fgColor: .black)) Button("A longer button title", action: {}) .buttonStyle(MyButtonStyle(bgColor: .green, fgColor: .white)) Button("A much, much, much longer button title", action: {}) .buttonStyle(MyButtonStyle(bgColor: .blue, fgColor: .white)) } } } struct MyButtonStyle: ButtonStyle { var bgColor: Color? var fgColor: Color? func makeBody(configuration: Configuration) -> some View { configuration.label .font(.headline) .bold() .allowsTightening(true) .lineLimit(2) .frame(width: 200, height: 60) .background(bgColor ?? .gray) .foregroundStyle(fgColor ?? .white) .clipShape(RoundedRectangle(cornerRadius: 16)) } } #Preview { ContentView() } That example gives you this: Note that you can change the number of lines in the button by changing .lineLimit().
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’24
Reply to XCode & MacOS Version
Sadly, that's the state of things. You're using an almost 10 year old laptop. Do you know anyone with a Mac with macOS 14.5 or later? Or, you can go down the usual route of refurbished machines or an auction site, or a trade-in.
Replies
Boosts
Views
Activity
Oct ’24
Reply to Conditionally compile newer API with older XCode
Xcode 15 doesn't support the iOS 18 SDK, so you cannot build iOS 18 apps with an Xcode earlier than version 16. There is no workaround for that. I suppose you should be asking how to fix the non-trivial issue with building your app in Xcode 16?
Replies
Boosts
Views
Activity
Oct ’24
Reply to macos menu bar color picker not working properly
It would help to see your code as you might be doing something wrong in there.
Replies
Boosts
Views
Activity
Oct ’24
Reply to macos menu bar color picker not working properly
You haven't actually told us why the ColorPicker isn't working properly... Show us your code, and explain exactly what you want to happen, and what it's actually doing. Maybe a screenshot would help too?
Replies
Boosts
Views
Activity
Oct ’24