Post

Replies

Boosts

Views

Activity

SwiftUI iOS 17, Xcode 15.3 MapContentBuilder
I consistently get an error that the Map initailizer I'm using is deprecated and I should use a MapContent builder instead. Various errors such as "'MapAnnotation' was deprecated in iOS 17.0: Use Annotation along with Map initializers that take a MapContentBuilder instead." or "'init(coordinateRegion:interactionModes:showsUserLocation:userTrackingMode:annotationItems:annotationContent:)' was deprecated in iOS 17.0: Use Map initializers that take a MapContentBuilder instead." The problem in my code seems to be located here: import SwiftUI import MapKit struct ContentView: View { @State private var region = MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 34.0522, longitude: -118.2437), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5) ) @State private var restaurants: [Restaurant] = [] var body: some View { Map(coordinateRegion: $region, annotationItems: restaurants) { restaurant in // This uses the updated Annotation API MapAnnotation(coordinate: restaurant.coordinate) { VStack { Text(restaurant.restaurantName) .bold() .foregroundColor(.white) .padding(5) .background(Color.black.opacity(0.75)) .cornerRadius(10) .fixedSize() Image(systemName: "mappin.circle.fill") .foregroundColor(.red) .font(.title) } } The errors persistently occur in the lines immediately below var body: some View { I've been stuck on this for two days now. Any help would be greatly appreciated.
1
1
942
May ’24
Mapkit SwiftUI iOS17
I am trying to load and view several locations onto a map from a JSOPN file in my SwiftUI project, but I continually encounter the error "no exact matches in call to initializer" in my ContentView.swift file. What I Am Trying to Do: I am working on a SwiftUI project where I need to display several locations on a map. These locations are stored in a JSON file, which I have successfully loaded into Swift. My goal is to display these locations as annotations on a Map view. JSON File Contents: coordinates: latitude and longitude name: name of the location uuid: unique identifier for each location Code and Screenshots: Here are the relevant parts of my code and the error I keep encountering: import SwiftUI import MapKit struct ContentView: View { @State private var mapPosition = MapCameraPosition.region( MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194), span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05) ) ) @State private var features: [Feature] = [] var body: some View { NavigationView { Map(position: $mapPosition, interactionModes: .all, showsUserLocation: true) { ForEach(features) { feature in Marker(coordinate: feature.coordinate) { FeatureAnnotation(feature: feature) } } } .onAppear { POILoader.loadPOIs { result in switch result { case .success(let features): self.features = features case .failure(let error): print("Error loading POIs: \(error.localizedDescription)") } } } .navigationBarTitle("POI Map", displayMode: .inline) } } } struct FeatureAnnotation: View { let feature: Feature var body: some View { VStack { Circle() .strokeBorder(Color.red, lineWidth: 2) .background(Circle().foregroundColor(.red)) .frame(width: 20, height: 20) Text(feature.name) } } } I have not had any luck searching for solutions to my problems using the error messages that keep arising. Does anyone have any advice for how to move forward?
2
0
691
May ’24
"Multiple Commands Produce Info.plist" error in Xcode 15
I keep on getting the same error when trying to build my project. It seems to stem from a problem that I am having entering the path to the info.plist file in packaging/build settings. I have repeatedly tried to install the proper path as "$(SRCROOT)/Main Project Group/Info.plist", yet as soon as I hit return, the path reverts to "/Users/josephnicholas/Documents/dEATour/Xcode/dEATourSunday/Main Project Group/Info.plist" and I get the following error when I clean/build the project: "/Users/josephnicholas/Documents/dEATour/Xcode/dEATourSunday/dEATourSunday.xcodeproj One of the paths in DEVELOPMENT_ASSET_PATHS does not exist: /Users/josephnicholas/Documents/dEATour/Xcode/dEATourSunday/dEATourSunday/Preview Content". I have deleted the info.plist file and reinstalled it, I have even started a new project this morning, transferring all of my files. I cannot figure out how to prevent the path in 'packaging' from reverting back to the absolute path and throwing this error out. I'd really appreciate any help anyone can offer. Thanks.
3
0
855
May ’24
Importing json file and displaying POI's in Mapkit using Xcode 15 and swiftUI
Description: I am working on an iOS 17 app using Xcode 15 and SwiftUI. The app involves displaying points of interest (POIs) on a MapView based on user proximity and other factors such as hours of operation. The data for the POIs is stored in a JSON file, which I am trying to import and parse in the project. However, I have encountered several issues: Deprecation Errors: When attempting to use MapAnnotation, I receive deprecation warnings and errors. It seems that MapAnnotation has been deprecated in iOS 17, and I need to use the new Annotation API along with MapContentBuilder. RandomAccessCollection Conformance: Errors related to RandomAccessCollection conformance when using Map with SwiftUI. JSON Import and Parsing: I used Bundle.main.url(forResource: "locations", withExtension: "json") to load the JSON file but faced issues with correctly parsing and mapping the JSON data to my model objects. What I Need: Guidance on how to correctly use the new Annotation API and MapContentBuilder for displaying POIs on a MapView in iOS 17. Best practices for importing and parsing JSON files in SwiftUI, especially for dynamically updating the MapView based on user proximity and other criteria like hours of operation. Any relevant code snippets or examples would be greatly appreciated. Example of What We Tried Model: swift Copy code struct POI: Codable, Identifiable { let id: Int let name: String let latitude: Double let longitude: Double let hours: [String: String] } Loading JSON: swift Copy code func loadPOIs() -> [POI] { guard let url = Bundle.main.url(forResource: "locations", withExtension: "json"), let data = try? Data(contentsOf: url) else { return [] } let decoder = JSONDecoder() return (try? decoder.decode([POI].self, from: data)) ?? [] } Map View: swift Copy code import SwiftUI import MapKit struct ContentView: View { @State private var pois: [POI] = loadPOIs() @State private var region = MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 40.7128, longitude: -74.0060), span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05) ) var body: some View { Map(coordinateRegion: $region, annotationItems: pois) { poi in MapAnnotation(coordinate: CLLocationCoordinate2D(latitude: poi.latitude, longitude: poi.longitude)) { VStack { Text(poi.name) Circle().fill(Color.red).frame(width: 10, height: 10) } } } } } Issues Encountered: MapAnnotation is deprecated. Errors related to RandomAccessCollection conformance. Any advice or solutions for these issues would be greatly appreciated. Thank you!
1
0
654
Jun ’24
Xcode 15.4 import error: 'No such module' Error in multiple files
I'm encountering a persistent "No such module" error in Xcode 15. The error appears in one file at a time, but the behavior is unusual. Here's what happens: The error initially points to a missing module in a specific file (e.g., POILoader.swift) If I remove the line (or even comment out the import statement, the error jumps to another file (PlaceOfInterestDefinition.swift) that also imports the same module. We've attempted to troubleshoot using common solutions like checking file paths, build settings, and cleaning the project. Additional Information: We tried creating a custom xcconfig file to manage build settings, but the documentation on Apple's developer site seemed outdated for Xcode 15, making it difficult to complete. The error says "No such module 'PlaceOfInterestModule'. POILoader.swift PlaceOfInterestDefinition.swift I've even created a new project and rebuilt the project. I'm working on an app that will show places of interest on a map- but only the ones that are open when the user is using the app- these are two files that I'm working on that will determine whether or not to put them in the mapview or not.
1
1
465
Jun ’24
Xcode 15.4 import error: 'No such module' Error in multiple files (disregard prior post)
I'm encountering a persistent "No such module" error in Xcode 15. The error appears in one file at a time, but the behavior is unusual. Here's what happens: The error initially points to a missing module in a specific file (e.g., POILoader.swift) If I remove the line (or even comment out the import statement, the error jumps to another file (PlaceOfInterestAnnotationView swift) that also imports the same module. We've attempted to troubleshoot using common solutions like checking file paths, build settings, and cleaning the project. We tried creating a custom xcconfig file to manage build settings, as well as an objective c bridging header file but the documentation on Apple's developer site seemed outdated for Xcode 15, making it difficult to complete. I've even started from scratch in a new project and rebuilt completely. The error says "No such module 'PlaceOfInterestDefinition'. I've even created a new project and rebuilt the project. The app that will show places of interest on a map- but only the ones that are open when the user is using the app- these are two files that I'm working on that will determine whether or not to put the locations in the json file in the mapview at a specific time. POILoader.swift PlaceOfInterestDefinition.swift
0
0
338
Jun ’24
Xcode 15: Multiple Commands Produce Duplicate Info.plist Error
I am encountering a persistent issue in Xcode 15 where multiple commands produce a duplicate Info.plist error. The specific error message is: M u ltiple commands produce '/Users/josephnicholas/Library/Developer/Xcode/DerivedData/Restaurant_Build-bapndkzqxdjxxbacjwattbpeqof/Build/Products/Debug-iphoneos/Restaurant Build.app/Info.plist': Target 'Restaurant Build' (project 'Restaurant Build') has copy command from '/Users/josephnicholas/Desktop/backups/Restaurant Build/Supporting Files/Info.plist' to '/Users/josephnicholas/Library/Developer/Xcode/DerivedData/Restaurant_Build-bapndkzqxdjxxbacjwattbpeqof/Build/Products/Debug-iphoneos/Restaurant Build.app/Info.plist' Target 'Restaurant Build' (project 'Restaurant Build') has process command with output '/Users/josephnicholas/Library/Developer/Xcode/DerivedData/Restaurant_Build-bapndkzqxdjxxbacjwattbpeqof/Build/Products/Debug-iphoneos/Restaurant Build.app/Info.plist' Despite following numerous troubleshooting steps, including deleting the Info.plist file, cleaning the build folder, and creating a new project from scratch, the issue persists. I have ensured the Info.plist path is correctly set in the Build Settings under Packaging, and verified the file's target membership. However, the error remains unresolved. Here is a detailed list of the steps I have taken: Deleted the Derived Data multiple times. Restarted Xcode. Deleted the Info.plist file and re-added it through File > New File. Created a new project and manually copied all the files. Verified the Info.plist path and target membership. Followed suggestions from various forums, including adjusting paths and cleaning the build folder. Unfortunately, these steps have not resolved the issue. Attached are screenshots detailing the error messages and my current project setup. I would greatly appreciate any insights or solutions to this problem.
5
1
4.7k
Jun ’24
Xcode 15 build error Info.plist "error: Build input file cannot be found:..."
I've been trying to add an 'Info.plist' file this afternoon and get a recurring error that I haven't seen before. I see a lot of other people have posted similar errors over the time but I con't seen any solutions posted. I'd appreciate anyone reading this giving it a boost to perhaps have an engineer post a solution so others will not waste as much time on this as I have. . Info.plist has the proper path, I do not have a 'script phase' or 'custom build rule', and I don't know what "Did you forget to declare this file as an output of a script phase or custom build rule" means. I've had Info.plists before, I'm just not sure why I'm getting this error or how to bypass it.
1
0
2.2k
Jul ’24
Make Developer Forums Better!
Too many irrelevant posts come up when I attempt to search for something. There should be an easy button or something to earmark posts as something irrelevant- something that shouldn't come up in a search. I'm looking for something in Xcode 15 and frequently the top posts in the search are 10 years old and don't have any relevance whatsoever to the solution to my problem.
1
0
331
Jul ’24
Issue with MKLocalSearchCompleter Not Returning Results in iOS 17/Xcode 15
I'm currently developing an app using SwiftUI with Xcode 15 targeting iOS 17, and I'm running into an issue with the MKLocalSearchCompleter. I'm trying to implement a search functionality where the user can type in a query, and the app suggests relevant locations (e.g., typing "Balt" should suggest "Baltimore, MD"). However, the search results are not being displayed correctly in my app. The immediate goal here is for the app to present an option that matches the users destination, to then provide a choice of routes each route will then display locations from my json file that are along the route. When the user makes the final selection from the options presented by the autocompleter the map will pan out to show both the current location and the destination- and if there is a choice of routes they would be highlighted. Here are the steps I've taken: Implemented the MKLocalSearchCompleterDelegate to handle search suggestions. Configured resultTypes to include .address. Used the onChange modifier to trigger searches when the search text changes. Set up proper bindings and state management for the search term and results. The app seems to initiate the search, but the results aren't being populated as expected. Instead, I get "Displaying search results: 0" in the debugger, and no suggestions are shown on the device screen. Additionally, I'm seeing errors related to invalid numeric values being passed to CoreGraphics API in the debugger, which might be related to this issue. Has anyone else encountered this issue, or can anyone suggest what might be going wrong? Is there a known issue with MKLocalSearchCompleter in iOS 17 or any configuration that I might be missing? Here is the file that attempts to perform the action:
0
0
219
Aug ’24
how to setup info.plist
I accidentally deleted info.plist from the navigator menu and now i get two errors when I clean/build the project: Multiple commands produce '/Users/josephnicholas/Library/Developer/Xcode/DerivedData/ThAug1-dlmsxzducymrcmhdmtjuxjckqfxj/Build/Products/Debug-iphoneos/ThAug1.app/info.plist' and duplicate output file '/Users/josephnicholas/Library/Developer/Xcode/DerivedData/ThAug1-dlmsxzducymrcmhdmtjuxjckqfxj/Build/Products/Debug-iphoneos/ThAug1.app/info.plist' on task: CopyPlistFile /Users/josephnicholas/Library/Developer/Xcode/DerivedData/ThAug1-dlmsxzducymrcmhdmtjuxjckqfxj/Build/Products/Debug-iphoneos/ThAug1.app/info.plist /Users/josephnicholas/Desktop/backups/ThAug1/info.plist
1
0
279
Sep ’24
cannot find certificate signing request/Certificate Assistant
I've been working on creating a CSR for about two hours now and I cannot find a Certificate assistant anywhere. I can open up keychain access, on the left I have login and cloud and system and system roots. there are 6 submenus under keychain access: All Items, Passwords, Secure Notes, My Certificates, Keys, and Certificates. I have used the search menu to find both in the search bar 'Certificate Assistant" and also Certificate Signing Request, and neither is anywhere to be found. I've looked on the developer Account help, I've read several places what you are supposed to do, I've see the illustrations where you enter the email and leave the CA email blank, I just can't find it anywhere around Keychain access. It is really really well described on the Developer account help, and the eskimo makes it sound really easy too, only nothing appears in my keychain access. I've scrolled through all of the submenus trying to find it and it is nowhere to be fount. Any help would be much appreciated
3
0
290
Sep ’24
CoreData/Database question
I am working on an app that will have about 200mb of data in a database. I would like to install a json file with 3-4 mb on the phone with the app, and then be able to send small packets of information to the user of the app as they are using the app, for example if they hit a button with a link to an instagram page, I can have the database/server send the link to the app, it will be just small bits of information going from the database to the phone, and perhaps I would do some location tracking and getting some information from the user to build up personal preferences etc. I'm wondering if coredata would be the best way to get smaller packets of information to the phone quickly or if I should think about firebase or something else. I was interested in using Cloudkit, but it seems like Cloudkit is really more about syncing devices and for getting information from the user to the database. It's been really hard to find any information about the strengths versus weaknesses of different databases and how they interact with mobile apps.
0
0
172
Oct ’24