- Install the react-native cli
npm install –g react-native-cli
git clone https://github.com/DaveAldon/Health-Hub-Mobile.git
npm install
Note that you need to run on a physical device or else the bluetooth functionality won't work.
- iOS
react-native run-ios --device
- Android
react-native run-android
- Specific iOS simulator
npx react-native run-ios --simulator="iPhone 12 Pro Max"
- iOS
react-native run-ios --configuration=release
- Android
cd android && ./gradlew assembleRelease -x bundleReleaseJsAndAssets
-
brew tap wix/brew
brew install applesimutils
-
-
Solution:
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
Then build:cd android && ./gradlew assembleRelease -x bundleReleaseJsAndAssets
-
Solution:
-
npm install --save react-native-ble-plx
npx react-native link react-native-ble-plx
- Open Xcode workspace located inside
ios
folder and add empty Swift file if you don't have at least one:
- Select File/New/File...
- Choose Swift file and click Next.
- Name it however you want, select your application target and create it.
- Accept to create Objective-C bridging header.
- Update your
ios/Podfile
to contain (it may be already there):
pod 'react-native-ble-plx', :path => '../node_modules/react-native-ble-plx'
- Enter
ios
folder and runpod update
- Add
NSBluetoothAlwaysUsageDescription
ininfo.plist
file. (it is a requirement since iOS 13) - Add support for background mode:
- In your application target go to
Capabilities
tab and enableUses Bluetooth LE Accessories
inBackground Modes
section - Pass
restoreStateIdentifier
andrestoreStateFunction
toBleManager
constructor
- In your application target go to
-
npm install --save react-native-ble-plx
npx react-native link react-native-ble-plx
- In top level
build.gradle
make sure that min SDK version is at least 18:
buildscript { ext { ... minSdkVersion = 18 ...
- In
build.gradle
make sure to add jitpack repository to known repositories:
allprojects { repositories { ... maven { url 'https://www.jitpack.io' } } }
- In
AndroidManifest.xml
, add Bluetooth permissions and update<uses-sdk/>
:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" ... <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> <uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"/> <!-- Add this line if your application always requires BLE. More info can be found on: https://developer.android.com/guide/topics/connectivity/bluetooth-le.html#permissions --> <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/> ...
-
- Delete files inside directory android/app/src/main/assets
react-native bundle --platform android --dev false --entry-file index.tsx --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
react-native run-android
-
react-native bundle --entry-file index.tsx --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios/assets
react-native run-ios --device
-
If you run an adb command, and it restarts and outputs a version mismatch like so:
adb server version (32) doesn't match this client (41); killing...
This is likely due to your environment variables not being setup correctly. Many solutions online point us to just stopping/starting adb server, but that may not suffice. If you're using a mac with zsh, run the following:nano ~./zshrc
Add this to the file:
alias adb='/Users/USERNAME/Library/Android/sdk/platform-tools/adb' export ANDROID_HOME=$HOME/Library/Android/sdk export PATH=$PATH:$ANDROID_HOME/emulator export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/tools/bin export PATH=$PATH:$ANDROID_HOME/platform-tools
Save, and restart terminal instances, or use
source ~/.zshrc
-
The error may look something like this, or a general failure to install because of "missing sdk" even though it's installed!
FAILURE: Build failed with an exception. * Where: Build file 'PATH/Health Hub/node_modules/react-native-reanimated/android/build.gradle' line: 89
Open the Android folder in Android Studio and wait until the automatic gradle processes finish. Then build normally.
-
xcrun: error: SDK "iphoneos" cannot be located xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos' configure: error: C compiler cannot create executables
Solution:
sudo xcode-select --switch /Applications/Xcode.app pod install
-
Solution:
react-native bundle --entry-file index.tsx --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios react-native run-ios --device
If you run the above command, even with sudo, and get a permissions issue that includes something like this:
watchmanResponse: { error: 'resolve_projpath: path `PATH/Health Hub`: open: PATH/Health Hub: Operation not permitted', version: '4.9.0' }
Give watchmen full disk access in System Preferences (System Preferences -> Security & Privacy -> Privacy -> Full Disk Access)
-
Solution:
npm install ios-deploy -g
If the above fails due to a permission error, run:
sudo npm install --global --unsafe-perm ios-deploy
-
Solution:
cd ios pod update MultiplatformBleAdapter
-
Solution:
Select app target in XCode -> Build Phases -> Remove all font files installed via React-Native-Vector-Icons package linking, and then rebuild
-
Solution:
sudo lsof -i :8081 kill -9 <PROCESS_ID>
These are conflicting with the default 8081 ports. You can also run RN on a different port if you wish via:
react-native start --port=8088
-
Solution: You have to exclude arm64 for simulator architecture both from your project and the Pod project
- Navigate to Build Settings of your project and add
Any iOS Simulator SDK
with valuearm64
insideExcluded Architecture
- Do the same for the Pod project
- Add the following to your pod file so that the settings aren't overwritten the next time you run
pod install
:
post_install do |installer| installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" end end
- Navigate to Build Settings of your project and add