iOS Development Setup
Repository:
ngwenya-ios
Submodule:ngwenya-front/mobile/ios
Requirements: Xcode 16+, Swift 6+, Apple Silicon Mac
Tested on: M1 Max, 64 GB RAM, macOS 15, Xcode 26.3
Quick Start
# 1. Clone (or init submodule)
cd /path/to/ngwenya-front
git submodule update --init mobile/ios
cd mobile/ios
# 2. Open Xcode and create project (see detailed steps below)
open -a Xcode
# 3. Build & run on Simulator (โR in Xcode)
The repo contains only Swift source files โ no .xcodeproj is committed. You create the Xcode project locally, add the existing sources, and you're running in under 10 minutes.
Prerequisites
| Tool | Minimum | Check |
|---|---|---|
| Xcode | 16.0+ | xcodebuild -version |
| Swift | 6.0+ | swift --version |
| macOS | 15.0+ | sw_vers |
# Verify simulator runtimes
xcrun simctl list runtimes | grep iOS
# Should show iOS 17.x or 18.x
# Accept Xcode license (if needed)
sudo xcodebuild -license accept
Project Setup in Xcode
Step 1: Create New Project
- File โ New โ Project... (โงโN)
- Select iOS โ App โ Next
- Configure:
| Field | Value |
|---|---|
| Product Name | Ngwenya |
| Organization Identifier | com.mallnline |
| Interface | SwiftUI |
| Language | Swift |
| Storage | None |
- Save inside the cloned
ngwenya-ios/directory - Uncheck "Create Git repository"
Step 2: Replace Default Files
Delete Xcode's generated starter files (ContentView.swift, NgwenyaApp.swift, Assets.xcassets), then add the repo's source files:
- Right-click Ngwenya group โ Add Files to "Ngwenya"...
- Select everything in the
Ngwenya/directory:NgwenyaApp.swiftViews/,Bridge/,Services/Assets.xcassets/,Info.plist
- Options: Create groups โ , Copy items โ, Add to target โ
Step 3: Set Info.plist Path
- Select project โ Build Settings โ search
Info.plist - Set
INFOPLIST_FILEtoNgwenya/Info.plist
Step 4: Set Deployment Target
General โ Minimum Deployments โ iOS 17.0
Add Push Notification Capability
- Select target โ Signing & Capabilities
- Click + Capability โ Add Push Notifications
- Add Background Modes โ check โ Remote notifications
Push tokens are only available on physical devices. The Simulator works for everything else.
APNs Key Setup (for real push testing)
- Apple Developer Portal โ Keys โ Create a Key
- Name:
Ngwenya Push Key, check โ APNs - Download the
.p8file (one-time download) - Configure the backend (alerts subgraph):
APNS_KEY_ID=ABC123DEF4
APNS_TEAM_ID=YOURTEAMID
APNS_KEY_CONTENTS="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----"
APNS_BUNDLE_ID=com.mallnline.ngwenya
APNS_PRODUCTION=false
See Mobile Push Infrastructure for the full backend configuration.
Run on Simulator
- Select iPhone 16 Pro from the device dropdown
- Press โR (Build & Run)
You should see:
- โ 6-tab navigation bar at the bottom
- โ Push permission dialog on first launch
- โ
Console:
[NgwenyaApp] Push auth error:(expected โ simulators don't support APNs)
| Feature | Simulator | Physical Device |
|---|---|---|
| Tab navigation | โ | โ |
| WebView bridge | โ | โ |
| Push token registration | โ | โ |
| Camera / biometrics | โ | โ |
Run on Physical Device
- Connect iPhone via USB-C / Lightning
- Select your iPhone from the device dropdown
- โR โ Xcode will install and launch
- Trust the developer certificate: Settings โ General โ VPN & Device Management
After granting notification permission, check Xcode console:
[NgwenyaApp] APNs token: a1b2c3d4e5f6...
Local Backend Development
API Endpoint
Update PushNotificationManager.swift to point to your Mac's backend:
// Your Mac and iPhone must be on the same Wi-Fi
private let graphQLEndpoint = "http://192.168.1.XXX:30000/graphql"
// Find your IP: System Settings โ Network โ Wi-Fi โ Details
WebView URL
Update WebViewBridge.swift:
let baseURL = "http://192.168.1.XXX:5173" // Vite dev server
The
Info.plistalready includes an ATS exception forlocalhostto permit HTTP in development.
WebView Bridge Testing
Enable Safari Web Inspector
- iPhone: Settings โ Safari โ Advanced โ Web Inspector โ
- Mac: Safari โ Settings โ Advanced โ Show features for web developers โ
Inspect the WebView
- Navigate to the Malet tab in the app
- Open Safari on Mac โ Develop โ select your Simulator/device โ Ngwenya
- In the Web Inspector console:
// Verify token injection
window.__NGWENYA_TOKEN__ // โ JWT string
window.__NGWENYA_PLATFORM__ // โ "ios"
// Test bridge messaging
window.webkit.messageHandlers.ngwenyaBridge.postMessage({
action: "navigate",
route: "/cart"
});
// Check Xcode console for: [WebViewBridge] Navigate: /cart
The frontend detects this context via mobileUtils.ts โ isMobileWebView(), getMobilePlatform(), and getNativeAuthToken().
Project Structure
Ngwenya/
โโโ NgwenyaApp.swift # @main entry + APNs AppDelegate
โโโ Info.plist # Bundle config, URL scheme, ATS
โโโ Assets.xcassets/ # App icon + AccentColor
โโโ Views/
โ โโโ ContentView.swift # 6-tab TabView shell
โ โโโ LobbyView.swift # Native discovery feed
โ โโโ MaletView.swift # WKWebView delegate
โ โโโ UCartView.swift # Native cart
โ โโโ MurchasesView.swift # Native order history
โ โโโ NotificationsView.swift # Push notification inbox
โ โโโ UChatView.swift # Native messaging
โโโ Bridge/
โ โโโ WebViewBridge.swift # WKWebView + JS bridge + token injection
โโโ Services/
โโโ AuthManager.swift # JWT token singleton
โโโ PushNotificationManager.swift # GraphQL push token registration
Troubleshooting
| Problem | Solution |
|---|---|
| "No such module 'SwiftUI'" | Set deployment target to iOS 17.0+ |
| "Signing requires a development team" | Select team in Signing & Capabilities, or disable for sim-only |
| Push token not in console | Simulators don't support APNs โ use physical device |
| WebView blank white screen | Update baseURL in WebViewBridge.swift to your local IP |
| "Multiple commands produce" | Delete DerivedData: rm -rf ~/Library/Developer/Xcode/DerivedData/Ngwenya-* |
Related
- Mobile Push Infrastructure โ In-house APNs/FCM dispatch and backend TCP event wiring
- Mobile SDK Architecture โ KMP shared module and OIDC/PKCE auth adapters
- Android Development Setup โ Companion guide for the Android app
- MFA & Passkeys โ Additional auth factors for native apps
- User Guide: Notifications โ Visitor-facing notification management