native

cross-platform framework for building native apps framework mobile-app multiplatform
0.1.2 released

Native.cr

Native.cr

Crystal Platform License CI PRs Welcome Discord

React Native, but for Crystal developers.

Write mobile apps in Crystal. Compile directly to native ARM64 code. No JavaScript bridge. No interpreter. Just Crystal talking to Android and iOS through raw FFI.


iOS Support Status (Click to expand)

iOS is not currently supported.

native.cr compiles and runs on:

  • Android (ARM64)
  • Linux (x86_64, ARM64)
  • macOS (Apple Silicon, Intel)
  • Windows (via WSL2)

iOS support is planned for a future release. The Crystal compiler does not yet have official iOS target support. We are waiting for upstream changes or will contribute them in the future.

Why the delay?

  • Crystal's standard library lacks iOS-specific bindings
  • Apple requires a Mac for iOS development
  • Cross-compilation to iOS is not yet supported by the Crystal team

Workarounds for now:

  • Use the desktop preview (native.cr reload) for development
  • Build for Android (fully supported)
  • Run on macOS as a desktop app

When will iOS be ready? No ETA. Follow GitHub issues for updates.

Installation

Add to your shard.yml:

dependencies:
  native:
    github: slick-lab/native.cr
    version: ~> 0.1.0

Then run:

shards install

The post-install script will:

  • Build the native.cr CLI
  • Install it to /usr/local/bin
  • Compile Android and iOS engines (if NDK/Xcode available)

Verify installation:

native.cr doctor

Quick Start

# Create a new project
native.cr create my_app
cd my_app

# Build APK directly
native.cr build android
# APK created at build/app.apk

# Or build for iOS
native.cr build ios
# Framework created at build/NativeCr.framework

# Desktop preview (development)
native.cr reload
# Opens a window showing your app

What It Looks Like

class MyApp < Native::App
  @[Preserve]
  property count : Int32 = 0

  def setup : Nil
    @label = UI::Text.new
    @label.text = "Tap: 0"
    @label.text_size = 24
    
    button = UI::Button.new
    button.text = "Tap Me"
    button.width = 120
    button.height = 44
    button.on_click = ->{ increment }
    
    column = UI::Column.new
    column.spacing = 20
    column.add_child(@label)
    column.add_child(button)
    
    @root = column
  end
  
  def increment
    @count += 1
    @label.text = "Tap: #{@count}"
  end
end

Native::App.start(MyApp)

Features

Feature | Android | iOS | | ----- | ----- | ----- | | UI Components| ✅ | ✅ | | Touch Events & Gestures| ✅ | ✅ | | Animations | ✅ | ✅ | | Camera | ✅ | ✅ | | Notifications| ✅| ✅ | | Biometric Auth| ✅ | ✅ | | In-App Purchases| ✅| ✅ | | HTTP & WebSocket| ✅| ✅ | | SQLite Storage| ✅ |✅ | | Audio| ✅| ✅ | | Video| ✅| ✅ | | Game Loop| ✅| ✅ |


Commands

| Command | Description | | ----- | ----- | | native.cr create NAME | Create new project | | native.cr build | android Build APK | | native.cr build ios | Build iOS framework| | native.cr reload | Desktop preview with fast restart| | native.cr doctor | Check toolchain| | native.cr --version | Show version|


How It Works

┌─────────────────────────────────────────────────────────────┐
│  Your Crystal App (src/main.cr)                            │
├─────────────────────────────────────────────────────────────┤
│  native.cr Framework                                        │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────────┐ ┌─────────────┐ ┌─────────────┐           │
│  │   Android   │ │     iOS     │ │  Desktop    │           │
│  │  C + JNI    │ │  Obj-C +    │ │  SDL2 +     │           │
│  │  OpenGL     │ │  Metal      │ │  OpenGL     │           │
│  └─────────────┘ └─────────────┘ └─────────────┘           │
├─────────────────────────────────────────────────────────────┤
│  Android NDK │ iOS SDK │ SDL2                               │
└─────────────────────────────────────────────────────────────┘

Requirements

Platform Requirements Android Android NDK, Android SDK, Java 11+ iOS macOS, Xcode 14+, CocoaPods Desktop SDL2 (brew install sdl2 or apt install libsdl2-dev)


Documentation

  • API Reference
  • UI Components Guide
  • Examples

License

MIT License


Built with frustration. Released with love.

native:
  github: slick-lab/native.cr
  version: ~> 0.1.2
License MIT
Crystal none

Authors

Dependencies 1

  • sdl
    {'github' => 'ysbaddaden/sdl.cr'}

Development Dependencies 1

  • ameba ~> 1.0
    {'github' => 'crystal-ameba/ameba', 'version' => '~> 1.0'}

Dependents 0

Last synced .
search fire star recently