Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 168 additions & 0 deletions .github/workflows/test-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
name: Test Template

on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:

jobs:
test-template-ios:
name: Template → iOS Build
runs-on: macos-15

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Enable Corepack
run: corepack enable

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: false

- name: Generate project from template
run: |
cd cli
bash build-template.sh
node bin.js test-app --bundleId com.ci.testapp --goModule ci.test/test-app

- name: Verify no leftover identifiers
run: |
cd cli/test-app
if grep -r "rn-golang" --include="*.go" --include="*.ts" --include="*.json" --include="*.kt" --include="*.swift" --include="*.pbxproj" --include="*.plist" .; then
echo "ERROR: Found leftover 'rn-golang' references"
exit 1
fi
if grep -r "io.rngolang.app" .; then
echo "ERROR: Found leftover 'io.rngolang.app' references"
exit 1
fi
if grep -r "siddarthkay/react-native-go" .; then
echo "ERROR: Found leftover Go module references"
exit 1
fi
echo "All identifiers replaced correctly"

- name: Setup Go backend
run: make -C cli/test-app/backend setup

- name: Build Go backend for iOS
run: make -C cli/test-app/backend ios

- name: Install Node dependencies
run: make -C cli/test-app/mobile-app install
env:
YARN_ENABLE_HARDENED_MODE: 0
YARN_ENABLE_IMMUTABLE_INSTALLS: false

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
working-directory: cli/test-app/mobile-app/ios

- name: Install CocoaPods
run: make -C cli/test-app/mobile-app pod-install

- name: Select Xcode
run: sudo xcode-select -s "/Applications/Xcode_16.4.app/Contents/Developer"

- name: Build iOS Simulator App
working-directory: cli/test-app/mobile-app
run: |
set -o pipefail
xcodebuild -workspace ios/testapp.xcworkspace \
-scheme testapp \
-sdk iphonesimulator \
-configuration Release \
-destination 'platform=iOS Simulator,name=iPhone 16' \
-derivedDataPath ios/build \
CODE_SIGNING_ALLOWED=NO \
ARCHS=arm64 \
ONLY_ACTIVE_ARCH=YES

test-template-android:
name: Template → Android Build
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Enable Corepack
run: corepack enable

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: false

- name: Generate project from template
run: |
cd cli
bash build-template.sh
node bin.js test-app --bundleId com.ci.testapp --goModule ci.test/test-app

- name: Verify no leftover identifiers
run: |
cd cli/test-app
if grep -r "rn-golang" --include="*.go" --include="*.ts" --include="*.json" --include="*.kt" --include="*.swift" --include="*.pbxproj" --include="*.plist" .; then
echo "ERROR: Found leftover 'rn-golang' references"
exit 1
fi
if grep -r "io.rngolang.app" .; then
echo "ERROR: Found leftover 'io.rngolang.app' references"
exit 1
fi
if grep -r "siddarthkay/react-native-go" .; then
echo "ERROR: Found leftover Go module references"
exit 1
fi
echo "All identifiers replaced correctly"

- name: Setup Go backend
run: make -C cli/test-app/backend setup

- name: Build Go backend for Android
run: make -C cli/test-app/backend android

- name: Install Node dependencies
run: make -C cli/test-app/mobile-app install
env:
YARN_ENABLE_HARDENED_MODE: 0
YARN_ENABLE_IMMUTABLE_INSTALLS: false

- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'

- name: Setup Gradle cache
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: false

- name: Build Release APK
run: make -C cli/test-app/mobile-app build-android

