Post

Replies

Boosts

Views

Activity

Reply to Invalid Bundle ID for container
I had the same issue, the bug still exists. But you can go to "Signing & Capabilities" in Xcode. Uncheck the "CloudKit" button under the iCloud section, save the project and check the button again. Then choose your container again. That fixes the issue. Additionally make sure that the name of your model doesn't already exist in your container as a RecordType to prevent unexpected errors again.
Feb ’24
Reply to Notification disappears after 5 seconds.
Hello :) okay, that‘s interesting, thank you for the information :) Maybe when you test it on another device it might work without performing that settings action. Furthermore you should completely delete and reinstall the application after changing the completionHandler method. Maybe you have done that already, otherwise you can try it. All in all there must be a way, because it has to work programmaticly.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’24
Reply to Var of type color inside swift data model
Hello :) SwiftData only supports primitive types (Int, Bool, ...) currently, so there is no possibility to save a color itself at the moment. In order to save a color you can choose different approaches. For example, you could define a SwiftData Model to save the different values of red, green, blue and alpha like this: final class ColorModel { var red: CGFloat var green: CGFloat var blue: CGFloat var alpha: CGFloat init(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) { self.red = red self.green = green self.blue = blue self.alpha = alpha } } Then you can display your colors through the following code (simplified here in a ForEach(), has to be adjusted): ForEach(colors, id: \.self) { color in Color(UIColor(red: color.red, green: color.green, blue: color.blue, alpha: color.alpha)) } If you have any further questions, don't hesitate to ask. I hope I was able to help you.
Feb ’24
Reply to Maximise Image above Form
Hello :) That's a really interesting question. I tried many things but I only found two different approaches. The problem is, you don't get the form's height itself in any way because a form always takes as much vertical space as it gets. So that's why you could fix the height of the image, so that there is enough space for the form with its content. The drawback of this solution is, that if the content in the form gets more and more, it's not visible anymore when it gets too much. It would be something like: Image(systemName: "gear") .resizable() .scaledToFit() Form { Section("section 1") { Text("text 1") Text("text 2") Text("text 3") } Section("section 2") { Text("text 1") Text("text 2") Text("text 3") } } .scrollDisabled(true) .frame(height: 500) //added the .frame() modifier Another approach would be to not use the Form. By using a normal VStack with the .layoutPriority() modifier the image gets maximized dynamically and the VStack adjusts its height itself. The advantage is that you can fill the VStack with any content you want and the image resizes itself. Example would be: Image(systemName: "gear") .resizable() .scaledToFit() VStack { ForEach(1..<9) { value in HStack { Text("Test + " + value.description) Spacer() } .padding(.leading) .padding(.bottom, 4) } } .layoutPriority(1) //very important, otherwise it won't work Maybe someone else found another solution but I think the second approach might be the best way to start in order to see everything good and adjusted on any device. If you have any further questions, don't hesitate to ask :)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’24
Reply to Using .environment() for Observable Object
Hello :) I would recommend you to use the .environment(). Therefore you create one instance of your ViewModel in order to handle it through the hierarchy to be accessible whenever it is necessary. Apple shows us with this example: @main struct BookReaderApp: App { @State private var library = Library() var body: some Scene { WindowGroup { LibraryView() .environment(library) } } } And for the LibraryView(): struct LibraryView: View { @Environment(Library.self) private var library var body: some View { List(library.books) { book in BookView(book: book) } } } You can find more information here. If you have any further questions don’t hesitate to ask.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’24
Reply to Invalid Bundle ID for container
I had the same issue, the bug still exists. But you can go to "Signing & Capabilities" in Xcode. Uncheck the "CloudKit" button under the iCloud section, save the project and check the button again. Then choose your container again. That fixes the issue. Additionally make sure that the name of your model doesn't already exist in your container as a RecordType to prevent unexpected errors again.
Replies
Boosts
Views
Activity
Feb ’24
Reply to Notification disappears after 5 seconds.
Hello :) I think the completionHandler with the option .banner might be a problem. Banners disappear after a few seconds no matter if the application is running or not. I can't test it right now, but it might work with completionHandler([.alert, .badge, .sound]).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’24
Reply to Notification disappears after 5 seconds.
Hello :) okay, that‘s interesting, thank you for the information :) Maybe when you test it on another device it might work without performing that settings action. Furthermore you should completely delete and reinstall the application after changing the completionHandler method. Maybe you have done that already, otherwise you can try it. All in all there must be a way, because it has to work programmaticly.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’24
Reply to Var of type color inside swift data model
Hello :) SwiftData only supports primitive types (Int, Bool, ...) currently, so there is no possibility to save a color itself at the moment. In order to save a color you can choose different approaches. For example, you could define a SwiftData Model to save the different values of red, green, blue and alpha like this: final class ColorModel { var red: CGFloat var green: CGFloat var blue: CGFloat var alpha: CGFloat init(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) { self.red = red self.green = green self.blue = blue self.alpha = alpha } } Then you can display your colors through the following code (simplified here in a ForEach(), has to be adjusted): ForEach(colors, id: \.self) { color in Color(UIColor(red: color.red, green: color.green, blue: color.blue, alpha: color.alpha)) } If you have any further questions, don't hesitate to ask. I hope I was able to help you.
Replies
Boosts
Views
Activity
Feb ’24
Reply to I am having trouble with my Team/Bundle Identifier and the iOS box right under it in Signing & Capabilities
Hello :) you can check this post, someone else had the exact same issue. If you have further questions, don’t hesitate to ask :)
Replies
Boosts
Views
Activity
Feb ’24
Reply to navigationDestination does not work
Hello :) You just need to embed your whole VStack (so everything inside the var body: some View {}) into a NavigationStack, then it works. If you have further questions, don't hesitate to ask :)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’24
Reply to Where is the Web entry for app iCloud SDK
Hello :) Here is the link for the CloudKit Console. There you can manage all your iCloud stuff like containers. There is still no way to delete CloudKit containers. So the only opportunity is to hide them as you already did. If you have further questions, don't hesitate to ask :)
Replies
Boosts
Views
Activity
Feb ’24
Reply to So in ios 17, I stored the login information in NSUserDefaults, and I opened the App again and the login information disappeared
Hello :) Can you share the piece of code to see where the problem might appear? Do you save the information locally or synchronized with CloudKit?
Replies
Boosts
Views
Activity
Feb ’24
Reply to Swift if statement with multiple conditions
Hello :) Yes, both syntaxes are equivalent. The only difference is that if a>b, c>d is evaluated as two separate expressions and if a>b && c>d is treated as one whole expression :)
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Feb ’24
Reply to Maximise Image above Form
Hello :) That's a really interesting question. I tried many things but I only found two different approaches. The problem is, you don't get the form's height itself in any way because a form always takes as much vertical space as it gets. So that's why you could fix the height of the image, so that there is enough space for the form with its content. The drawback of this solution is, that if the content in the form gets more and more, it's not visible anymore when it gets too much. It would be something like: Image(systemName: "gear") .resizable() .scaledToFit() Form { Section("section 1") { Text("text 1") Text("text 2") Text("text 3") } Section("section 2") { Text("text 1") Text("text 2") Text("text 3") } } .scrollDisabled(true) .frame(height: 500) //added the .frame() modifier Another approach would be to not use the Form. By using a normal VStack with the .layoutPriority() modifier the image gets maximized dynamically and the VStack adjusts its height itself. The advantage is that you can fill the VStack with any content you want and the image resizes itself. Example would be: Image(systemName: "gear") .resizable() .scaledToFit() VStack { ForEach(1..<9) { value in HStack { Text("Test + " + value.description) Spacer() } .padding(.leading) .padding(.bottom, 4) } } .layoutPriority(1) //very important, otherwise it won't work Maybe someone else found another solution but I think the second approach might be the best way to start in order to see everything good and adjusted on any device. If you have any further questions, don't hesitate to ask :)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’24
Reply to AppStore Preview stuck in "This file has been uploaded and is processing"
Hello :) I don’t have a solution for that but I had the exact same issue. It uploaded after I deleted the previews and tried it again but I think you might have already tried that.
Replies
Boosts
Views
Activity
Feb ’24
Reply to Install Xcode iOS hard without AppleStore etc
Hello :) One opportunity might be to connect your iPhone to your Mac. Simply by choosing your iPhone as a run device and executing, Xcode will install your application on your device. After that you can use your application. If you have any further questions, don’t hesitate to ask :)
Replies
Boosts
Views
Activity
Mar ’24
Reply to Using .environment() for Observable Object
Hello :) I would recommend you to use the .environment(). Therefore you create one instance of your ViewModel in order to handle it through the hierarchy to be accessible whenever it is necessary. Apple shows us with this example: @main struct BookReaderApp: App { @State private var library = Library() var body: some Scene { WindowGroup { LibraryView() .environment(library) } } } And for the LibraryView(): struct LibraryView: View { @Environment(Library.self) private var library var body: some View { List(library.books) { book in BookView(book: book) } } } You can find more information here. If you have any further questions don’t hesitate to ask.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’24