Back to Blog
iOSSwiftUICase StudyStripeCarPlayMobile

Building Prima Bilvård: A Case Study in Modern iOS Development

A comprehensive case study on building a native iOS application for car care services with SwiftUI, Stripe payments, loyalty rewards, and CarPlay integration.

Retro87 Team
January 20, 2025

Building Prima Bilvård: A Case Study in Modern iOS Development

Executive Summary

Prima Bilvård is a native iOS application that transforms how Swedish car owners access professional car care services. Built with SwiftUI and modern iOS technologies, the app delivers a complete service booking platform with integrated payments, loyalty rewards, and groundbreaking CarPlay integration currently in development. The app is live on the App Store, serving customers across Sweden.

Business Value Delivered

For End Users

Seamless Service Booking: The app eliminates friction from the car service booking process. Users select their service tier, choose from their registered vehicles, pick an available time slot, and complete payment – all within a unified, intuitive flow.

Multi-Vehicle Management: Car owners can register and manage multiple vehicles with automatic license plate lookup or manual entry, making fleet management effortless for families and businesses.

Intelligent Scheduling: A visual calendar heat map shows booking density patterns, helping users make informed decisions about when to schedule their service and avoid peak times.

Loyalty Rewards Program: An integrated points system rewards customer loyalty with redeemable vouchers, tier progression tracking, and transparent points history – driving repeat business and customer retention.

CarPlay Innovation (In Development): Industry-leading CarPlay integration brings emergency roadside services, express reconditioning, and contextual features like restaurant recommendations directly to the vehicle dashboard. Currently pending Apple entitlement approval.

For the Business

Customer Acquisition & Retention: The app's browse mode allows unauthenticated users to explore services and pricing before committing, lowering the barrier to entry while the rewards system encourages long-term engagement.

Operational Efficiency: Automated booking management, real-time availability checking, and structured service tiers reduce administrative overhead and optimize resource allocation.

Revenue Growth: Integrated Stripe payment processing enables frictionless transactions, reducing cart abandonment and accelerating cash flow.

Data-Driven Insights: Firebase integration provides analytics foundation for understanding user behavior, booking patterns, and service preferences.

Competitive Differentiation: CarPlay integration (pending approval) positions Prima Bilvård as a technology leader in the automotive services space, offering capabilities competitors lack.

Technical Architecture

Technology Stack

Frontend Framework: Built entirely in SwiftUI using MVVM (Model-View-ViewModel) architecture across 52 Swift files totaling over 10,000 lines of code.

Authentication: Firebase Authentication with Google Sign-In integration, providing secure, frictionless user access with JWT token-based API communication.

Payment Processing: Stripe SDK integration for PCI-compliant payment handling with support for both test and production environments.

Backend Communication: RESTful API architecture with async/await Swift concurrency patterns for responsive, reliable data synchronization.

State Management: Reactive UI updates using SwiftUI's Combine framework with @Published properties and ObservableObject ViewModels.

Core Capabilities

1. Authentication & Profile Management

  • Firebase Auth with Google Sign-In for streamlined onboarding
  • Automatic JWT token refresh and session management
  • Profile management with display name and contact information
  • Secure credential storage following iOS best practices

2. Intelligent Booking Engine

  • Multi-tier service selection (Bronze, Silver, Gold)
  • Real-time availability checking with calendar visualization
  • Booking status tracking (pending, confirmed, completed, cancelled)
  • Booking history with full transaction records
  • Calendar heat map visualization for booking density analysis

3. Vehicle Registry System

  • Automatic vehicle lookup via license plate registration
  • Manual entry support for specialty vehicles
  • Vehicle metadata management (make, model, year, size classification)
  • Multi-vehicle switching with persistent user preferences

4. Points & Rewards Platform

  • Automatic points accrual on every transaction
  • Tier-based loyalty system with progressive benefits
  • Voucher redemption engine with expiration tracking
  • Comprehensive points transaction history
  • Real-time balance synchronization

5. Payment Integration

  • Stripe SDK for secure payment processing
  • Service-based dynamic pricing calculation
  • Transaction history and receipt management
  • Test and production mode support
  • PCI DSS compliant implementation