- name: Stop Gradle daemon
if: always()
working-directory: cli/test-app/mobile-app/android
run: ./gradlew --stop
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ backend/*.xcframework
# IDEs
.vscode/
.idea/
.claude/
*.swp
*.swo
*~

# CLI template (generated before npm publish)
cli/template/

# Testing
coverage/
*.log
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ This project showcases how to build a fast mobile application where:
- iOS: Xcode 15+, CocoaPods
- Android: Android Studio, JDK 17+

## Create a New Project

```bash
npx create-react-native-go my-app --bundleId com.mycompany.myapp --goModule mycompany.com/my-app
cd my-app
make setup
make ios # or: make android
```

The CLI scaffolds a new project with your app name, bundle ID, and Go module — fully configured and ready to build.

## Quick Start

### Setup
Expand Down
62 changes: 62 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# create-react-native-go

Scaffold a React Native + Go mobile app in seconds. Go runs as an embedded HTTP server providing JSON-RPC APIs, while React Native handles the UI with the New Architecture (Fabric + TurboModules).

## Usage

```bash
npx create-react-native-go my-app --bundleId com.mycompany.myapp --goModule mycompany.com/my-app
cd my-app
make setup
make ios # or: make android
```

If you omit any flags, the CLI will prompt you interactively.

## What You Get

```
my-app/
├── Makefile # Root orchestrator
├── backend/
│ ├── Makefile # Go build targets
│ ├── mobile_api.go # Mobile API for server lifecycle
│ └── http_server.go # JSON-RPC HTTP server
└── mobile-app/
├── Makefile # Mobile build targets
├── src/
│ ├── NativeGoServerBridge.ts # TurboModule spec
│ ├── GoServerBridgeJSI.ts # JSI wrapper
│ └── JsonRpcClient.ts # JSON-RPC client
├── android/ # Android native code
└── ios/ # iOS native code
```

## Prerequisites

- Node.js 18+
- Go 1.25+
- iOS: Xcode 15+, CocoaPods
- Android: Android Studio, JDK 17+

## Options

| Flag | Description | Example |
|------|-------------|---------|
| `--bundleId` | App bundle identifier | `com.mycompany.myapp` |
| `--goModule` | Go module path | `mycompany.com/my-app` |

The first positional argument is the app name (e.g. `my-app`).

## How It Works

The CLI copies a pre-built template and replaces all identifiers (app name, bundle ID, Go module path, iOS project name, Android package directories) to match your configuration. It then initializes a fresh git repo.

## Links

- [GitHub Repository](https://github.com/siddarthkay/react-native-go)
- [Issues](https://github.com/siddarthkay/react-native-go/issues)

## License

MIT
3 changes: 3 additions & 0 deletions cli/bin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node
const { run } = require("./src/index");
run();
56 changes: 56 additions & 0 deletions cli/build-template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
# Copies project template files into cli/template/ for npm publishing.
# Run this before `npm publish` in the cli/ directory.
set -e

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
TEMPLATE_DIR="$SCRIPT_DIR/template"

echo "Building template from repo..."

rm -rf "$TEMPLATE_DIR"
mkdir -p "$TEMPLATE_DIR"

# Use rsync to copy while excluding build artifacts and dependencies
rsync -a \
--exclude='.git' \
--exclude='node_modules' \
--exclude='Pods' \
--exclude='Podfile.lock' \
--exclude='*.xcworkspace' \
--exclude='build' \
--exclude='.gradle' \
--exclude='gradle/' \
--exclude='.yarn/cache' \
--exclude='.yarn/install-state.gz' \
--exclude='gobridge.aar' \
--exclude='Gobridge.xcframework' \
--exclude='go.sum' \
--exclude='.expo' \
--exclude='.cxx' \
--exclude='local.properties' \
"$REPO_ROOT/backend" "$TEMPLATE_DIR/"

rsync -a \
--exclude='.git' \
--exclude='node_modules' \
--exclude='Pods' \
--exclude='Podfile.lock' \
--exclude='*.xcworkspace' \
--exclude='build' \
--exclude='.gradle' \
--exclude='.yarn/cache' \
--exclude='.yarn/install-state.gz' \
--exclude='gobridge.aar' \
--exclude='Gobridge.xcframework' \
--exclude='.expo' \
--exclude='.cxx' \
--exclude='.claude' \
--exclude='local.properties' \
"$REPO_ROOT/mobile-app" "$TEMPLATE_DIR/"

cp "$REPO_ROOT/Makefile" "$TEMPLATE_DIR/Makefile"
cp "$REPO_ROOT/.gitignore" "$TEMPLATE_DIR/.gitignore"

echo "Template built at: $TEMPLATE_DIR"
32 changes: 32 additions & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "create-react-native-go",
"version": "1.0.2",
"description": "Create a React Native + Go mobile app",
"bin": {
"create-react-native-go": "./bin.js"
},
"scripts": {
"prepublishOnly": "./build-template.sh"
},
"files": [
"bin.js",
"src/",
"template/"
],
"keywords": [
"react-native",
"golang",
"go",
"mobile",
"template",
"gomobile",
"jsi",
"turbomodules"
],
"author": "siddarthkay",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/siddarthkay/react-native-go"
}
}
Loading
Loading