Post

Replies

Boosts

Views

Activity

Reply to Getting Preview Crashed with the Red X
I found the issue. I was calling ZStack(){ }allowsHitTesting(false) when maybe I should have. been calling ZStack() { }.allowsHitTesting(false) This seems like a bug to me. I believe that this should have been a compile error. I am new and learningSwiftUI developer and would like to better understand this issue Any Comments would be appreciated. Thanks
Dec ’23
Reply to Having issues with SwiftUI ForEach usage
I modified two structs to be Identifiable. I am testing this code in playground, but want this code in an SwiftUI App ... // MARK: - ApaResultElement struct ApaResultElement: Codable, Identifiable { var id: UUID = UUID() let data: DataClass } // MARK: - DataClass struct DataClass: Codable, Identifiable { var id: UUID = UUID() let viewer: Viewer let league: League Added this ForEach which compliles but throws exception let d1 = try decoder.decode([ApaResultElement].self, from: leagueView). // No Error... ForEach(d1, id: \.id) { schema in Text("\(schema.data.viewer.firstName)") } Error found => keyNotFound(CodingKeys(stringValue: "id", intValue: nil), Swift.DecodingError.Context(codingPath: [_JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: "id", intValue: nil) ("id").", underlyingError: nil)) Playground execution terminated: An error was thrown and was not caught: ▿ DecodingError ▿ keyNotFound : 2 elements - .0 : CodingKeys(stringValue: "id", intValue: nil) ▿ .1 : Context ▿ codingPath : 1 element ▿ 0 : _JSONKey(stringValue: "Index 0", intValue: 0) ▿ rep : Rep - index : 0 - debugDescription : "No value associated with key CodingKeys(stringValue: "id", intValue: nil) ("id")." - underlyingError : nil
Dec ’23
Reply to Warning: color asset name resolves to a conflicting Color symbol
I found an explanation on Hacking With Swift website. This web site is for Learning Swift and as far as I can see, it is a safe website which provided the solution to my issue. I am not able to post that link here. In my case the warning is destructive and causes runtime issues and also issue with the preview failing I have set flag to false and this appears to have resolved this runtime issue. What I read is this appears to be a feature added in xCode 15. This setting is found under Asset: Catalog Compiler - Options The switch is Generate Asset Symbols = false. It has a default of yes. When I have more time I will look deeper into this feature. I would have issues in my development style, if this was not a build setting. Thanks for any more details, if you happen to know more about this feature..
Jan ’24
Reply to Warning: color asset name resolves to a conflicting Color symbol
It works and no more issues. My current design is to reuse the RedColor so that I can maximize color set names. It is a design pattern. I wanted to reuse this simple name so that all applications might have access to these various color schemes. I suggest it is an ok design pattern to reuse color sets. I have a Color.swift extension that uses this name, and it allows me to write faster code and reuse these designs thruout my code base. I am a new Swift developer so it took my several hours to figure this out. I think this feature was added in 15.0
Jan ’24
Reply to How to use Map initializers Xcode15
wuminqi, I commented above and here is my example I played with. my view model appears to have no issues, but can not use it in a view to generate a Map(position: argument ) such as Map(position: vm.mapRegion) struct MapView: View { // load LocationViewModel Environment @Environment(LocationsViewModel.self) private var vm //@State private var cameraPos = vm.mapRegion // Cannot use instance member 'vm' within property initializer; property initializers run before 'self' is available //@State private var cameraPosition = MapCameraPosition.region(vm.mapRegion) // Cannot use instance member 'vm' within property initializer; property initializers run before 'self' is available @State private var cameraPosition = MapCameraPosition.region(MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 34.011286, longitude: -116.166868), span: MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2) )) var body: some View { Text(vm.mapLocation.name) .padding(5) //Text("center: \(vm.mapRegion.center.latitude), span: \( span: vm.mapRegion.mapSpan.)") Text("MapLocation: \(vm.mapLocation.region)") .padding(5) Text("Region.center: \(vm.mapLocation.region.center)") .padding(5) Text("Region.span: \(vm.mapLocation.region.span)") .padding(5) Text("Region: \(vm.mapRegion)") // Instance method 'appendInterpolation' requires that 'CLLocationCoordinate2D' conform to '_FormatSpecifiable' Spacer() // Map(position: MapCameraPosition.region(MKCoordinateRegion(center:vm.mapLocation.region.center, span: vm.mapLocation.region.span // Cannot convert value of type 'MapCameraPosition' to expected argument type 'Binding<MapCameraPosition>'))) // Map(position: MapCameraPosition.region(MKCoordinateRegion(center: vm.mapRegion.center, span: vm.mapSpan))) // Cannot convert value of type 'MapCameraPosition' to expected argument type 'Binding<MapCameraPosition>' //Map(position: MapCameraPosition.region(vm.mapRegion.)) //Cannot convert value of type 'MapCameraPosition' to expected argument type 'Binding<MapCameraPosition>' Map(position: $cameraPosition) } } code-block
Jul ’24
Reply to Ghost Complile Error and other odd project issues
In my investigation, I recreated a new Project and moved all the files to the new Project. The issues went away... I seem to have this type of issue occasionally.... This is frustrating to have to recreate projects I have also had the issue where I had a file like Something.swift cause an error where the compiler reported duplication file name in my Library Folder ... ? I delete it, but I wished I had saved the error message.....
Aug ’24
Reply to Ghost Complile Error and other odd project issues
I found that the difference in the Simulator View vs Preview is different in the recreated App also. I am using a Color Extension which may be reason. I will have to look at that also. Rebooting my Mac got rid of the ghost Error Message. I am assuming that it is some kind of cache issue. Restarting XCode did not resolve, so maybe the mac was caching the file Still have the issue with the Preview IPad NavigationSplitView having different colors than in my Preview Window. Here is the Code Segement var body: some View { NavigationSplitView(columnVisibility: .constant(.doubleColumn)) { VStack { Form { Section(header: Text("Admin Matainence").foregroundStyle(Color.theme.red).font(.subheadline)){ List { NavigationLink("Leagues", destination: SchemaDetail(schemaName: LeagueCategory.leagues, displayCategory: DisplayCategory.full)) NavigationLink("Sessions", destination: SchemaDetail(schemaName: LeagueCategory.sessions, displayCategory: DisplayCategory.full)) NavigationLink("Format", destination: SchemaDetail(schemaName: LeagueCategory.formats, displayCategory: DisplayCategory.full)) NavigationLink("Divisions", destination: SchemaDetail(schemaName: LeagueCategory.divisions, displayCategory: DisplayCategory.full)) NavigationLink("Teams", destination: SchemaDetail(schemaName: LeagueCategory.teams, displayCategory: DisplayCategory.full)) NavigationLink("Players", destination: SchemaDetail(schemaName: LeagueCategory.players, displayCategory: DisplayCategory.full)) NavigationLink("Match", destination: SchemaDetail(schemaName: LeagueCategory.matches, displayCategory: DisplayCategory.full)) NavigationLink("Game", destination: SchemaDetail(schemaName: LeagueCategory.games, displayCategory: DisplayCategory.full)) NavigationLink("Score Sheet", destination: SchemaDetail(schemaName: LeagueCategory.scoreSheets, displayCategory: DisplayCategory.full)) NavigationLink("Test Data", destination: DivisionSessionTeamsTournamentsView()) } } //.backgroundColor(.gray) } //.foregroundColor(.theme.accent) } .navigationTitle("Wildcards Admin") .padding() //.background(Color.theme.background) } detail: { } // Balanced Style keep sidebar open .navigationSplitViewStyle(.balanced) } } #Preview { ContentView() .environment(ApplicationData()) } so on the simulator the List Row Background is red on the preview it is a gray color. The Toolbar in both the simulator and preview have the red color on the toolbar icons. If I do not get a response by Friday, I will have to just live with it. I am closing this issue, as I am new to working with the NavigationSplitView on the Mac.
Aug ’24