6. CarPlay Extension (In Development - Pending Apple Entitlement)

On-Demand Services: Emergency roadside assistance, flat tire service, and express reconditioning accessible from the vehicle dashboard.

Real-Time Tracking: WebSocket-based live status updates showing service provider location and estimated arrival.

Safety-First UI: CarPlay-optimized interface following Apple's design guidelines for minimal driver distraction.

Location Integration: Automatic current location detection for service requests without manual address entry.

Development Status: Fully implemented and tested in development environment, awaiting production CarPlay entitlement from Apple.

Architecture Patterns

MVVM Implementation

Clear separation between View (UI), ViewModel (presentation logic), and Model (data) layers ensures:

  • Testability: ViewModels can be unit tested independently of UI
  • Maintainability: Changes to business logic don't require UI modifications
  • Scalability: New features integrate cleanly without architectural refactoring
  • Reusability: ViewModels and Models can be shared across different views

Service Layer Pattern

Dedicated service classes encapsulate all backend communication:

  • APIService: Core HTTP client with authentication and error handling
  • BookingService: Booking lifecycle management
  • VehicleService: Vehicle registry operations
  • PaymentService: Stripe integration and transaction handling
  • PointsService: Rewards program business logic
  • CarPlayServiceManager: CarPlay-specific service coordination

This separation provides:

  • Centralized API error handling
  • Consistent authentication token management
  • Request/response logging for debugging
  • Mock service implementations for testing

Configuration Management

Environment-specific configurations managed via .xcconfig files:

  • Debug: Development API endpoints and Stripe test keys
  • Release: Production endpoints and live payment credentials
  • Debug-CarPlay: Development builds with CarPlay enabled
  • Release-CarPlay: Production CarPlay builds (pending entitlement)

Compilation flags (-D CARPLAY_ENABLED) enable conditional feature compilation for different build targets.

Development Infrastructure

Build Configurations

Four distinct build configurations support different deployment scenarios:

  1. Debug: Standard development with full logging
  2. Debug-CarPlay: Development with CarPlay features enabled
  3. Release: App Store production build
  4. Release-CarPlay: Production CarPlay build (awaiting Apple approval)

Developer Tooling

Custom automation script (scripts/dev.sh) provides:

  • One-command builds for different configurations
  • Automated simulator and device installation
  • Backend server health checks
  • Live log monitoring
  • Dependency tree visualization
  • Code formatting and linting integration

Quality Assurance

  • Unit test infrastructure for ViewModels and Services
  • Comprehensive error handling with typed error enums
  • Debug logging with contextual information
  • Environment-specific API endpoint validation

Technical Achievements

Performance

  • Async/await concurrency eliminates UI blocking
  • Lazy loading for booking history and transaction data
  • Efficient SwiftUI view updates minimize unnecessary renders
  • Image caching for vehicle photos and service imagery

Security

  • JWT token-based API authentication
  • Secure keychain storage for sensitive credentials
  • HTTPS-only API communication
  • Stripe PCI-compliant payment handling
  • No client-side storage of payment information

Scalability

  • Modular architecture supports feature additions without refactoring
  • Service layer abstraction enables backend migration
  • Environment configuration supports multiple deployment targets
  • Swift Package Manager enables dependency version management

User Experience

  • Native SwiftUI animations and transitions
  • Adaptive layouts for different iPhone screen sizes
  • Error recovery flows with user-friendly messaging
  • Offline capability awareness with graceful degradation

CarPlay: A Technical Deep Dive (In Development)

The CarPlay integration represents a significant technical achievement, requiring:

Scene Management

Custom CarPlaySceneDelegate handles CarPlay lifecycle:

  • Template-based UI construction following CarPlay guidelines
  • Scene activation/deactivation state management
  • Background to foreground transitions
  • Multi-scene coordination with main iOS app

Real-Time Communication

WebSocket integration for live service tracking:

  • Connection management with automatic reconnection
  • Status update parsing and UI synchronization
  • Location data streaming for service provider tracking
  • Graceful degradation when connection is unavailable

