Saturday 10 October 2020

React Native Development Environment Setup

 I choose to setup the react native development environment for iOS first since I already have Xcode installed.

  • React Native CLI (not using Expo since I may need to use native code)
  • React Native with TypeScript

Target OS: iOS

Dependencies:
  • Node : already installed v12.9.0 using nvm v6.14.8
  • Watchman: su admin; brew install watchman
  • Xcode with command line tools : already installed
  • Cocoapods: already installed
Create react native project.
npx react-native init <project> --template react-native-template-typescript

Run Metro
cd ~/<project>; npx react-native start

Run iOS App
cd ~/<project>; npx react-native run-ios

Target OS: Android

Dependencies:
  • brew cask install adoptopenjdk/openjdk/adoptopenjdk8
  • Install Android Studio
    • Android SDK Platform 29
    • Google APIs Intel x86 Atom System Image
    • Android SDK Build-Tools select 29.0.2
  • Add ANDROID_HOME environment variable to .profile and add PATH.
Run Metro
cd ~/<project>; npx react-native start

Run Android App
cd ~/<project>; npx react-native run-android

Wednesday 1 April 2020

Using GitHub from Xcode and Mac OS Command Prompt

Introduction

I have the front end app developed in Xcode and the backend logic developed in NodeJS.  Therefore I will need to manage 2 independent repositories.

Using GitHub from Xcode 11

If you Xcode project is using local Git, you can create new remote GitHub repository directly in Xcode.  Follow this link.

Using GitHub from Mac OS Command Prompt

You need to create an empty private repository in GitHub manually first followed by pushing it from command prompt.
  1. Create Repository in GitHub manually.  Set it to private.
  2. Copy the clone url.  Example: https://github.com/username/project_name.git
  3. On Mac, open the command prompt and go to the project folder.  Ensure that the git user has permission to the repository.  Check the user using git config user.name
  4. Set the origin URL to the new repository.  git remote set-url origin https://github.com/username/project_name.git
  5. If the local git repository doesn't have any existing remote.  You can use add.  git remote add origin https://github.com/username/project_name.git
  6. Push to remote.  git push -u origin master
  7. Omit the -u parameter for subsequent push.
If you see this error, you can clear your credential first.
$ git push origin master
remote: Repository not found.
fatal: repository 'https://github.com/username/project_name.git/' not found