Complete step-by-step guide to configure WoffuX on your machine.
Swift has two main approaches for managing sensitive configuration like API keys and tokens:
Similar to: .env files in Node.js, local.properties in Android
Pros:
- ✅ Clean separation of config from code
- ✅ Different configs for Debug/Release builds
- ✅ Easy to exclude from version control
- ✅ Industry standard for iOS/macOS projects
Setup Steps:
-
Create your config file:
cp Config/Config.xcconfig.template Config.xcconfig
-
Edit
Config.xcconfig:WOFFU_COMPANY = mycompany WOFFU_JWT_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... WOFFU_USERNAME = Xavi -
Add to Xcode:
- Open Xcode
- Right-click on project root → "Add Files to WoffuX"
- Select
Config.xcconfig - ✅ Check "Copy items if needed"
- ✅ Check your Watch App target
-
Set as Configuration File:
- Select project in navigator
- Select the PROJECT (not target)
- Go to "Info" tab
- Under "Configurations", expand "Debug" and "Release"
- Set
Config.xcconfigfor both configurations
-
Add keys to Info.plist:
- Open
Info.plist(in Watch App target) - Add these three keys:
<key>WoffuCompany</key> <string>$(WOFFU_COMPANY)</string> <key>WoffuJWTToken</key> <string>$(WOFFU_JWT_TOKEN)</string> <key>WoffuUsername</key> <string>$(WOFFU_USERNAME)</string>
- Open
-
Verify
.gitignore:# Should already be there Config.xcconfig *.xcconfig !Config.xcconfig.template -
Clean and rebuild:
- Product → Clean Build Folder (⇧⌘K)
- Product → Build (⌘B)
Similar to: Hardcoded configs, but in a separate ignored file
Pros:
- ✅ Very simple
- ✅ No Xcode configuration needed
- ✅ Easy to understand
Cons:
- ❌ Can't have different configs for Debug/Release
- ❌ Less standard approach
Setup Steps:
-
Create
WoffuConfig.local.swift:// WoffuConfig.local.swift // This file is git-ignored and contains your credentials extension WoffuConfig { static let company = "mycompany" static let jwtToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." static let username = "Xavi" }
-
Add to Xcode:
- Right-click on "Config" folder → "Add Files"
- Select
WoffuConfig.local.swift - ✅ Check your Watch App target
-
Verify
.gitignore:WoffuConfig.local.swift
You need to extract the JWT token from Woffu's web application.
-
Open Woffu in browser:
https://your-company.woffu.com -
Open DevTools:
- Chrome/Edge: F12 or Ctrl+Shift+I
- Safari: Develop → Show Web Inspector
- Firefox: F12
-
Go to Network tab
-
Perform any action (like clicking on a menu)
-
Find a request to
/api/ -
Check Headers:
- Look for
Authorizationheader - Copy the value after
Bearer - Example:
Bearer eyJhbGciOiJIUzI1Ni... - Your token is the part AFTER "Bearer "
- Look for
-
Open DevTools → Application (Chrome) or Storage (Firefox)
-
Check these locations:
- Local Storage →
https://your-company.woffu.com - Look for keys like:
token,authToken,jwt,access_token
- Local Storage →
-
Copy the token value
Test your configuration:
// Add this to your app initialization
print("Company: \(WoffuConfig.company)")
print("Token exists: \(!WoffuConfig.jwtToken.isEmpty)")
print("Username: \(WoffuConfig.username)")
// Or use the validation
do {
try WoffuConfig.validateOrThrow()
print("✅ Configuration is valid")
} catch {
print("❌ Configuration error: \(error)")
}Solution: Make sure WoffuConfig.swift is added to your Watch App target:
- Select the file
- Open File Inspector (right panel)
- Check "Target Membership"
Solution:
- Clean build folder (⇧⌘K)
- Verify xcconfig is set in Project → Info → Configurations
- Verify Info.plist has the
$(VARIABLE)syntax - Restart Xcode
Solution:
- You need to create it from the template
- It's git-ignored by design (for security)
- Each developer needs their own
Config.xcconfig
-
NEVER commit credentials:
- ✅ Config.xcconfig is in .gitignore
- ✅ WoffuConfig.local.swift is in .gitignore
- ✅ Only commit
.templatefiles
-
Rotate tokens regularly:
- JWT tokens should be refreshed periodically
- Update your config file when needed
-
Different tokens for different environments:
- Use different xcconfig files:
Config.Debug.xcconfigConfig.Release.xcconfig
- Use different xcconfig files:
-
Keep your repository clean:
# Check what would be committed git status # Should NOT see: # - Config.xcconfig # - WoffuConfig.local.swift
If you encounter issues:
- Check the logs in Xcode Console
- Verify your JWT token is still valid
- Test the API with Postman first
- Review the README.md for architecture details