-
-
Notifications
You must be signed in to change notification settings - Fork 268
feat(example): Add backend API server to Weather example #405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sergical
wants to merge
1
commit into
getsentry:main
Choose a base branch
from
sergical:weather-example-add-backend
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,101 +1,72 @@ | ||
| # Atmos Weather | ||
|
|
||
| Atmos Weather is a native SwiftUI weather app prototype for iOS. | ||
| Atmos Weather is a native SwiftUI weather app with a Node.js backend API. | ||
|
|
||
| ## Launch with mock weather data | ||
| ## Project structure | ||
|
|
||
| Build and run the app with XcodeBuildMCP first: | ||
|
|
||
| ```bash | ||
| ../../build/cli.js simulator build-and-run | ||
| ``` | ||
|
|
||
| Then relaunch the installed app with the mock API argument: | ||
|
|
||
| ```bash | ||
| ../../build/cli.js simulator launch-app \ | ||
| --bundle-id com.sentry.weather.Weather \ | ||
| --args=--mock-weather-api | ||
| Weather/ | ||
| app/ iOS app (Xcode project) | ||
| backend/ API server (Hono + Node.js) | ||
| ``` | ||
|
|
||
| ## JSON fixtures | ||
| ## Backend | ||
|
|
||
| Fixture JSON files live in: | ||
| Start the API server: | ||
|
|
||
| ```text | ||
| WeatherTests/Fixtures/ | ||
| ```bash | ||
| cd backend | ||
| npm install | ||
| npm run dev | ||
| ``` | ||
|
|
||
| Current fixtures: | ||
|
|
||
| - `WeatherTests/Fixtures/default-locations.json` | ||
| - `WeatherTests/Fixtures/search-locations.json` | ||
| - `WeatherTests/Fixtures/weather-report-loc-current-san-francisco.json` | ||
| The server runs on `http://localhost:3001` by default. Set `PORT` to change it. | ||
|
|
||
| ## API schemas | ||
| ## iOS app | ||
|
|
||
| OpenAI-compatible API schema files live in: | ||
| Build and run with XcodeBuildMCP from the `app/` directory: | ||
|
|
||
| ```text | ||
| Schemas/ | ||
| ```bash | ||
| cd app | ||
| ../../../build/cli.js simulator build-and-run | ||
| ``` | ||
|
|
||
| Current schemas: | ||
|
|
||
| - `Schemas/default-locations.schema.json` | ||
| - `Schemas/search-locations.schema.json` | ||
| - `Schemas/weather-report.schema.json` | ||
|
|
||
| These schemas describe the JSON response shape expected by the DTO layer. | ||
|
|
||
| ## Expected API endpoints | ||
| ### Mock mode | ||
|
|
||
| The production client is `URLSessionWeatherAPIClient`. It currently expects a JSON API rooted at: | ||
| Relaunch with mock data (no backend required): | ||
|
|
||
| ```text | ||
| https://api.atmosweather.example/v1 | ||
| ```bash | ||
| ../../../build/cli.js simulator launch-app \ | ||
| --bundle-id com.sentry.weather.Weather \ | ||
| --args=--mock-weather-api | ||
| ``` | ||
|
|
||
| All endpoints are `GET` requests. | ||
|
|
||
| | Purpose | Method | Path | Request shape | Schema | | ||
| | --- | --- | --- | --- | --- | | ||
| | Default saved locations | `GET` | `/locations/default` | No path params, query params, or body. | `Schemas/default-locations.schema.json` | | ||
| | Search locations | `GET` | `/locations/search` | Query string: `query=<string>` | `Schemas/search-locations.schema.json` | | ||
| | Weather report for a location | `GET` | `/weather/{locationID}` | Path param: `locationID=<WeatherLocationDTO.id>` | `Schemas/weather-report.schema.json` | | ||
|
|
||
| ### Request examples | ||
|
|
||
| Default locations: | ||
| ### Tests | ||
|
|
||
| ```http | ||
| GET /v1/locations/default | ||
| ```bash | ||
| ../../../build/cli.js simulator test | ||
| ``` | ||
|
|
||
| Search locations: | ||
|
|
||
| ```http | ||
| GET /v1/locations/search?query=San%20Francisco | ||
| ``` | ||
| UI tests inject `--mock-weather-api` so they do not depend on the backend. | ||
|
|
||
| Weather report: | ||
| ## API endpoints | ||
|
|
||
| ```http | ||
| GET /v1/weather/loc-current-san-francisco | ||
| ``` | ||
| The backend serves three `GET` endpoints under `/v1`: | ||
|
|
||
| ### Response expectations | ||
| | Purpose | Path | Params | | ||
| | --- | --- | --- | | ||
| | Default locations | `/v1/locations/default` | None | | ||
| | Search locations | `/v1/locations/search` | `?query=<string>` | | ||
| | Weather report | `/v1/weather/:locationID` | Path param | | ||
|
|
||
| - Responses must be JSON. | ||
| - Successful responses should use a `2xx` HTTP status code. | ||
| - Non-`2xx` responses are treated as API failures. | ||
| ### JSON schemas | ||
|
|
||
| ## Tests | ||
| Schema files in `app/Schemas/` describe the expected response shapes: | ||
|
|
||
| Run the app test suite through XcodeBuildMCP: | ||
| - `default-locations.schema.json` | ||
| - `search-locations.schema.json` | ||
| - `weather-report.schema.json` | ||
|
|
||
| ```bash | ||
| ../../build/cli.js simulator test | ||
| ``` | ||
| ### Test fixtures | ||
|
|
||
| UI tests inject `--mock-weather-api` themselves so they do not depend on the production API endpoint. | ||
| Fixture JSON files in `app/WeatherTests/Fixtures/` are used by unit tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # AGENTS.md | ||
|
|
||
| - If using XcodeBuildMCP, use the installed XcodeBuildMCP skill before calling XcodeBuildMCP tools. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>NSAppTransportSecurity</key> | ||
| <dict> | ||
| <key>NSAllowsLocalNetworking</key> | ||
| <true/> | ||
| </dict> | ||
| </dict> | ||
| </plist> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| node_modules/ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The project has conflicting build settings for the
Info.plist.GENERATE_INFOPLIST_FILEisYESwhile also specifying a customINFOPLIST_FILE, which will likely be ignored.Severity: HIGH
Suggested Fix
To ensure the custom
Info.plistis used, setGENERATE_INFOPLIST_FILE = NO;in the build settings for both Debug and Release configurations. This resolves the conflict and allows theNSAllowsLocalNetworkingkey from your customInfo.plistto be included in the final app bundle.Prompt for AI Agent
Also affects:
example_projects/Weather/app/Weather.xcodeproj/project.pbxproj:445~448