mirror of
https://github.com/we-promise/sure.git
synced 2026-04-20 20:44:08 +00:00
7.1 KiB
7.1 KiB
Turbo Native Hosting Guide
This guide explains how to build and ship the iOS and Android shells that host the Sure web experience via Hotwire Native. It assumes you have already cut the feature/hotwire-native-prototype branch and merged the Rails changes documented in docs/hotwire_native_prototype_plan.md.
1. Account & Access Checklist
| Platform | Required Accounts | Notes |
|---|---|---|
| Apple iOS | Apple Developer Program (Individual or Company) | One team owner must invite the rest of the mobile crew via App Store Connect. Enable access to Certificates, Identifiers & Profiles. |
| Google Android | Google Play Console & Google Cloud project | Grant release managers the "Release manager" role and ensure a linked Firebase project for crash reporting (optional but recommended). |
| Source Control | GitHub (or host of record) access to the feature/hotwire-native-prototype branch |
Keep Rails and native wrappers in sync by rebasing on main before every release build. |
| Distribution | TestFlight and Google Play Internal testing tracks | Set up at least one internal track per platform for QA builds. |
2. Local Development Environment
Shared prerequisites
- Ruby & Node – Match the versions declared in
.ruby-versionand.node-version. Runbin/setuponce to install gems, npm packages, and prepare the Rails application. - Hotwire Native CLI – Install via
gem install hotwire-native(requires Ruby 3.1+). This provides thehotwire-native iosandhotwire-native androidcommands used below. - Environment files – Copy
.env.local.exampleto.env.native. Populate API hosts, feature flags, and any third-party keys required by the mobile shell. Do not commit secrets; use 1Password or the shared vault to distribute them. - HTTPS tunnel – For simulator work, expose your Rails dev server over HTTPS (e.g.,
cloudflared tunnelorngrok http https://localhost:3000). The native apps refuse clear-text HTTP when ATS/Network Security Config is enabled.
macOS requirements (iOS builds)
- macOS 13 Ventura or newer.
- Xcode 15.x with the Command Line Tools installed (
xcode-select --install). - CocoaPods (
sudo gem install cocoapods) for dependency syncing. - Homebrew (optional) for installing simulators and utilities.
Windows/Linux requirements (Android builds)
- Android Studio Giraffe+ with Android SDK Platform 34.
- Java 17 (Android Gradle Plugin 8 requires it).
adbavailable in your$PATH.- Gradle managed through Android Studio (wrapper checked into the native repo).
3. Repository Layout
The prototype keeps the native wrappers under native/ alongside the Rails app:
native/
├── ios/ # Xcode workspace generated by hotwire-native
├── android/ # Gradle project for the Android shell
└── README.md # Shared notes specific to the wrappers
If native/ does not exist yet, initialize it with:
hotwire-native init --platforms=ios,android --path=native \
--app-name "Sure" \
--server-url "https://dev.sure.example" # replace with your tunnel URL
Commit the scaffolding to the prototype branch so others can collaborate.
4. Configuring the WebView bridge
- Update
native/ios/Sure/Info.plistandnative/android/app/src/main/AndroidManifest.xmlwith the production domain (https://app.sure.com). - Ensure the Rails layout
app/views/layouts/application.html+turbo_native.erbserves navigation payloads. No code change is required, but verify the JSON includes the tabs expected by the native shell. - Add your HTTPS tunnel domain to the allow-list during development:
- iOS:
NSAppTransportSecurity -> NSAllowsArbitraryLoadsInWebContent = YESfor the tunnel hostname only. - Android: Update
res/xml/network_security_config.xmlto allow the dev hostname over HTTPS.
- iOS:
5. Building the iOS app
cd native/ios
pod install
xed . # or open Sure.xcworkspace manually
- Select the
Surescheme. - Choose a signing team that matches your Apple Developer account.
- Configure the bundle identifier under Signing & Capabilities (e.g.,
com.sure.appfor production,com.sure.devfor staging). - Update the build settings:
- Server URL: Edit
Config.xcconfigto point to your desired environment (https://staging.sure.com). - App Icon & Assets: Replace the placeholder images in
Assets.xcassets.
- Server URL: Edit
- To run in the simulator, press ⌘R. For a physical device, ensure it is registered in the Developer portal and use Product → Destination to select it.
- Create an archive (Product → Archive) and upload to TestFlight using the Organizer. Document the build number in the release notes.
6. Building the Android app
cd native/android
./gradlew wrapper
./gradlew assembleDevDebug # dev tunnel build
./gradlew assembleRelease # production-ready build (requires keystore)
- In Android Studio, open the
native/androidfolder. - Set the application ID in
app/build.gradle(applicationId "com.sure.app"). Use suffixes like.devfor QA channels. - Update
app/src/main/res/xml/remote_config_defaults.xmlor equivalent to point to the correct server URL. - Configure signing:
- Place the keystore under
native/android/keystores/(ignored by git). - Add a
keystore.propertiesfile (ignored) withstoreFile,storePassword,keyAlias,keyPassword. - Reference the file in
build.gradleto enable release signing.
- Place the keystore under
- Verify the WebView bridge loads the Turbo Native layout by launching
devDebugon an emulator (Run > Run 'app'). - Use the Play Console Internal track for QA: upload the
app-release.aabgenerated by./gradlew bundleRelease.
7. Continuous Integration (Optional)
For automated builds, configure CI jobs to:
- Check out the Rails repo and run
bin/rails testto ensure the web bundle is healthy. - Cache
native/ios/Podsand Android Gradle caches between runs. - Use
xcodebuild -workspace Sure.xcworkspace -scheme Sure -archivePath ... archivefor iOS. - Use
./gradlew bundleReleasefor Android. - Store signed artifacts in the build pipeline or upload to App Store Connect / Play Console via API keys.
8. Release Checklist
- Verify the Rails backend has been deployed with the matching commit hash.
- Smoke-test the PWA to ensure parity with the native wrappers.
- Update the in-app version string (Settings → About screen) to reflect the build.
- Publish release notes describing the Turbo Native changes.
- Coordinate rollout percentages (start with 5%, monitor, then ramp).
9. Support & Troubleshooting
- Authentication loops: Confirm
Turbo-Visit-Controlheaders are present on sign-out routes and that cookies share the same domain between web and native shells. - Push notifications: The prototype does not ship push support; add Firebase Cloud Messaging / APNs later.
- Performance: Use
WKWebViewandandroidx.webkit.WebViewCompatdebugging tools to profile slow pages. Enable remote debugging via Safari DevTools orchrome://inspect.
Keep this document updated as the prototype graduates from experimentation to production. Contributions should include simulator screenshots and updated instructions when the workflow changes.