This is a sample iOS application demonstrating how to use ProxLock to securely proxy API requests to the Stormglass.io Weather API. The app displays current weather conditions, hourly forecasts, and 5-day forecasts for any location.
- 🌤️ Current weather conditions
- 📊 Hourly weather forecast
- 📅 5-day weather forecast
- 🌙 Astronomy data (sunrise, sunset)
- 🔒 Secure API requests via ProxLock
- 📱 Works on both simulator and real devices
Before you begin, make sure you have:
- Xcode installed (latest version recommended)
- A ProxLock account
- A Stormglass.io API key - Sign up at stormglass.io
- App Attest capability enabled (already configured in this project)
Open the Signing & Capabilities tab under the ProxLock-Demo target and select your development team.
Example:
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.ProxLock-Demo
DEVELOPMENT_TEAM = YOUR_TEAM_ID_HERE
- Visit stormglass.io and create an account
- Navigate to your dashboard and generate an API key
- Copy your API key - you'll need this for ProxLock configuration
- Log in to the ProxLock web dashboard
- Navigate to your project
- Add a new API key:
- Click "Add Key"
- Enter your Stormglass.io API key as the full key
- Add
api.stormglass.ioto the whitelisted URLs - Save the key
- Copy your credentials from the key card:
- Partial Key - This is the partial key shown in your dashboard
- Association ID - This is the association ID for your key
- (Optional) For simulator testing, get your Bypass Token:
- Navigate to the Device Check section in your dashboard
- Copy the bypass token
The app uses environment variables to securely store your ProxLock credentials. Follow these steps to configure them:
-
Open the project in Xcode
-
Go to Product → Scheme → Edit Scheme...
-
Select Run in the left sidebar
-
Go to the Arguments tab
-
Under Environment Variables, click the + button to add each variable:
Add the following environment variables:
Name Value Notes PROXLOCK_PARTIAL_KEYPROXLOCK_ASSOCIATION_IDYour association ID from ProxLock PROXLOCK_DEVICE_CHECK_BYPASSYour bypass token (optional) Required for simulator testing only Example:
PROXLOCK_PARTIAL_KEY = abc123def456... PROXLOCK_ASSOCIATION_ID = xyz789... PROXLOCK_DEVICE_CHECK_BYPASS = bypass_token_here (only for simulator) -
Click Close to save your changes
- Select your target device (simulator or real device)
- Press ⌘R or click the Run button
- The app will launch and display weather for San Francisco by default
- Search for any city to see its weather data
ProxLock-Demo/
├── Config.xcconfig # Build configuration (bundle ID, team ID)
├── ProxLock-Demo/
│ ├── Services/
│ │ └── WeatherService.swift # Service for fetching weather data via ProxLock
│ ├── ViewModels/
│ │ └── WeatherViewModel.swift # View model managing weather state
│ ├── Views/
│ │ ├── ContentView.swift # Main view
│ │ ├── WeatherDetailView.swift # Weather details display
│ │ ├── HourlyForecastView.swift # Hourly forecast display
│ │ ├── ForecastCardView.swift # Forecast card component
│ │ └── AstronomyView.swift # Astronomy data display
│ └── Models/
│ └── WeatherModels.swift # Data models for weather data
└── README.md
The app uses ProxLock to securely proxy requests to Stormglass.io:
- PLSession Setup: A
PLSessionis created using your partial key and association ID (from environment variables) - Bearer Token: The app uses
session.bearerTokenin the Authorization header instead of the full API key - Request Proxying: All requests go through ProxLock, which:
- Validates the request using Device Check
- Replaces the bearer token placeholder with your full Stormglass.io API key
- Forwards the request to Stormglass.io
- Returns the response to your app
See WeatherService.swift for the implementation details.
- Requires the
PROXLOCK_DEVICE_CHECK_BYPASSenvironment variable to be set - Device Check doesn't work in the simulator, so the bypass token is required
- Device Check works automatically on real devices
- No bypass token needed
- This is the recommended way to test before releasing
- Verify that
PROXLOCK_PARTIAL_KEYandPROXLOCK_ASSOCIATION_IDare set in your run scheme - Make sure there are no extra spaces in the environment variable values
- Restart Xcode if the variables don't seem to be loading
- On Simulator: Make sure
PROXLOCK_DEVICE_CHECK_BYPASSis set - On Real Device: Verify that App Attest is enabled in your target's capabilities (already configured)
- Verify your Stormglass.io API key is valid and active
- Check that
https://api.stormglass.iois whitelisted in your ProxLock key configuration - Ensure you're using the correct partial key and association ID
- Ensure that you have not hit the 10 request per day rate limit.
- Check your internet connection
- Verify the ProxLock service is accessible
- Check Xcode console for detailed error messages
This is a sample project for demonstration purposes.