All Projects → gnestor → rubymotion-react

gnestor / rubymotion-react

Licence: other
Embedded React Native in RubyMotion

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to rubymotion-react

motion-markdown-it
Ruby/RubyMotion version of Markdown-it (CommonMark compliant parser and extendable)
Stars: ✭ 42 (+31.25%)
Mutual labels:  rubymotion
ProMotion-map
ProMotion::MapScreen gem. Extracted from ProMotion core.
Stars: ✭ 13 (-59.37%)
Mutual labels:  rubymotion

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].