Post

Replies

Boosts

Views

Activity

Reply to iPad/iPhone - Display best practices….
All my apps work on both the iPhone and iPad, but due to the amount of changes - some structural - that are required to get an iPhone version to look and work properly on the iPad, I use two different views: @main struct MainApp: App { // ... var body: some Scene { WindowGroup { if(UIDevice.current.userInterfaceIdiom == .pad) { TabletView() } else { PhoneView() } } } } So, if the user is using an iPhone, the PhoneView() is the main entry point. For iPads, it's TabletView(). The reason I did this is because the iPad has much more space and allows me to do more things, so the TabletView has more things in it. Also, I'd rather not have one big, unmanageable View full of if ... else statements and ternary operators. It also means your spacers and padding values apply only to that device type. Where the two views have similar UI, those bits are extracted into their own little View structs and called within those two main entry points. When you separate out the two views you may find you're duplicating some work, but you'll also be working on a view that only applies to an iPad or an iPhone and not both. You can make a change in the TabletView and be assured it hasn't affected the PhoneView, so you haven't got to retest that change on the iPhone. You can also then expand this to include Vision Pro, Apple TV, and any other device idioms Apple has or releases in future, and you won't need to add more and more if ... else and ternary operators in that one massive file. If you're having issues with specific models of an iPad or iPhone I'd say you're maybe using too many magic numbers in your code? You've probably found that the padding on an iPhone 13 mini for some label is 5, while on an iPhone 14 Plus it's 12 so you've written that in. You should rework this to align things naturally using SwiftUI's HStacks, YStacks etc. Or, have a consistent padding for your UI so that it looks the same on every device. Let's say you can fit 8 text fields vertically in a form on an iPhone 12 mini, and 10 on an iPhone 15 Pro, that's fine. You don't need to space everything out to always fit 8 fields on the screen, so the padding between the fields can be the same on every device. If you want to show us an example of what's causing you issues, drop some code here (properly-formatted using the code formatting toolbar) and screenshots showing us the issue in the UI so we can visualise it.
Topic: Design SubTopic: General Tags:
Apr ’25
Reply to How to import large data from Server and save it to Swift Data
Do you know how much data is expected to be downloaded? If so, you could ensure the view doesn't update until the right amount of data is received and stored. If you don't know the quantity of data, you could add a Bool and toggle it when the data loading starts, then toggle it when the data has finished loading, so the View is only refreshed when the last of the data is stored. Another way would be to disable the UI so the user can't interact with it until the data has finished loading. The UI would update in the background, but the user wouldn't experience a slow UI as they can't interact with it anyway. You could put a partially-transparent View with a ProgressView in it at the top of a ZStack (which would be at the bottom of the ZStack in the code...) and hide it when you're done. I'll show you how I do it below. There's a few ways of doing it, but I don't think there's a built-in way to achieve this. But then, I'm not a genius on SwiftData, so... Using a blocking view: @State private var loadingData: Bool = false var body: some View { ZStack { // ... UI goes here // ... BlockingView() .additional().hidden(loadingData) // Hide the view when loading data == true } } struct BlockingView: View { var body: some View { ZStack { Rectangle() .fill(Color.black.opacity(0.2)) // Partially-transparent, but doesn't have to be ProgressView(label: { Label(title: { Text("Please Wait") }, icon: { Image(systemName: "exclamationmark.circle") }) }) .frame(width: 240, height: 100) .background(.ultraThickMaterial) .clipShape(RoundedRectangle(cornerRadius: 24)) .shadow(color: .black.opacity(0.3), radius: 4, x: 0, y: 0) } .ignoresSafeArea() } } /* This modifier is required because you can't conditionally hide a view with `.hidden()` but on the plus side, you can use this in tons of places, and add new modifiers like conditional shadows etc. */ public struct Additional<Content> { public let content: Content public init(_ content: Content) { self.content = content } } extension View { var additional: Additional<Self> { Additional(self) } } extension Additional where Content: View { @ViewBuilder func hidden(_ hide: Bool) -> some View { if(hide) { content.hidden() } else { content } } }
Apr ’25
Reply to Shadow-banned by design: the App Store visibility crisis for independent developers
These are the Developer Forums, where developers of third-party apps for Apple's platforms ask each other for hints and tips on coding. These forums are not where Apple's actual employee developers chat about what they're doing in the platform code. If you have a suggestion, you should raise it at: https://www.apple.com/feedback/ or https://feedbackassistant.apple.com/ and post the FB number here.
Apr ’25
Reply to Request for Rosetta: support optionally faster x87 emulation (via some env variable similar to AVX) like Rosettax87 project..
These are the Developer Forums, where developers of third-party apps for Apple's platforms ask each other for hints and tips on coding. These forums are not where Apple's actual developers chat about new features. If you have a suggestion, you should raise it at: https://www.apple.com/feedback/ or https://feedbackassistant.apple.com/ and post the FB number here.
Topic: App & System Services SubTopic: Core OS Tags:
Apr ’25
Reply to Extra Trailing Closure for List {}
I even removed my code and copy-pasted Apple's sample from here If you had done that, you wouldn't have those extra indents in the code (before every Text). When I paste it I get this: struct ContentView: View { var body: some View { List { Text("A List Item") Text("A Second List Item") Text("A Third List Item") } } } So, as @Claude31 says, you may have one or more non-printing characters in there.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’25
Reply to iOS18, certificates, mail app and domain
Sorry, what is your question for us not-employed-by-Apple, third-party developers who write third-party software for Apple's platforms? If you're just having a moan, sorry, but this isn't the place for that. These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. If you have a product support question I'd suggest you ask it over at the Apple Support Forums. If, however, you have a suggestion raise it at https://feedbackassistant.apple.com/ Thanks.
Topic: Community SubTopic: Apple Developers Tags:
Apr ’25
Reply to Xcode Build Failure
The error: The compiler is unable to type-check the expression in real-time generally means you're trying to do too many things in one place, and you should break it down a little. Firstly, to make it more readable, I'd put brackets around each ternary expression, for example: (row %2 == 0 ? Color.blue : Color.orange) so you can see which bits are enclosed. Then I'd split it out like this, creating a let for the various bits so they're individually evaluated prior to the larger expression. Also, I'd indent the code so it's more readable, putting the positive on the first line, and the negative on the next line, indented: let borderColor1 = (row %2 == 0 ? Color.blue : Color.orange) let borderColor2 = (shelterViewModel.getShelter(row: row, column: column).productId = ViewConstants.LAYOUT_DUMMY_ID ? Color.yellow : Color.green) .border( (shelterViewModel.getShelter0perationFormat() ? borderColor1 : (locationViewModel.getLocation(row: row, column: column) ? Color.red : borderColor2)), width: 0.5 //(self.interfaceLayout == ViewConstants.BACKEND_OPERATION ? 0.5 : 0.5) ) Finally, this bit at the end is pointless as the two values are the same: width: (self.interfaceLayout == ViewConstants.BACKEND_OPERATION ? 0.5 : 0.5) so you can replace it with 0.5, unless you're going to change one of those values?
Apr ’25
Reply to How do I use "views" and structures / what's wrong with my code?
We've already explained. A class contains variables and methods that act on those variables. For example, you might have a Ball class that contains x and y CGFloats for the position, and you'll have methods in the class that add/remove 1 to the values to move the ball's position, e.g.: class Ball { var x: CGFloat var y: CGFloat init(x: CGFloat, y: CGFloat) { self.x = x self.y = y } func moveRight() { x += 1 } func moveLeft() { x -= 1 } func moveUp() { y -= 1 } func moveDown() { y += 1 } } That's the class, all done. And to use it, you'd do this: let ball: Ball = Ball(x: 20, y: 50) redBall.moveDown() // redBall.y is now 51 redBall.moveLeft() // redBall.x is now 19 You've just posted code where lines 27, 29 and 31 create three instances of your Balls class inside the Balls class. That's not how it works. You should create those three instances of Balls outside of the class where you're going to use them. Then, despite @Claude31 giving you actual working code showing you where the 'struct Userview: View goes, you've ignored it completely, and put your UI code inside your Balls class. Then, you have a go at us for actually helping you and suggesting you don't use AI to learn coding. We are trying to help you, but if you don't take onboard any of our suggestions, why should we bother? I certainly aren't going to bother anymore.
Topic: UI Frameworks SubTopic: SwiftUI
Apr ’25
Reply to External Keyboard and Mouse Input Broken in iOS/iPadOS 18.4.1 — Apple and Third-Party Devices Affected (Magic Keyboard, Redragon K580RGBPRO, Razer Naga V2 Pro)
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.
Topic: Community SubTopic: Apple Developers Tags:
Apr ’25
Reply to Swift question:
There are tons of online resources to learn how to code in Swift. Apple's own sample code is extensive and allows you to follow along. https://developer.apple.com/swift/
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to How to implement this textfield in SwitfUI
Isn't it just a normal TextField? Maybe with a placeholder? Show us the code you've tried, properly-formatted with the code formatting tools in the toolbar.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to Is the MacBook Air sufficient for iOS Development
Yes. I was using an M1 MacBook Air 2020 with 16GB and 1TB SSD. Never had any issues. You're on the M4 chip. You'll be fine for years.
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to iPad/iPhone - Display best practices….
All my apps work on both the iPhone and iPad, but due to the amount of changes - some structural - that are required to get an iPhone version to look and work properly on the iPad, I use two different views: @main struct MainApp: App { // ... var body: some Scene { WindowGroup { if(UIDevice.current.userInterfaceIdiom == .pad) { TabletView() } else { PhoneView() } } } } So, if the user is using an iPhone, the PhoneView() is the main entry point. For iPads, it's TabletView(). The reason I did this is because the iPad has much more space and allows me to do more things, so the TabletView has more things in it. Also, I'd rather not have one big, unmanageable View full of if ... else statements and ternary operators. It also means your spacers and padding values apply only to that device type. Where the two views have similar UI, those bits are extracted into their own little View structs and called within those two main entry points. When you separate out the two views you may find you're duplicating some work, but you'll also be working on a view that only applies to an iPad or an iPhone and not both. You can make a change in the TabletView and be assured it hasn't affected the PhoneView, so you haven't got to retest that change on the iPhone. You can also then expand this to include Vision Pro, Apple TV, and any other device idioms Apple has or releases in future, and you won't need to add more and more if ... else and ternary operators in that one massive file. If you're having issues with specific models of an iPad or iPhone I'd say you're maybe using too many magic numbers in your code? You've probably found that the padding on an iPhone 13 mini for some label is 5, while on an iPhone 14 Plus it's 12 so you've written that in. You should rework this to align things naturally using SwiftUI's HStacks, YStacks etc. Or, have a consistent padding for your UI so that it looks the same on every device. Let's say you can fit 8 text fields vertically in a form on an iPhone 12 mini, and 10 on an iPhone 15 Pro, that's fine. You don't need to space everything out to always fit 8 fields on the screen, so the padding between the fields can be the same on every device. If you want to show us an example of what's causing you issues, drop some code here (properly-formatted using the code formatting toolbar) and screenshots showing us the issue in the UI so we can visualise it.
Topic: Design SubTopic: General Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to How to import large data from Server and save it to Swift Data
Do you know how much data is expected to be downloaded? If so, you could ensure the view doesn't update until the right amount of data is received and stored. If you don't know the quantity of data, you could add a Bool and toggle it when the data loading starts, then toggle it when the data has finished loading, so the View is only refreshed when the last of the data is stored. Another way would be to disable the UI so the user can't interact with it until the data has finished loading. The UI would update in the background, but the user wouldn't experience a slow UI as they can't interact with it anyway. You could put a partially-transparent View with a ProgressView in it at the top of a ZStack (which would be at the bottom of the ZStack in the code...) and hide it when you're done. I'll show you how I do it below. There's a few ways of doing it, but I don't think there's a built-in way to achieve this. But then, I'm not a genius on SwiftData, so... Using a blocking view: @State private var loadingData: Bool = false var body: some View { ZStack { // ... UI goes here // ... BlockingView() .additional().hidden(loadingData) // Hide the view when loading data == true } } struct BlockingView: View { var body: some View { ZStack { Rectangle() .fill(Color.black.opacity(0.2)) // Partially-transparent, but doesn't have to be ProgressView(label: { Label(title: { Text("Please Wait") }, icon: { Image(systemName: "exclamationmark.circle") }) }) .frame(width: 240, height: 100) .background(.ultraThickMaterial) .clipShape(RoundedRectangle(cornerRadius: 24)) .shadow(color: .black.opacity(0.3), radius: 4, x: 0, y: 0) } .ignoresSafeArea() } } /* This modifier is required because you can't conditionally hide a view with `.hidden()` but on the plus side, you can use this in tons of places, and add new modifiers like conditional shadows etc. */ public struct Additional<Content> { public let content: Content public init(_ content: Content) { self.content = content } } extension View { var additional: Additional<Self> { Additional(self) } } extension Additional where Content: View { @ViewBuilder func hidden(_ hide: Bool) -> some View { if(hide) { content.hidden() } else { content } } }
Replies
Boosts
Views
Activity
Apr ’25
Reply to iOS18, certificates, mail app and domain
Sorry, it's still not a developer question. You're asking for support with an app, not with how to write code. While your question may be technical, that doesn't mean only developers can answer it.
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to Shadow-banned by design: the App Store visibility crisis for independent developers
These are the Developer Forums, where developers of third-party apps for Apple's platforms ask each other for hints and tips on coding. These forums are not where Apple's actual employee developers chat about what they're doing in the platform code. If you have a suggestion, you should raise it at: https://www.apple.com/feedback/ or https://feedbackassistant.apple.com/ and post the FB number here.
Replies
Boosts
Views
Activity
Apr ’25
Reply to Request for Rosetta: support optionally faster x87 emulation (via some env variable similar to AVX) like Rosettax87 project..
These are the Developer Forums, where developers of third-party apps for Apple's platforms ask each other for hints and tips on coding. These forums are not where Apple's actual developers chat about new features. If you have a suggestion, you should raise it at: https://www.apple.com/feedback/ or https://feedbackassistant.apple.com/ and post the FB number here.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to Extra Trailing Closure for List {}
I even removed my code and copy-pasted Apple's sample from here If you had done that, you wouldn't have those extra indents in the code (before every Text). When I paste it I get this: struct ContentView: View { var body: some View { List { Text("A List Item") Text("A Second List Item") Text("A Third List Item") } } } So, as @Claude31 says, you may have one or more non-printing characters in there.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to Any have issue with passcode different on App Store vs on phone unlock
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
Apr ’25
Reply to iOS18, certificates, mail app and domain
Sorry, what is your question for us not-employed-by-Apple, third-party developers who write third-party software for Apple's platforms? If you're just having a moan, sorry, but this isn't the place for that. These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. If you have a product support question I'd suggest you ask it over at the Apple Support Forums. If, however, you have a suggestion raise it at https://feedbackassistant.apple.com/ Thanks.
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to Xcode project erros for other users maybe money if solved
No one on here is going to download and run a random .zip file, and we're not going to follow you on Discord. Sorry. If you ned help with coding or with your build errors, ask us a question on here. Tell us what the build errors are (not via screenshots), and we might be able to help. Finally, don't offer money. It's rude, and it will get you banned.
Replies
Boosts
Views
Activity
Apr ’25
Reply to Xcode Build Failure
The error: The compiler is unable to type-check the expression in real-time generally means you're trying to do too many things in one place, and you should break it down a little. Firstly, to make it more readable, I'd put brackets around each ternary expression, for example: (row %2 == 0 ? Color.blue : Color.orange) so you can see which bits are enclosed. Then I'd split it out like this, creating a let for the various bits so they're individually evaluated prior to the larger expression. Also, I'd indent the code so it's more readable, putting the positive on the first line, and the negative on the next line, indented: let borderColor1 = (row %2 == 0 ? Color.blue : Color.orange) let borderColor2 = (shelterViewModel.getShelter(row: row, column: column).productId = ViewConstants.LAYOUT_DUMMY_ID ? Color.yellow : Color.green) .border( (shelterViewModel.getShelter0perationFormat() ? borderColor1 : (locationViewModel.getLocation(row: row, column: column) ? Color.red : borderColor2)), width: 0.5 //(self.interfaceLayout == ViewConstants.BACKEND_OPERATION ? 0.5 : 0.5) ) Finally, this bit at the end is pointless as the two values are the same: width: (self.interfaceLayout == ViewConstants.BACKEND_OPERATION ? 0.5 : 0.5) so you can replace it with 0.5, unless you're going to change one of those values?
Replies
Boosts
Views
Activity
Apr ’25
Reply to How do I use "views" and structures / what's wrong with my code?
We've already explained. A class contains variables and methods that act on those variables. For example, you might have a Ball class that contains x and y CGFloats for the position, and you'll have methods in the class that add/remove 1 to the values to move the ball's position, e.g.: class Ball { var x: CGFloat var y: CGFloat init(x: CGFloat, y: CGFloat) { self.x = x self.y = y } func moveRight() { x += 1 } func moveLeft() { x -= 1 } func moveUp() { y -= 1 } func moveDown() { y += 1 } } That's the class, all done. And to use it, you'd do this: let ball: Ball = Ball(x: 20, y: 50) redBall.moveDown() // redBall.y is now 51 redBall.moveLeft() // redBall.x is now 19 You've just posted code where lines 27, 29 and 31 create three instances of your Balls class inside the Balls class. That's not how it works. You should create those three instances of Balls outside of the class where you're going to use them. Then, despite @Claude31 giving you actual working code showing you where the 'struct Userview: View goes, you've ignored it completely, and put your UI code inside your Balls class. Then, you have a go at us for actually helping you and suggesting you don't use AI to learn coding. We are trying to help you, but if you don't take onboard any of our suggestions, why should we bother? I certainly aren't going to bother anymore.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Apr ’25
Reply to External Keyboard and Mouse Input Broken in iOS/iPadOS 18.4.1 — Apple and Third-Party Devices Affected (Magic Keyboard, Redragon K580RGBPRO, Razer Naga V2 Pro)
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.
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
Apr ’25