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.
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 No preview when creating new project
Hello Andrea :) there seems to be a problem with the certificates. Try to go to the top left corner, click "Xcode", then go to "Settings" and then choose "Accounts". Your Apple-ID should be listed there. Click the button "Download Manual Profiles". Try to restart Xcode. Maybe it is working then. I hope, this might help.
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 :)
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.
Mar ’24