Location Services

CoreLocation integration for automatic positioning:

  • Authorization state management
  • Continuous location updates during service tracking
  • Coordinate transmission to backend services
  • Privacy-compliant location handling

API Architecture

Dedicated CarPlay API client with distinct endpoints:

  • Service request submission
  • Status polling and updates
  • Request cancellation
  • WebSocket authentication

Development & Approval Status

The CarPlay implementation is fully developed and tested in our development environment. We're currently in the Apple entitlement approval process, which is required before CarPlay features can be enabled in production App Store builds. The codebase includes complete CarPlay support across multiple files (577+ lines in CarPlaySceneDelegate.swift alone), with service management, location tracking, and WebSocket communication all operational and ready for production deployment upon approval.

Business Impact Metrics

Deployment Status

  • Live on App Store: Production-ready and serving customers
  • Active Development: Ongoing CarPlay feature development on dedicated branch
  • Code Maturity: 10,751 lines across 52 carefully architected Swift files
  • Platform Coverage: iOS 15.0+ with CarPlay support (in development)

Technical Metrics

  • Dependencies: 13 external packages managed via Swift Package Manager
  • Build Configurations: 4 distinct configurations for different deployment scenarios
  • API Integration: Full REST API with 15+ endpoints
  • Test Coverage: Unit test infrastructure established

Future Technical Roadmap

Immediate Goals

CarPlay Production Launch: Complete Apple entitlement approval process and deploy CarPlay features to production.

Planned Enhancements

Comprehensive Testing: Expand unit test coverage for ViewModels and Services, implement UI tests for critical user flows.

CI/CD Pipeline: Fastlane integration for automated builds, testing, and App Store deployment.

Offline Support: Core Data integration for offline booking viewing and draft creation.

Push Notifications: Firebase Cloud Messaging for booking updates, service reminders, and promotional campaigns.

Analytics Platform: Firebase Analytics implementation for user behavior insights and conversion tracking.

Performance Monitoring: Instrumentation for app performance profiling and optimization.

Accessibility: VoiceOver optimization and accessibility audit implementation.

Technical Challenges & Solutions

Challenge: CarPlay Scene Configuration

Problem: SwiftUI's automatic scene manifest generation conflicted with CarPlay's custom scene delegate.

Solution: Implemented INFOPLIST_KEY_UIApplicationSceneManifest_Generation = NO for CarPlay configurations, allowing manual scene management while maintaining SwiftUI lifecycle for main app.

Challenge: Token Management

Problem: JWT tokens expire, requiring graceful refresh without disrupting user experience.

Solution: Centralized token refresh logic in APIService with automatic retry on 401 responses, transparent to ViewModels and Views.

Challenge: Multi-Environment Configuration

Problem: Managing different API endpoints, Stripe keys, and feature flags across environments.

Solution: .xcconfig files with build configuration inheritance and Swift compilation flags for compile-time feature selection.

Conclusion

Prima Bilvård demonstrates modern iOS development best practices applied to a real-world business problem. The combination of SwiftUI, MVVM architecture, comprehensive service layer abstraction, and innovative CarPlay integration (pending approval) delivers both technical excellence and measurable business value.

The app's live App Store presence validates the architectural decisions, while ongoing development of CarPlay capabilities shows a commitment to continuous innovation and feature expansion.

Key Takeaways:

  • SwiftUI and MVVM provide a robust foundation for complex business applications
  • Proper separation of concerns enables rapid feature development without technical debt
  • CarPlay integration opens new service delivery channels and competitive advantages
  • Modern Swift concurrency (async/await) delivers responsive, maintainable asynchronous code
  • Environment-based configuration management supports clean development workflows

Prima Bilvård represents what's achievable when modern iOS technologies meet clear business requirements and thoughtful architectural planning.


Technical architecture: SwiftUI, MVVM, Firebase, Stripe
Platform: iOS 15.0+, CarPlay (in development)
Status: Live on App Store

Need help with your project?

We solve complex technical challenges in production. Let's discuss how we can help.

Start a Conversation