App Client Base Swift
Ứng dụng iOS native cho nền tảng GoodGo, xây dựng bằng Swift và SwiftUI.
📱 Tổng quan
App client iOS native sử dụng kiến trúc MVVM với SwiftUI, tương tự như app-client-base-net (MAUI) nhưng dành riêng cho nền tảng Apple.
🛠️ Công nghệ
| Công nghệ | Phiên bản | Mục đích |
|---|---|---|
| Swift | 5.9+ | Ngôn ngữ lập trình |
| SwiftUI | iOS 15+ | UI Framework |
| Xcode | 15+ | IDE |
| URLSession | Native | Networking |
| Keychain | Native | Secure Storage |
📂 Cấu trúc thư mục
AppClientBaseSwift/
├── App/
│ └── AppClientBaseSwiftApp.swift # @main entry point
├── Core/
│ ├── Constants/
│ │ └── Constants.swift # App-wide constants
│ └── Extensions/
│ ├── View+Extensions.swift # SwiftUI View helpers
│ └── String+Extensions.swift # String utilities
├── Models/
│ └── User.swift # User data model
├── ViewModels/
│ └── HomeViewModel.swift # MVVM ViewModel
├── Views/
│ └── Screens/
│ ├── ContentView.swift # Main tab container
│ ├── WelcomeView.swift # Onboarding screen
│ ├── HomeView.swift # Home tab
│ ├── ExploreView.swift # Explore tab
│ └── ProfileView.swift # Profile tab
├── Services/
│ ├── APIService.swift # HTTP client
│ └── AuthManager.swift # Authentication
├── Resources/
│ ├── Assets.xcassets/ # Images & Colors
│ ├── en.lproj/ # English strings
│ └── vi.lproj/ # Vietnamese strings
└── Info.plist # App configuration
🚀 Bắt đầu
Yêu cầu
- macOS 14.0+ (Sonoma)
- Xcode 15.0+
- iOS 15.0+ target
Mở project
- Mở Xcode
- Chọn File > Open hoặc nhấn
⌘O - Chọn thư mục
app-client-base-swift - Build và chạy trên Simulator (
⌘R)
Tạo Xcode Project (Nếu chưa có)
Do project này chỉ chứa source files, bạn cần tạo Xcode project:
# Mở Xcode và tạo project mới
# 1. File > New > Project
# 2. Chọn "App" template
# 3. Product Name: AppClientBaseSwift
# 4. Team: Chọn team của bạn
# 5. Organization Identifier: vn.goodgo
# 6. Interface: SwiftUI
# 7. Language: Swift
# 8. Lưu vào thư mục app-client-base-swift
# 9. Xóa các file generated và thay thế bằng files trong thư mục này
🎨 Kiến trúc
MVVM Pattern
┌─────────────────────────────────────────────────────────────┐
│ VIEW (SwiftUI) │
│ ContentView, HomeView, ExploreView, ProfileView │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────┐ │
│ │ @StateObject │ │
│ │ @EnvironmentObject │ │
│ └──────────────────────────────────┘ │
│ │ │
├────────────────────────────▼────────────────────────────────┤
│ VIEWMODEL │
│ HomeViewModel (ObservableObject) │
│ - @Published properties │
│ - async/await methods │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────┐ │
│ │ Protocol / Dependency │ │
│ │ Injection │ │
│ └──────────────────────────────────┘ │
│ │ │
├────────────────────────────▼────────────────────────────────┤
│ SERVICES │
│ APIService, AuthManager │
└─────────────────────────────────────────────────────────────┘
Key Features
- SwiftUI: UI declarative hiện đại
- Async/Await: Xử lý bất đồng bộ native
- Keychain: Lưu trữ token bảo mật
- Localization: Hỗ trợ đa ngôn ngữ (VI/EN)
- Dark Mode: Hỗ trợ giao diện tối
📋 Conventions
Coding Style
// ViewModel với ObservableObject
@MainActor
class HomeViewModel: ObservableObject {
@Published var isLoading: Bool = false
func loadData() async {
// Async data loading
}
}
// View với MVVM binding
struct HomeView: View {
@StateObject private var viewModel = HomeViewModel()
var body: some View {
// SwiftUI body
}
}
Comments (Bilingual)
/// Load home screen data
/// Tải dữ liệu màn hình home
func loadData() async { }
🔗 Liên kết
- app-client-base-net - .NET MAUI client
- web-client - Web client
📄 License
Copyright © 2026 GoodGo. All rights reserved.