

{"id":115595,"date":"2023-07-10T10:21:44","date_gmt":"2023-07-10T04:51:44","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=115595"},"modified":"2026-06-01T14:32:38","modified_gmt":"2026-06-01T09:02:38","slug":"swift-cab-booking-app","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/","title":{"rendered":"Swift Cab Booking App \u2013 Ride with Ease, Book with Confidence"},"content":{"rendered":"<p>In this project, we will learn how to create a Cab Booking app using SwiftUI and Firebase Firestore. The app will allow users to book a cab by selecting their source and destination locations on a map. We will use MapKit for location and map services and Firebase Firestore to store the booking details.<\/p>\n<h3>About Swift Cab Booking App Project<\/h3>\n<p>The objective of this project is to create a fully functional Cab Booking app that allows users to book cabs by selecting source and destination locations on a map. The app will store the booking details in Firebase Firestore.<\/p>\n<h3>Prerequisites for Cab Booking App Project using Swift<\/h3>\n<p>To follow along with this project, you need the following:<\/p>\n<ul>\n<li>Xcode 12 or later installed on your Mac.<\/li>\n<li>Basic knowledge of SwiftUI and Swift programming language.<\/li>\n<li>An active Firebase account and a new Firestore project set up.<\/li>\n<\/ul>\n<h3>Download Swift Cab Booking App Project<\/h3>\n<p>Please download the source code of Swift Cab Booking App from the following link: <a href=\"https:\/\/drive.google.com\/file\/d\/1LWWNmxrGf7VVN1SQ78v98d6HZ4U3oLji\/view?usp=drive_link\"><strong>Swift Cab Booking App Project Code.<\/strong><\/a><\/p>\n<h3>Steps to Create a Cab Booking App Project Using Swift<\/h3>\n<p><strong>Step 1:<\/strong> Create a new SwiftUI project in Xcode.<\/p>\n<p><strong>Step 2:<\/strong> Set Up Firebase Firestore<\/p>\n<p><strong>Step 3:<\/strong> Designing the MapView<\/p>\n<p><strong>Step 4:<\/strong> Designing the SearchView<\/p>\n<p><strong>Step 5:<\/strong> Designing the BookedView<\/p>\n<p><strong>Step 6:<\/strong> Designing the Loader View<\/p>\n<p><strong>Step 7:<\/strong> Designing the Home View<\/p>\n<p><strong>Step 8:<\/strong> Connecting Views in ContentView<\/p>\n<h4>Step 1: Create a new SwiftUI project in Xcode.<\/h4>\n<p><strong>a.<\/strong> Open Xcode and click on the \u201cCreate a new Xcode Project\u201d option.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/create-a-new-xcode-project.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115801 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/create-a-new-xcode-project.webp\" alt=\"create a new xcode project\" width=\"1602\" height=\"887\" \/><\/a><\/p>\n<p><strong>b.<\/strong> Now select the platform as \u201ciOS\u201d and the application type as \u201cApp\u201d.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/application-type-as-app.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115802 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/application-type-as-app.webp\" alt=\"application type as app\" width=\"1460\" height=\"1034\" \/><\/a><\/p>\n<p><strong>c.<\/strong> Now, Enter the name of the app, and organization identifier, and select SwiftUI interface for `building the UI of the app. Also, select Swift as a language for creating the app.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/select-swiftui-interface.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115803 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/select-swiftui-interface.webp\" alt=\"select swiftui interface\" width=\"1472\" height=\"1052\" \/><\/a><\/p>\n<p><strong>d.<\/strong> Select the folder where you want to save the app and click on Create.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/save-the-app.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115804 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/save-the-app.webp\" alt=\"save the app\" width=\"1602\" height=\"1038\" \/><\/a><\/p>\n<p><strong>e.<\/strong> Now your project is ready for development, and you will see something like below.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/project-is-ready-for-development-scaled.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115805 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/project-is-ready-for-development-scaled.webp\" alt=\"project is ready for development\" width=\"2560\" height=\"1508\" \/><\/a><\/p>\n<h4>Step 2: Set Up Firebase Firestore<\/h4>\n<p><strong>a.<\/strong> Go to the<a href=\"https:\/\/console.firebase.google.com\/\"> Firebase console<\/a>\u00a0and create a new project.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/firebase-console-scaled.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115806 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/firebase-console-scaled.webp\" alt=\"firebase console\" width=\"2560\" height=\"1555\" \/><\/a><\/p>\n<p><strong>b.<\/strong> Complete All the Steps in the order it guides you to complete<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/complete-all-steps-scaled.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115807 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/complete-all-steps-scaled.webp\" alt=\"complete all steps\" width=\"2560\" height=\"1557\" \/><\/a><\/p>\n<p><strong>c.<\/strong> After Completing all the tasks, your project in Xcode will look like this.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/after-completing-all-tasks-scaled.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115808 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/after-completing-all-tasks-scaled.webp\" alt=\"after completing all tasks\" width=\"2560\" height=\"1483\" \/><\/a><\/p>\n<p><strong>d.<\/strong> Enable Firestore for your project by selecting the Firestore Database in then following the guide. Now your Firestore will be created and will look like below.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/enable-firebase-scaled.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115809 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/enable-firebase-scaled.webp\" alt=\"enable firebase for your project\" width=\"2560\" height=\"1551\" \/><\/a><\/p>\n<p>Make sure you have the necessary Firebase configurations added to your Xcode project.<\/p>\n<h4>Step 3: Designing the MapView<\/h4>\n<p><strong>a.<\/strong> Create a new Swift file called<strong> &#8220;MapView.swift&#8221;<\/strong> in your project.<br \/>\n<strong>b.<\/strong> Define a SwiftUI view named <strong>MapView<\/strong> as given below code.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import SwiftUI\r\nimport MapKit\r\nimport CoreLocation\r\nstruct MapView : UIViewRepresentable {\r\n    \r\n    \/\/ Create a coordinator to handle interactions between the MapView and the rest of the app\r\n    func makeCoordinator() -&gt; Coordinator {\r\n        return MapView.Coordinator(parent1: self)\r\n    }\r\n    \r\n    \/\/ Bindings to various properties that are used to update the UI\r\n    @Binding var map : MKMapView\r\n    @Binding var manager : CLLocationManager\r\n    @Binding var alert : Bool\r\n    @Binding var source : CLLocationCoordinate2D!\r\n    @Binding var destination : CLLocationCoordinate2D!\r\n    @Binding var name : String\r\n    @Binding var distance : String\r\n    @Binding var time : String\r\n    @Binding var show : Bool\r\n    \r\n    \/\/ Create the initial MapView\r\n    func makeUIView(context: Context) -&gt;  MKMapView {\r\n        \/\/ Set up the delegate and gesture recognizer\r\n        map.delegate = context.coordinator\r\n        manager.delegate = context.coordinator\r\n        map.showsUserLocation = true\r\n        let gesture = UITapGestureRecognizer(target: context.coordinator, action: #selector(context.coordinator.tap(ges:)))\r\n        map.addGestureRecognizer(gesture)\r\n        return map\r\n    }\r\n    \r\n    \/\/ Update the MapView\r\n    func updateUIView(_ uiView:  MKMapView, context: Context) {\r\n    }\r\n    \r\n    \/\/ The coordinator handles interactions between the MapView and the rest of the app\r\n    class Coordinator : NSObject,MKMapViewDelegate,CLLocationManagerDelegate{\r\n        \r\n        var parent : MapView\r\n        \r\n        init(parent1 : MapView) {\r\n            parent = parent1\r\n        }\r\n        \r\n        \/\/ Handle changes to the user's location authorization status\r\n        func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {\r\n            if status == .denied{\r\n                self.parent.alert.toggle()\r\n            }\r\n            else{\r\n                self.parent.manager.startUpdatingLocation()\r\n            }\r\n        }\r\n        \r\n        \/\/ Handle updates to the user's location\r\n        func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {\r\n            let region = MKCoordinateRegion(center: locations.last!.coordinate, latitudinalMeters: 10000, longitudinalMeters: 10000)\r\n            self.parent.source = locations.last!.coordinate\r\n            self.parent.map.region = region\r\n        }\r\n        \r\n        \/\/ Handle taps on the MapView\r\n        @objc func tap(ges: UITapGestureRecognizer){\r\n            let location = ges.location(in: self.parent.map)\r\n            let mplocation = self.parent.map.convert(location, toCoordinateFrom: self.parent.map)\r\n            \r\n            \/\/ Create a point annotation for the destination\r\n            let point = MKPointAnnotation()\r\n            point.subtitle = \"Destination\"\r\n            point.coordinate = mplocation\r\n            \r\n            \/\/ Update the destination and name properties\r\n            self.parent.destination = mplocation\r\n            let decoder = CLGeocoder()\r\n            decoder.reverseGeocodeLocation(CLLocation(latitude: mplocation.latitude, longitude: mplocation.longitude)) { (places, err) in\r\n                if err != nil{\r\n                    print((err?.localizedDescription)!)\r\n                    return\r\n                }\r\n                self.parent.name = places?.first?.name ?? \"\"\r\n                point.title = places?.first?.name ?? \"\"\r\n                self.parent.show = true\r\n            }\r\n            \r\n            \/\/ Calculate the directions between the source and destination\r\n            let req = MKDirections.Request()\r\n            req.source = MKMapItem(placemark: MKPlacemark(coordinate: self.parent.source))\r\n            req.destination = MKMapItem(placemark: MKPlacemark(coordinate: mplocation))\r\n            let directions = MKDirections(request: req)\r\n            directions.calculate { (dir, err) in\r\n                if err != nil{\r\n                    print((err?.localizedDescription)!)\r\n                    return\r\n                }\r\n                \r\n                \/\/ Update the distance and time properties\r\n                let polyline = dir?.routes[0].polyline\r\n                let dis = dir?.routes[0].distance as! Double\r\n                self.parent.distance = String(format: \"%.1f\", dis \/ 1000)\r\n                let time = dir?.routes[0].expectedTravelTime as! Double\r\n                self.parent.time = String(format: \"%.1f\", time \/ 60)\r\n                \r\n                \/\/ Add the polyline to the map\r\n                self.parent.map.removeOverlays(self.parent.map.overlays)\r\n                self.parent.map.addOverlay(polyline!)\r\n                self.parent.map.setRegion(MKCoordinateRegion(polyline!.boundingMapRect), animated: true)\r\n            }\r\n            \r\n            \/\/ Add the point annotation to the map\r\n            self.parent.map.removeAnnotations(self.parent.map.annotations)\r\n            self.parent.map.addAnnotation(point)\r\n        }\r\n        \r\n        \/\/ Render the polyline on the map\r\n        func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -&gt; MKOverlayRenderer {\r\n            let over = MKPolylineRenderer(overlay: overlay)\r\n            over.strokeColor = .red\r\n            over.lineWidth = 3\r\n            return over\r\n        }\r\n    }\r\n}<\/pre>\n<ul>\n<li>\u200b\u200bThe MapView struct is a <strong>UIViewRepresentable<\/strong> that wraps the<strong> MKMapView<\/strong> from <strong>MapKit<\/strong> to be used as a SwiftUI view.<\/li>\n<li>It defines several <strong>@Binding<\/strong> properties that allow communication between the SwiftUI view and the underlying MKMapView.<\/li>\n<li>The makeUIView function creates and configures the<strong> MKMapView<\/strong> instance.<\/li>\n<li>The updateUIView function is called when the view needs to be updated.<\/li>\n<li>The Coordinator class acts as the delegate for the <strong>MKMapView<\/strong> and <strong>CLLocationManager<\/strong> and handles various events and user interactions.<\/li>\n<\/ul>\n<h4>Step 4: Designing the SearchView<\/h4>\n<p><strong>a.<\/strong> Create a new Swift file called <strong>&#8220;SearchView.swift&#8221;<\/strong> in your project.<br \/>\n<strong>b.<\/strong> Define a SwiftUI view named <strong>SearchView<\/strong> as given below code.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import SwiftUI\r\nimport CoreLocation\r\nimport MapKit\r\nstruct SearchView: View {\r\n    \r\n    \/\/ State and Binding properties used in the view\r\n    @State var result : [SearchData] = []\r\n    @Binding var show : Bool\r\n    @Binding var map : MKMapView\r\n    @Binding var source : CLLocationCoordinate2D!\r\n    @Binding var destination : CLLocationCoordinate2D!\r\n    @Binding var name : String\r\n    @Binding var distance : String\r\n    @Binding var time : String\r\n    @State var txt = \"\"\r\n    @Binding var detail : Bool\r\n    \r\n    var body: some View {\r\n        \r\n        \/\/ A ZStack is used to layer views on top of each other\r\n        ZStack {\r\n            \r\n            \/\/ A gradient background color is added to the ZStack\r\n            LinearGradient(gradient: Gradient(colors: [.blue, .purple]), startPoint: .topLeading, endPoint: .bottomTrailing)\r\n                .edgesIgnoringSafeArea(.all)\r\n            \r\n            \/\/ A GeometryReader is used to get the size of the screen\r\n            GeometryReader{_ in\r\n                \r\n                \/\/ A VStack is used to stack views vertically\r\n                VStack{\r\n                    \r\n                    \/\/ A custom SearchBar view is added to the VStack\r\n                    SearchBar(map: self.$map, source: self.$source, destination: self.$destination, result: self.$result, name: self.$name, distance: self.$distance, time: self.$time,txt: self.$txt)\r\n                    \r\n                    \/\/ If there is text in the search bar, a list of search results is displayed\r\n                    if self.txt != \"\"{\r\n                        \r\n                        List(self.result){i in\r\n                            \r\n                            VStack(alignment: .leading){\r\n                                \r\n                                Text(i.name)\r\n                                \r\n                                Text(i.address)\r\n                                    .font(.caption)\r\n                            }\r\n                            .onTapGesture {\r\n                                \r\n                                \/\/ When a search result is tapped, the destination is updated and the map is updated\r\n                                self.destination = i.coordinate\r\n                                self.UpdateMap()\r\n                                self.show.toggle()\r\n                            }\r\n                        }\r\n                        .frame(height: UIScreen.main.bounds.height \/ 2)\r\n                    }\r\n                }\r\n                .padding(.horizontal, 25)\r\n            }\r\n            \/\/ A background color is added to the GeometryReader to dismiss the keyboard when tapped\r\n            .background(Color.black.opacity(0.2).edgesIgnoringSafeArea(.all)\r\n            .onTapGesture {\r\n                self.show.toggle()\r\n            })\r\n            \r\n            \/\/ If the detail property is true, a QRCodeView is displayed\r\n            if self.detail {\r\n                QRCodeView()\r\n            }\r\n        }\r\n    }\r\n    \r\n    \/\/ A function to update the map with the new destination\r\n    func UpdateMap(){\r\n        \r\n        \/\/ A point annotation is created for the destination\r\n        let point = MKPointAnnotation()\r\n        point.subtitle = \"Destination\"\r\n        point.coordinate = destination\r\n           \r\n        \/\/ A CLGeocoder is used to get the name of the destination\r\n        let decoder = CLGeocoder()\r\n        decoder.reverseGeocodeLocation(CLLocation(latitude: destination.latitude, longitude: destination.longitude)) { (places, err) in\r\n            \r\n            if err != nil{\r\n                \r\n                print((err?.localizedDescription)!)\r\n                return\r\n            }\r\n            \r\n            \/\/ The name of the destination is set as the title of the point annotation\r\n            self.name = places?.first?.name ?? \"\"\r\n            point.title = places?.first?.name ?? \"\"\r\n            \/\/ The detail property is set to true to display the QRCodeView\r\n            self.detail = true\r\n        }\r\n        \r\n        \/\/ A MKDirections.Request is created to get the route from the source to the destination\r\n        let req = MKDirections.Request()\r\n        req.source = MKMapItem(placemark: MKPlacemark(coordinate: self.source))\r\n        req.destination = MKMapItem(placemark: MKPlacemark(coordinate: destination))\r\n        \r\n        let directions = MKDirections(request: req)\r\n        \r\n        directions.calculate { (dir, err) in\r\n            \r\n            if err != nil{\r\n                \r\n                print((err?.localizedDescription)!)\r\n                return\r\n            }\r\n            \r\n            \/\/ The polyline for the route is added to the map\r\n            let polyline = dir?.routes[0].polyline\r\n            \r\n            \/\/ The distance and time for the route are calculated and set as properties\r\n            let dis = dir?.routes[0].distance as! Double\r\n            self.distance = String(format: \"%.1f\", dis \/ 1000)\r\n            \r\n            let time = dir?.routes[0].expectedTravelTime as! Double\r\n            self.time = String(format: \"%.1f\", time \/ 60)\r\n            \r\n            \/\/ The previous overlays are removed and the new polyline is added to the map\r\n            self.map.removeOverlays(self.map.overlays)\r\n            self.map.addOverlay(polyline!)\r\n            \r\n            \/\/ The map is centered on the polyline\r\n            self.map.setRegion(MKCoordinateRegion(polyline!.boundingMapRect), animated: true)\r\n        }\r\n        \r\n        \/\/ The previous annotations are removed and the new point annotation is added to the map\r\n        self.map.removeAnnotations(self.map.annotations)\r\n        self.map.addAnnotation(point)\r\n    }\r\n}\r\nstruct SearchBar : UIViewRepresentable {\r\n    \r\n    \/\/ Binding properties used in the view\r\n    @Binding var map : MKMapView\r\n    @Binding var source : CLLocationCoordinate2D!\r\n    @Binding var destination : CLLocationCoordinate2D!\r\n    @Binding var result : [SearchData]\r\n    @Binding var name : String\r\n    @Binding var distance : String\r\n    @Binding var time : String\r\n    @Binding var txt : String\r\n    \r\n    func makeCoordinator() -&gt; Coordinator {\r\n        \r\n        return SearchBar.Coordinator(parent1: self)\r\n    }\r\n    \r\n    func makeUIView(context: Context) -&gt; UISearchBar {\r\n        \r\n        \/\/ A UISearchBar is created and configured\r\n        let view = UISearchBar()\r\n        view.autocorrectionType = .no\r\n        view.autocapitalizationType = .none\r\n        view.delegate = context.coordinator\r\n        \r\n        return view\r\n    }\r\n    \r\n    func updateUIView(_ uiView:  UISearchBar, context: Context) {\r\n        \r\n        \r\n    }\r\n    \r\n    class Coordinator : NSObject,UISearchBarDelegate{\r\n        \r\n        var parent : SearchBar\r\n        \r\n        init(parent1 : SearchBar) {\r\n            \r\n            parent = parent1\r\n        }\r\n        \r\n        func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {\r\n            \r\n            \/\/ The text in the search bar is set as a property\r\n            self.parent.txt = searchText\r\n            \r\n            \/\/ A MKLocalSearch.Request is created to get the search results\r\n            let req = MKLocalSearch.Request()\r\n            req.naturalLanguageQuery = searchText\r\n            req.region = self.parent.map.region\r\n            \r\n            let search = MKLocalSearch(request: req)\r\n            \r\n            DispatchQueue.main.async {\r\n                \r\n                \/\/ The previous search results are removed\r\n                self.parent.result.removeAll()\r\n            }\r\n            \r\n            search.start { (res, err) in\r\n                \r\n                if err != nil{\r\n                    \r\n                    print((err?.localizedDescription)!)\r\n                    return\r\n                }\r\n                \r\n                \/\/ The search results are added to the result array\r\n                for i in 0..&lt;res!.mapItems.count{\r\n                    \r\n                    let temp = SearchData(id: i, name: res!.mapItems[i].name!, address: res!.mapItems[i].placemark.title!, coordinate: res!.mapItems[i].placemark.coordinate)\r\n                    \r\n                    self.parent.result.append(temp)\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\nstruct SearchData : Identifiable {\r\n    \r\n    \/\/ Properties for the search data\r\n    var id : Int\r\n    var name : String\r\n    var address : String\r\n    var coordinate : CLLocationCoordinate2D\r\n}\r\nstruct QRCodeView: View {\r\n    var body: some View {\r\n        \r\n        \/\/ A view to display the QR code\r\n        ZStack {\r\n            Color.white\r\n            Text(\"QR Code\")\r\n                .font(.title)\r\n        }\r\n        .frame(width: 200, height: 200)\r\n        .cornerRadius(10)\r\n        .shadow(radius: 10)\r\n    }\r\n}<\/pre>\n<ul>\n<li>The <strong>SearchView<\/strong> struct represents the search view used to search for locations.<\/li>\n<li>It contains several <strong>@Binding<\/strong> properties to manage the state of the search process and the selected location.<\/li>\n<li>The view consists of a<strong> LinearGradient<\/strong> background and a<strong> SearchBar<\/strong> component that allows the user to enter a search query.<\/li>\n<li>The search results are displayed in a List based on the user&#8217;s query.<\/li>\n<li>When the user selects a location from the list, the <strong>UpdateMap<\/strong> function is called to update the map view with the selected location.<\/li>\n<\/ul>\n<h4>Step 5: Designing the BookedView<\/h4>\n<p><strong>a.<\/strong> Create a new Swift file called <strong>&#8220;BookedView.swift&#8221;<\/strong> in your project.<br \/>\n<strong>b.<\/strong> Define a SwiftUI view named <strong>BookedView<\/strong> as given below code.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import SwiftUI\r\nimport Firebase\r\nstruct Booked : View {\r\n    \r\n    \/\/ Binding properties that are passed in from the parent view\r\n    @Binding var data : Data\r\n    @Binding var doc : String\r\n    @Binding var loading : Bool\r\n    @Binding var book : Bool\r\n    \r\n    var body: some View{\r\n        \r\n        \/\/ A ZStack is used to layer views on top of each other\r\n        ZStack{\r\n            \r\n            \/\/ A white background color is added to the ZStack\r\n            Color.white\r\n            \r\n            \/\/ A VStack is used to stack views vertically\r\n            VStack{\r\n                \r\n                \/\/ A Spacer is added to center the QR code\r\n                Spacer()\r\n                \r\n                \/\/ An image view is created with the QR code data\r\n                Image(uiImage: UIImage(data: self.data)!)\r\n                    .resizable()\r\n                    .frame(width: 250, height: 250)\r\n                \r\n                \/\/ A text label is added to display the booking ID\r\n                Text(\"Booking ID : \\(self.doc)\")\r\n                    .fontWeight(.bold)\r\n                    .padding(.top)\r\n                \r\n                \/\/ Another Spacer is added to push the button to the bottom of the screen\r\n                Spacer()\r\n                \r\n                \/\/ A button is added to cancel the booking\r\n                Button(action: {\r\n                    \r\n                    \/\/ The loading and book properties are toggled\r\n                    self.loading.toggle()\r\n                    self.book.toggle()\r\n                    \/\/ A reference to the Firestore database is created\r\n                    let db = Firestore.firestore()\r\n                    \/\/ The document with the specified ID is deleted\r\n                    db.collection(\"Booking\").document(self.doc).delete { (err) in\r\n                        if err != nil{\r\n                            \/\/ If there is an error, it is printed to the console\r\n                            print((err?.localizedDescription)!)\r\n                            return\r\n                        }\r\n                    \/\/ The loading property is toggled again\r\n                    self.loading.toggle()\r\n                    }\r\n                }) {\r\n                    \r\n                    \/\/ The button text is added\r\n                    Text(\"Cancel\")\r\n                        .foregroundColor(.white)\r\n                        .padding(.vertical, 10)\r\n                        .frame(width: UIScreen.main.bounds.width \/ 2)\r\n                }\r\n                \/\/ The button is styled with a gradient background, white text, and a capsule shape\r\n                .background(LinearGradient(gradient: Gradient(colors: [.blue, .purple]), startPoint: .leading, endPoint: .trailing))\r\n                .clipShape(Capsule())\r\n                .padding(.top, 25)\r\n            }\r\n            .padding()\r\n        }\r\n    }\r\n}<\/pre>\n<ul>\n<li>The Booked struct represents the view displayed after a successful booking.<\/li>\n<li>It displays the generated QR code for the booking ID and provides a &#8220;Cancel&#8221; button to cancel the booking.<\/li>\n<li>When the cancel button is tapped, the loading and book state properties are toggled, and the booking is deleted from the Firestore database.<\/li>\n<\/ul>\n<h4>Step 6: Designing the Loader View<\/h4>\n<p><strong>a.<\/strong> Create a new Swift file called <strong>&#8220;Loader.swift&#8221;<\/strong> in your project.<br \/>\n<strong>b.<\/strong> Define a SwiftUI view named<strong> Loader view<\/strong> as given below code.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import SwiftUI\r\nstruct Loader : View {\r\n    \r\n    \/\/ A state property that toggles the animation\r\n    @State var show = false\r\n    \r\n    var body: some View{\r\n        \r\n        \/\/ A GeometryReader is used to get the size of the parent view\r\n        GeometryReader{_ in\r\n            \r\n            \/\/ A VStack is used to stack views vertically\r\n            VStack(spacing: 20){\r\n                \r\n                \/\/ A Circle view is created with a red stroke\r\n                Circle()\r\n                    .trim(from: 0, to: 0.7)\r\n                    .stroke(Color.red, style: StrokeStyle(lineWidth: 4, lineCap: .round))\r\n                    .frame(width: 30, height: 30)\r\n                    .rotationEffect(.init(degrees: self.show ? 360 : 0))\r\n                    .onAppear {\r\n                        \r\n                        \/\/ The Circle view is animated using a repeatForever animation\r\n                        withAnimation(Animation.default.speed(0.45).repeatForever(autoreverses: false)){\r\n                            \r\n                            self.show.toggle()\r\n                        }\r\n                }\r\n                \r\n                \/\/ A text label is added to display a loading message\r\n                Text(\"Please Wait....\")\r\n            }\r\n            .padding(.vertical, 25)\r\n            .padding(.horizontal, 40)\r\n            .background(Color.white)\r\n            .cornerRadius(12)\r\n        }\r\n        .background(Color.black.opacity(0.25).edgesIgnoringSafeArea(.all))\r\n    }\r\n}<\/pre>\n<ul>\n<li>The<strong> Loader<\/strong> struct represents a loading indicator view.<\/li>\n<li>It displays a rotating circle and a <strong>&#8220;Please Wait&#8230;&#8221;<\/strong> text.<\/li>\n<li>The rotation animation is achieved using the show state property and SwiftUI&#8217;s <strong>withAnimation<\/strong> function.<\/li>\n<\/ul>\n<h4>Step 7: Designing the Home View<\/h4>\n<p><strong>a.<\/strong> Create a new Swift file called <strong>&#8220;Home.swift&#8221;<\/strong> in your project.<br \/>\n<strong>b.<\/strong> Define a SwiftUI view named <strong>Home view<\/strong> as given below code.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import SwiftUI\r\nimport MapKit\r\nimport CoreLocation\r\nimport Firebase\r\nstruct Home : View {\r\n    \r\n    \/\/ Map view and location manager\r\n    @State var map = MKMapView()\r\n    @State var manager = CLLocationManager()\r\n    \r\n    \/\/ Alert for location permission\r\n    @State var alert = false\r\n    \r\n    \/\/ Coordinates for source and destination\r\n    @State var source : CLLocationCoordinate2D!\r\n    @State var destination : CLLocationCoordinate2D!\r\n    \r\n    \/\/ Name of destination\r\n    @State var name = \"\"\r\n    \r\n    \/\/ Distance and time to destination\r\n    @State var distance = \"\"\r\n    @State var time = \"\"\r\n    \r\n    \/\/ Show booking details\r\n    @State var show = false\r\n    \r\n    \/\/ Show loading indicator\r\n    @State var loading = false\r\n    \r\n    \/\/ Show booking confirmation\r\n    @State var book = false\r\n    \r\n    \/\/ Document ID for booking\r\n    @State var doc = \"\"\r\n    \r\n    \/\/ QR code data for booking\r\n    @State var data : Data = .init(count: 0)\r\n    \r\n    \/\/ Show search view\r\n    @State var search = false\r\n    \r\n    var body: some View{\r\n        \r\n        ZStack{\r\n            \r\n            ZStack(alignment: .bottom){\r\n                \r\n                VStack(spacing: 0){\r\n                    \r\n                    HStack{\r\n                        \r\n                        VStack(alignment: .leading, spacing: 15) {\r\n                            \r\n                            \/\/ Show destination or pick a location\r\n                            Text(self.destination != nil ? \"Destination\" : \"Pick a Location\")\r\n                                .font(.title)\r\n                            \r\n                            if self.destination != nil{\r\n                                \r\n                                \/\/ Show name of destination\r\n                                Text(self.name)\r\n                                    .fontWeight(.bold)\r\n                            }\r\n                        }\r\n                        \r\n                        Spacer()\r\n                        \r\n                        \/\/ Show search button\r\n                        Button(action: {\r\n                            \r\n                            self.search.toggle()\r\n                            \r\n                        }) {\r\n                            \r\n                            Image(systemName: \"magnifyingglass\")\r\n                                .foregroundColor(.black)\r\n                        }\r\n                        \r\n                    }\r\n                    .padding()\r\n                    .padding(.top, UIApplication.shared.windows.first?.safeAreaInsets.top)\r\n                    .background(Color.white)\r\n                    \r\n                    \/\/ Show map view\r\n                    MapView(map: self.$map, manager: self.$manager, alert: self.$alert, source: self.$source, destination: self.$destination, name: self.$name,distance: self.$distance,time: self.$time, show: self.$show)\r\n                    .onAppear {\r\n                    \r\n                        \/\/ Request location permission\r\n                        self.manager.requestAlwaysAuthorization()\r\n                            \r\n                    }\r\n                    .ignoresSafeArea(.all)\r\n                }\r\n                \r\n                if self.destination != nil &amp;&amp; self.show{\r\n                    \r\n                    ZStack(alignment: .topTrailing){\r\n                        \r\n                        VStack(spacing: 20){\r\n                            \r\n                            HStack{\r\n                                \r\n                                VStack(alignment: .leading,spacing: 15){\r\n                                    \r\n                                    \/\/ Show destination name, distance and time\r\n                                    Text(\"Destination\")\r\n                                        .fontWeight(.bold)\r\n                                    Text(self.name)\r\n                                    \r\n                                    Text(\"Distance - \"+self.distance+\" KM\")\r\n                                    \r\n                                    Text(\"Expexted Time - \"+self.time + \"Min\")\r\n                                }\r\n                                \r\n                                Spacer()\r\n                            }\r\n                            \r\n                            \/\/ Show book now button\r\n                            Button(action: {\r\n                                \r\n                                self.loading.toggle()\r\n                                \r\n                                self.Book()\r\n                                \r\n                            }) {\r\n                                \r\n                                Text(\"Book Now\")\r\n                                    .foregroundColor(.white)\r\n                                    .padding(.vertical, 10)\r\n                                    .frame(width: UIScreen.main.bounds.width \/ 2)\r\n                            }\r\n                            .background(LinearGradient(gradient: Gradient(colors: [.blue, .purple]), startPoint: .leading, endPoint: .trailing))\r\n                            .clipShape(Capsule())\r\n                        \r\n                        }\r\n                        \r\n                        \/\/ Show close button\r\n                        Button(action: {\r\n                            \r\n                            self.map.removeOverlays(self.map.overlays)\r\n                            self.map.removeAnnotations(self.map.annotations)\r\n                            self.destination = nil\r\n                            \r\n                            self.show.toggle()\r\n                            \r\n                        }) {\r\n                            \r\n                            Image(systemName: \"xmark\")\r\n                                .foregroundColor(.black)\r\n                        }\r\n                    }\r\n                    .padding(.vertical, 10)\r\n                    .padding(.horizontal)\r\n                    .padding(.bottom, UIApplication.shared.windows.first?.safeAreaInsets.bottom)\r\n                    .background(Color.white)\r\n                    .cornerRadius(20)\r\n                    .overlay(\r\n                        RoundedRectangle(cornerRadius: 20)\r\n                            .stroke(Color.black, lineWidth: 1)\r\n                    )\r\n                    .padding(.horizontal, 20)\r\n                }\r\n            }\r\n            \r\n            \/\/ Show loading indicator\r\n            if self.loading{\r\n                \r\n                Loader()\r\n            }\r\n            \r\n            \/\/ Show booking confirmation\r\n            if self.book{\r\n                \r\n                Booked(data: self.$data, doc: self.$doc, loading: self.$loading, book: self.$book)\r\n            }\r\n            \r\n            \/\/ Show search view\r\n            if self.search{\r\n                \r\n                SearchView(show: self.$search, map: self.$map, source: self.$source, destination: self.$destination, name: self.$name, distance: self.$distance, time: self.$time,detail: self.$show)\r\n            }\r\n        }\r\n        .alert(isPresented: self.$alert) { () -&gt; Alert in\r\n            \r\n            \/\/ Show location permission error\r\n            Alert(title: Text(\"Error\"), message: Text(\"Please Enable Location In Settings !!!\"), dismissButton: .destructive(Text(\"Ok\")))\r\n        }\r\n    }\r\n    \r\n    \/\/ Book a ride\r\n    func Book(){\r\n        \r\n        let db = Firestore.firestore()\r\n        let doc = db.collection(\"Booking\").document()\r\n        self.doc = doc.documentID\r\n        \r\n        let from = GeoPoint(latitude: self.source.latitude, longitude: self.source.longitude)\r\n        let to = GeoPoint(latitude: self.destination.latitude, longitude: self.destination.longitude)\r\n        \r\n        \/\/ Save booking details to Firestore\r\n        doc.setData([\"name\":\"DataFlair\",\"from\":from,\"to\":to,\"distance\":self.distance,\"fair\": (self.distance as NSString).floatValue * 1.2]) { (err) in\r\n            \r\n            if err != nil{\r\n                \r\n                print((err?.localizedDescription)!)\r\n                return\r\n            }\r\n            \r\n            \/\/ Generate QR code for booking\r\n            let filter = CIFilter(name: \"CIQRCodeGenerator\")\r\n            filter?.setValue(self.doc.data(using: .ascii), forKey: \"inputMessage\")\r\n            \r\n            let image = UIImage(ciImage: (filter?.outputImage?.transformed(by: CGAffineTransform(scaleX: 5, y: 5)))!)\r\n            \r\n            self.data = image.pngData()!\r\n            \r\n            \/\/ Show booking confirmation\r\n            self.loading.toggle()\r\n            self.book.toggle()\r\n            \r\n        }\r\n    }\r\n}\r\nstruct HomeView_Previews: PreviewProvider {\r\n    static var previews: some View {\r\n        Home()\r\n    }\r\n}<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/home-view-1-scaled.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-115811 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/home-view-1-scaled.webp\" alt=\"home view\" width=\"2560\" height=\"1504\" \/><\/a><\/p>\n<ul>\n<li>The Home struct is a <strong>SwiftUI<\/strong> view that represents the main screen of the app.<\/li>\n<li>It contains various<strong> @State<\/strong> properties to manage the app&#8217;s state, such as map (an instance of <strong>MKMapView),<\/strong> manager (an instance of<strong> CLLocationManager),<\/strong> <strong>alert, source,<\/strong> <strong>destination, name, distance, time, show, loading, book, doc, and data.<\/strong><\/li>\n<li>The body property defines the UI layout of the view using a <strong>ZStack<\/strong> and several other SwiftUI components like <strong>VStack, HStack, and Button.<\/strong><\/li>\n<li>The <strong>MapView<\/strong> is a custom SwiftUI view that represents the map view and is embedded within the <strong>Home<\/strong> view.<\/li>\n<li>The Book function is responsible for booking a ride and saving the booking details to the <strong>Firestore database.<\/strong><\/li>\n<\/ul>\n<h4>Step 8: Connect Views in ContentView<\/h4>\n<p><strong>a.<\/strong> Open the<strong> &#8220;ContentView.swift&#8221;<\/strong> file.<br \/>\n<strong>b.<\/strong> Replace the default implementation of the ContentView struct with a new implementation that returns an instance of the<strong> Home<\/strong> view.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import SwiftUI\r\nstruct ContentView: View {\r\n    var body: some View {\r\n        \r\n        \/\/ The Home view is displayed\r\n        Home()\r\n    }\r\n}\r\nstruct ContentView_Previews: PreviewProvider {\r\n    static var previews: some View {\r\n        \r\n        \/\/ The ContentView is displayed in the preview\r\n        ContentView()\r\n    }\r\n}<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/connecting-views-scaled.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115812 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/connecting-views-scaled.webp\" alt=\"connecting views\" width=\"2560\" height=\"1504\" \/><\/a><\/p>\n<p><strong>Output<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/cab-booking-app-output.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115814 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/cab-booking-app-output.webp\" alt=\"cab booking app output\" width=\"800\" height=\"562\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/swift-cab-booking-app-output.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115815 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/swift-cab-booking-app-output.webp\" alt=\"swift cab booking app output\" width=\"800\" height=\"816\" \/><\/a><\/p>\n<p>Firebase Firestore stores the Fare details like distance, cost, and customer name.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/firebase-strores-fares-details-scaled.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115816 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/firebase-strores-fares-details-scaled.webp\" alt=\"firebase stores fares details\" width=\"2560\" height=\"1552\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p>Congratulations! You have successfully created a Cab Booking app using SwiftUI and Firebase Firestore. In this project, we learned how to integrate MapKit for location and map services, use Firebase Firestore to store booking details and display a QR code with the booking information. You can now further enhance the app by adding additional features based on your requirements.<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:2633,&quot;href&quot;:&quot;https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1LWWNmxrGf7VVN1SQ78v98d6HZ4U3oLji\\\/view?usp=drive_link&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20260601090304\\\/https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1LWWNmxrGf7VVN1SQ78v98d6HZ4U3oLji\\\/view?usp=drive_link&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-06-02 08:51:39&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-13 14:44:52&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-13 14:44:52&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:205,&quot;href&quot;:&quot;https:\\\/\\\/console.firebase.google.com&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;https:\\\/\\\/accounts.google.com\\\/ServiceLogin?passive=1209600\\u0026osid=1\\u0026continue=https:\\\/\\\/console.firebase.google.com\\\/\\u0026followup=https:\\\/\\\/console.firebase.google.com\\\/&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this project, we will learn how to create a Cab Booking app using SwiftUI and Firebase Firestore. The app will allow users to book a cab by selecting their source and destination locations&#46;&#46;&#46;<\/p>\n","protected":false},"author":581,"featured_media":115798,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27789],"tags":[27819,27818,27817,27816,27801,27791,27790],"class_list":["post-115595","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-swift-tutorials","tag-cab-booking-app","tag-cab-booking-app-project","tag-swift-cab-booking-app","tag-swift-cab-booking-app-project","tag-swift-project-for-practice","tag-swift-project-ideas","tag-swift-projects"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Swift Cab Booking App \u2013 Ride with Ease, Book with Confidence - DataFlair<\/title>\n<meta name=\"description\" content=\"Experience seamless cab bookings with Swift, the fastest and most reliable cab booking app. Get to your destination with just a tap.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Swift Cab Booking App \u2013 Ride with Ease, Book with Confidence - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Experience seamless cab bookings with Swift, the fastest and most reliable cab booking app. Get to your destination with just a tap.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-10T04:51:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-01T09:02:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/cab-booking-application-.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Swift Cab Booking App \u2013 Ride with Ease, Book with Confidence - DataFlair","description":"Experience seamless cab bookings with Swift, the fastest and most reliable cab booking app. Get to your destination with just a tap.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/","og_locale":"en_US","og_type":"article","og_title":"Swift Cab Booking App \u2013 Ride with Ease, Book with Confidence - DataFlair","og_description":"Experience seamless cab bookings with Swift, the fastest and most reliable cab booking app. Get to your destination with just a tap.","og_url":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2023-07-10T04:51:44+00:00","article_modified_time":"2026-06-01T09:02:38+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/cab-booking-application-.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445"},"headline":"Swift Cab Booking App \u2013 Ride with Ease, Book with Confidence","datePublished":"2023-07-10T04:51:44+00:00","dateModified":"2026-06-01T09:02:38+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/"},"wordCount":1009,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/cab-booking-application-.webp","keywords":["cab booking app","cab booking app project","swift cab booking app","swift cab booking app project","swift project for practice","swift project ideas","swift projects"],"articleSection":["Swift Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/","url":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/","name":"Swift Cab Booking App \u2013 Ride with Ease, Book with Confidence - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/cab-booking-application-.webp","datePublished":"2023-07-10T04:51:44+00:00","dateModified":"2026-06-01T09:02:38+00:00","description":"Experience seamless cab bookings with Swift, the fastest and most reliable cab booking app. Get to your destination with just a tap.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/cab-booking-application-.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/07\/cab-booking-application-.webp","width":1200,"height":628,"caption":"cab booking application"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/swift-cab-booking-app\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Swift Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/swift-tutorials\/"},{"@type":"ListItem","position":3,"name":"Swift Cab Booking App \u2013 Ride with Ease, Book with Confidence"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam6\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/115595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=115595"}],"version-history":[{"count":8,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/115595\/revisions"}],"predecessor-version":[{"id":148724,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/115595\/revisions\/148724"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/115798"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=115595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=115595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=115595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}