Skip to content
The Chat Archive
chatgpt-4o-latest-20250326· OpenAI LMArena Human Preference 140K

Build a Swift ios app that solves a common problem between ios users, you choose the…

  1. User

    Build a Swift ios app that solves a common problem between ios users, you choose the problem.

  2. Assistant

    Sure! Let's build a Swift iOS app that solves a common problem: Managing and sharing Wi-Fi passwords securely and easily among iOS users.

    🧠 Problem: Many iOS users struggle with remembering or sharing Wi-Fi passwords with friends, family, or guests. While Apple has a built-in Wi-Fi sharing feature, it only works under specific conditions (both devices must be nearby, unlocked, and have each other in contacts). This can be limiting.

    ✅ Solution: Create a simple iOS app called "WiFiVault" that allows users to:

    • Securely store Wi-Fi credentials (SSID + password).
    • Share them via QR code or AirDrop.
    • Scan QR codes to quickly join a network.
    • Use Face ID/Touch ID to protect access.

    📱 App Name: WiFiVault

    🔐 Key Features:

    1. Secure storage using Keychain.
    2. Add/edit/delete Wi-Fi credentials.
    3. Generate QR code for a selected network.
    4. Scan QR code to retrieve and optionally auto-connect (if possible).
    5. Face ID/Touch ID authentication.

    🛠 Technologies Used:

    • Swift
    • UIKit
    • LocalAuthentication (for Face ID/Touch ID)
    • KeychainAccess (or native Keychain API)
    • CoreImage for QR code generation
    • AVFoundation for QR code scanning

    📦 Project Structure:

    • Models/
      • WiFiCredential.swift
    • Views/
      • WiFiListViewController.swift
      • AddWiFiViewController.swift
      • QRCodeViewController.swift
      • QRScannerViewController.swift
    • Services/
      • KeychainService.swift
      • AuthService.swift
    • Utilities/
      • QRCodeGenerator.swift
      • QRCodeScanner.swift

    🧱 Sample Code Snippets:

    1. WiFiCredential.swift
    struct WiFiCredential: Codable {
        let ssid: String
        let password: String
    }
    
    1. KeychainService.swift
    import Foundation
    import Security
    
    class KeychainService {
        static let shared = KeychainService()
    
        func save(_ credentials: [WiFiCredential]) {
            if let data = try? JSONEncoder().encode(credentials) {
                let query: [String: Any] = [
                    kSecClass as String: kSecClassGenericPassword,
                    kSecAttrAccount as String: "wifiVault",
                    kSecValueData as String: data
                ]
                SecItemDelete(query as CFDictionary)
                SecItemAdd(query as CFDictionary, nil)
            }
        }
    
        func load() -> [WiFiCredential] {
            let query: [String: Any] = [
                kSecClass as String: kSecClassGenericPassword,
                kSecAttrAccount as String: "wifiVault",
                kSecReturnData as String: true,
                kSecMatchLimit as String: kSecMatchLimitOne
            ]
    
            var result: AnyObject?
            if SecItemCopyMatching(query as CFDictionary, &result) == noErr,
               let data = result as? Data,
               let credentials = try? JSONDecoder().decode([WiFiCredential].self, from: data) {
                return credentials
            }
            return []
        }
    }
    
    1. QRCodeGenerator.swift
    import UIKit
    import CoreImage
    
    class QRCodeGenerator {
        static func generate(from string: String) -> UIImage? {
            let data = string.data(using: .utf8)
            if let filter = CIFilter(name: "CIQRCodeGenerator") {
                filter.setValue(data, forKey: "inputMessage")
                filter.setValue("Q", forKey: "inputCorrectionLevel")
                if let outputImage = filter.outputImage {
                    let transform = CGAffineTransform(scaleX: 10, y: 10)
                    let scaledImage = outputImage.transformed(by: transform)
                    return UIImage(ciImage: scaledImage)
                }
            }
            return nil
        }
    }
    
    1. QRScannerViewController.swift (simplified)
    import UIKit
    import AVFoundation
    
    class QRScannerViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate {
        var captureSession: AVCaptureSession!
        var previewLayer: AVCaptureVideoPreviewLayer!
    
        override func viewDidLoad() {
            super.viewDidLoad()
            captureSession = AVCaptureSession()
    
            guard let videoCaptureDevice = AVCaptureDevice.default(for: .video),
                  let videoInput = try? AVCaptureDeviceInput(device: videoCaptureDevice),
                  captureSession.canAddInput(videoInput) else { return }
    
            captureSession.addInput(videoInput)
    
            let metadataOutput = AVCaptureMetadataOutput()
            if captureSession.canAddOutput(metadataOutput) {
                captureSession.addOutput(metadataOutput)
                metadataOutput.setMetadataObjectsDelegate(self, queue: DispatchQueue.main)
                metadataOutput.metadataObjectTypes = [.qr]
            }
    
            previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
            previewLayer.frame = view.layer.bounds
            previewLayer.videoGravity = .resizeAspectFill
            view.layer.addSublayer(previewLayer)
    
            captureSession.startRunning()
        }
    
        func metadataOutput(_ output: AVCaptureMetadataOutput,
                            didOutput metadataObjects: [AVMetadataObject],
                            from connection: AVCaptureConnection) {
            captureSession.stopRunning()
            if let metadataObject = metadataObjects.first as? AVMetadataMachineReadableCodeObject,
               let stringValue = metadataObject.stringValue {
                // Parse and save Wi-Fi credentials
                print("Scanned: \(stringValue)")
                // Dismiss or show alert
            }
        }
    }
    

    🧪 Testing:

    • Add dummy Wi-Fi credentials.
    • Generate QR code and scan with another device.
    • Ensure Face ID/Touch ID prompts on app launch.
    • Validate Keychain persistence.

    🚀 Future Enhancements:

    • iCloud sync for credentials.
    • Auto-connect to Wi-Fi (limited by iOS APIs).
    • Share via AirDrop or iMessage.
    • Dark mode support.

    📲 Summary:

    WiFiVault solves a real-world problem of securely storing and sharing Wi-Fi credentials among iOS users. It leverages native iOS features like Keychain, Face ID, and QR code scanning to provide a seamless and secure experience.

    Would you like a full Xcode project or a UI design mockup for this app?

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.