PoC of using js-waku in a React native app
Go to file
jemboh d99dc43136 added readme 2022-04-08 14:15:32 +01:00
.bundle initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
__tests__ initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
android initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
ios upgraded some rn packages 2022-04-08 14:15:18 +01:00
.buckconfig initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
.eslintrc.js initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
.gitignore initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
.prettierrc.js initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
.ruby-version initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
.watchmanconfig initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
App.tsx added waku code to app 2022-04-08 12:26:52 +01:00
Gemfile initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
Gemfile.lock initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
app.json initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
babel.config.js trying babel plugin for bigint issue 2022-04-08 13:04:05 +01:00
index.js initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
metro.config.js upgraded some rn packages 2022-04-08 14:15:18 +01:00
package-lock.json upgraded some rn packages 2022-04-08 14:15:18 +01:00
package.json upgraded some rn packages 2022-04-08 14:15:18 +01:00
readme.md added readme 2022-04-08 14:15:32 +01:00
shim.js fixed big-int error 2022-04-08 13:14:47 +01:00
tsconfig.json initial commit after initialisation of new react native app 2022-04-07 10:37:33 +01:00
yarn.lock upgraded some rn packages 2022-04-08 14:15:18 +01:00

readme.md

React Native PoC

  • Setup Environment (React Native CLI)

    • install brew
    • install node (f not already installed), watchman and cocoapods
    brew install node
    brew install watchman
    brew install cocoapods
    
    • install xcode from app store
  • Create new app

    • Use react natives built in cli to init new app
    npx react-native init WakuRelay
    ## or with typescript
    npx react-native init WakuRelay --template react-native-template-typescript
    
    Run instructions for iOS:
        • cd "/Users/jem/code/react-native-waku-poc/WakuRelay" && npx react-native run-ios
        - or -
        • Open WakuRelay/ios/WakuRelay.xcworkspace in Xcode or run "xed -b ios"
        • Hit the Run button
    
    cd ios/
    pod install
    
  • Run app

    • Start Metro (like webpack)
    npx react-native start
    
    • start the app (in a new terminal window)
    npx react-native run-ios
    
  • Waku

    • install js-waku
    npm install --save js-waku
    
    • Will get a warning when starting app with metro
    warn Package js-waku has been ignored because it contains invalid configuration. Reason: Package subpath './package.json' is not defined by "exports" in /Users/jem/code/react-native-waku-poc/WakuRelay/node_modules/js-waku/package.json
    
    • Add waku code to App.tsx
    • Get error about xxxxx library
    npm install --save assert buffer crypto-browserify stream-browserify
    
    	- metro.config.js
    module.exports = {
      resolver: {
        extraNodeModules: {
          assert: require.resolve('assert'),
          buffer: require.resolve('buffer'),
          crypto: require.resolve('crypto-browserify'),
          stream: require.resolve('stream-browserify'),
        },
      },
    
    
    • heartbeat error, force it to use 0.13.0 (Fixed in Release 0.20.0)
    npm install libp2p-gossipsub@0.13.0 --save
    
    ## Add to metro.config.js > resolver > extraNodeModules
    "libp2p-gossipsub": "^0.13.0",
    
    • issue with run-ios
    ## in ios/
    pod cache clean --all
    
    ## upgrade in package.json
    "react-native-tcp": "^4.0.0",
    "react-native-udp": "^4.0.0",
    
    npm i
    
    # ios/
    pod install
    

    ERROR (ios)

    79 duplicate symbols for architecture x86_64
    

    FIX (seems like every time a pod install is done)

    - Open project in xcode
    - Project Navigator > Pods project > Pods
    - Under targets, select TcpSockets
    - Build Phases > Compile sources
    - Delete reference to `CocoaAsyncSocket`
    

    ERROR (metro)

    ERROR  TypeError: Conversion from 'BigInt' to 'number' is not allowed.
    
    ## BigInt error
    
    ## https://github.com/facebook/react-native/issues/28492#issuecomment-824698934
    
    ## babel.config.js ??
    plugins: ['@babel/plugin-syntax-bigint'],
    
    npm i --save-dev rn-nodeify@latest
    npm install --save big-integer
    ./node_modules/.bin/rn-nodeify --hack --install
    ./node_modules/.bin/rn-nodeify --install "big-integer" --hack
    
    ## shim.js - just after the Buffer shim
    if (typeof BigInt === 'undefined') {
      global.BigInt = require('big-integer');
    }