Skip to content

martinmoec/fable-react-native-template

Repository files navigation

Template for starting out a new Fable React Native App using F#, .NET Core and Yarn

Requirements

  • Yarn or NPM

    • brew install yarn
    • brew install npm
      • (comes with Node)
  • Node.js

    • brew install node
  • Watchman

    • brew install watchman
  • JDK

    • brew tap AdoptOpenJDK/openjdk
    • brew cask install adoptopenjdk8
  • React Native CLI

    • npm install -g react-native-cli
  • .NET Core SDK

  • XCode ( for iOS )

    • install command line tools: xcode-select --install

brew install node brew install watchman brew tap AdoptOpenJDK/openjdk brew cask install adoptopenjdk8

Setup

After cloning the respository cd into project root

  • yarn
  • paket install
  • cd src
  • dotnet restore

Building JavaScript

  • Building for debug: yarn debug
  • Building for release : yarn build
  • Running with auto-compiling: yarn watch
    • Enables auto-updating when the F# project in src/ is altered.

Output is built to out/

Running the React Native application

  • iOS simulator: react-native run-ios
  • Android: react-native run-android

Remember to build JavaScript files. If the package manager does not automatically start run react-native start before react-native run-(ios/android).

Error handling

iOS

  • No bundle URL present :

    • Try cleaning build-output, kill metro bundler and rebuild.
    • rm -rf ios/build/; kill $(lsof -t -i:8081); react-native run-ios
  • No bundle URL present & the packager did not start automatically:

    • Kill running instances
    • Start packager manually react-native start
    • Re-run project after packager successfully starts react-native run-ios
  • Entry, ":CFBundleIdentifier", Does Not Exist and similar

    • open ios/ReactNativeApp.xcodeproj in XCode
    • File -> Project Settings... -> Advanced
      • Set build location to Custom
      • Replace Build/.. with build/Build/... for the Products and Intermediates entries
      • E.g
        • Products: build/Build/Products
        • Intermediates: build/Build/Intermediates.noindex

Android

  • Licenses not accepted

    • run <Android folder>/sdk/tools/bin/sdkmanager --licenses and accept all
  • Device unable to load script from asset

    1. mkdir android/app/src/main/assets
    2. react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
    3. react-native run-android