Giter VIP home page Giter VIP logo

rubymotion-react's Introduction

React Native in Motion

Embedded React Native in RubyMotion

Install

  1. Install RubyMotion
  2. Install React Native: https://facebook.github.io/react-native/docs/getting-started.html
  • Install node: brew install node
  • Install watchman: brew install watchman
  • Optional: Install React Native CLI: npm install -g react-native-cli
  1. Install bundler: gem install bundler
  2. Install gems (motion-cocoapods): bundle
  3. Initialize cocoapods: pod setup
  4. Install cocoapods: rake pod:install

Run

  1. Run React Native server (run this in a separate terminal tab): npm --prefix ./vendor/Pods/React start
  2. Build your app: rake or rake device

Embedding React Native in an existing RubyMotion project

  1. Add motion-cocoapods gem to your Gemfile
  2. Add React and any additional React component pods to your Rakefile
app.pods do
  pod 'React'
  pod 'React/RCTText'
end
  1. Create a React index.ios.js file in vendors/Pods/React directory
  2. Add RCTRootView to a container view (any UIView):
jsCodeLocation = NSURL.URLWithString("http://localhost:8081/index.ios.bundle")
@root_view = RCTRootView.alloc.initWithBundleURL(jsCodeLocation, moduleName:"SimpleApp", launchOptions:nil)
@container_view.addSubview(@root_view)
@root_view.frame = @container_view.bounds

Production vs. Development

The React Native server is intended for development (the server watches for changes to the index.ios.js file and allows the developer to refresh the Simulator with CMD+R vs. rebuilding).

For production use, this NSURL could instead point to a pre-bundled file on disk: jsCodeLocation = NSBundle.mainBundle.URLForResource("main",withExtension:"jsbundle")

To generate that file, run the curl command and add the output to your resources directory: curl http://localhost:8081/index.ios.bundle -o main.jsbundle

rubymotion-react's People

Contributors

gnestor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

spnkr superror lax

rubymotion-react's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.