Guide: Creating React Native โš›๏ธ App For Our Design Studio Application โ€“ Part 1

The guide is for creating a React Native app for our design studio web application made with Ruby On Rails 8. Let me start by explaining the fundamentals and then walk you through the entire setup process.

What is React Native? ๐Ÿค”

React Native is a framework developed by Facebook (now Meta) that allows you to build mobile applications using JavaScript and React. It enables you to write code once and deploy it on both iOS and Android platforms.

Why Use React Native? ๐ŸŽฏ

Key Benefits:

  • Cross-Platform Development: Write once, run on both iOS and Android
  • Code Reusability: Share up to 90% of code between platforms
  • Native Performance: Uses native components, not webviews
  • Hot Reloading: See changes instantly during development
  • Large Community: Extensive libraries and community support
  • Cost-Effective: Faster development with smaller teams
  • Facebook Backing: Strong ecosystem and continuous updates

React Native vs React: Key Differences ๐Ÿ“Š

AspectReactReact Native
Target PlatformWeb browsersMobile devices (iOS/Android)
DOMVirtual DOMNative components
StylingCSSStyleSheet API (CSS-like)
ComponentsHTML elements (<div>, <p>, etc.)Native components (<View>, <Text>, etc.)
NavigationReact RouterReact Navigation
DeploymentWeb serversApp stores
DevelopmentBrowser dev toolsMobile simulators/devices

Setting Up Your React Native Development Environment ๐Ÿ› ๏ธ

Let me guide you through creating your React Native app step by step:

Step 1: Install Prerequisites

First, let’s check your current setup and install the necessary tools:
Ran tool

We’ll need to install several tools. Let me guide you through each one:

1. Node.js & npm/yarn

# Check if Node.js is installed
node --version
npm --version

# If not installed, download from https://nodejs.org/
# Or install via Homebrew (recommended for macOS):
brew install node

2. React Native CLI

npm install -g @react-native-community/cli

3. For iOS Development (macOS only):

# Install Xcode from Mac App Store

# Install CocoaPods
# Homebrew
brew install cocoapods

# Later
# Update with Homebrew
brew upgrade cocoapods

# OR use ruby gem
sudo gem install cocoapods

4. For Android Development:

  • Install Android Studio
  • Set up Android SDK
  • Configure environment variables

Step 2: Create Your React Native App

Let’s navigate to our react folder and create the app. Let’s create our React Native app for the design studio.

Run these commands in our terminal:

# Navigate to your react directory
cd ~/react

# Create a new React Native app
npx react-native init DesignStudioApp

# Navigate to the new app directory
cd DesignStudioApp

๐ŸŽ‰ Our DesignStudioApp has been created successfully!

What Happened

The React Native CLI successfully:

  • โœ… Downloaded the template
  • โœ… Copied template files
  • โœ… Processed the template
  • โœ… Installed dependencies
  • โœ… Initialized Git repository

โœ…  CocoaPods is Already Installed!

CocoaPods version 1.16.2_1 is properly installed via Homebrew in our system.

CocoaPods manages dependencies for your Xcode projects.

You specify the dependencies for your project in a simple text file: your Podfile. CocoaPods recursively resolves dependencies between libraries, fetches source code for all dependencies, and creates and maintains an Xcode workspace to build your project. The latest released Xcode versions and the prior version are supported.

What This Means ๐Ÿ“‹

CocoaPods Installation Details:

  • โœ… Version: 1.16.2_1 (latest stable)
  • โœ… Location: /opt/homebrew/Cellar/cocoapods/1.16.2_1/
  • โœ… Main Command: pod is available
  • โœ… Complete Installation: All necessary files are present
# Let's Verify CocoaPods is Working 
pod --version
1.16.2

Now Let’s Try Installing iOS Dependencies ๐Ÿ“ฑ

Since CocoaPods is working, let’s try to install the iOS dependencies for our DesignStudioApp:

cd DesignStudioApp/ios && pod install
....
[Hermes] Using release tarball from URL: https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.80.1/react-native-artifacts-0.80.1-hermes-ios-debug.tar.gz

Step 3: Understanding the Project Structure ๐Ÿ“

After creating the app, you’ll see this structure:

DesignStudioApp/
โ”œโ”€โ”€ android/          # Android-specific code
โ”œโ”€โ”€ ios/              # iOS-specific code
โ”œโ”€โ”€ node_modules/     # Dependencies
โ”œโ”€โ”€ src/              # Your app source code (you'll create this)
โ”œโ”€โ”€ App.tsx           # Main app component
โ”œโ”€โ”€ index.js          # Entry point
โ”œโ”€โ”€ package.json      # Dependencies and scripts
โ”œโ”€โ”€ metro.config.js   # Metro bundler configuration
โ””โ”€โ”€ ...

Step 4: Key Files Explained ๐Ÿ“

App.tsx – Main component (like App.js in React web)
index.js – Entry point that registers your app
package.json – Dependencies and scripts
android/ & ios/ – Platform-specific native code

Step 5: Running Your App (No XCode installed) ๐Ÿš€

For iOS Simulator:

# Make sure you're in the DesignStudioApp directory
npx react-native run-ios

Install Xcode: Xcode Component Selection for React Native Development ๐Ÿ› ๏ธ

For React Native development, you should select BOTH:

โœ… Required Components:

  • macOS15.5 (built-in) – โœ… Select this
  • iOS 18.5 – โœ… Select this (Essential for React Native)

Why You Need Both ๐Ÿ“ฑ

ComponentWhy You Need ItWhat It Provides
macOS15.5Basic development toolsXcode IDE, build tools, debugger
iOS 18.5iOS app developmentiOS Simulator, iOS SDK, device support

Select BOTH components because:

  1. macOS15.5 (built-in) โœ…
  • Core Xcode functionality
  • Build tools and compiler
  • Essential for any development
  1. iOS 18.5 โœ…
  • iOS Simulator – Test your React Native app
  • iOS SDK – Required for building iOS apps
  • Device support – Deploy to real iPhones

Step-by-Step Instructions ๐Ÿ“‹

Point System to Full Xcode Installation
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

xcode-select --print-path

xcodebuild -version
Xcode 16.4

Now Try:

# Install iOS Dependencies Again
cd DesignStudioApp && cd ios && pod install

๐ŸŽ‰ CocoaPods Installation Complete!

All iOS dependencies have been successfully installed!

What Just Happened โœ…

  • โœ… 74 dependencies installed from Podfile
  • โœ… 73 total pods installed successfully
  • โœ… React Native modules all configured
  • โœ… Hermes engine installed (JavaScript engine)
  • โœ… Xcode workspace created

Hermes is an open-source JavaScript engine optimized for React Native. For many apps, using Hermes will result in improved start-up time, decreased memory usage, and smaller app size when compared to JavaScriptCore. Hermes is used by default by React Native and no additional configuration is required to enable it.

Important Note ๐Ÿ“

The system created a .xcworkspace file – this is what you’ll use instead of .xcodeproj from now on.

# Step 5: Now Let's Run Your App on iOS! 

โœ— npx react-native run-ios
info Found Xcode workspace "DesignStudioApp.xcworkspace"
info No booted devices or simulators found. Launching first available simulator...
info Launching iPhone 16 Pro (iOS 18.5)
info Building (using "xcodebuild -workspace DesignStudioApp.xcworkspace -configuration Debug -scheme DesignStudioApp -destination id=XXXX-XXXXX-XXXX-XXXX

Step 1: Install iOS Dependencies ๐Ÿ“ฆ

Open your terminal and run these commands:

# Navigate to your app directory
cd ~/react/DesignStudioApp

# Install iOS dependencies
cd ios && pod install && cd ..

This will install all the necessary iOS libraries and dependencies.

Step 2: Run the iOS App ๐Ÿ“ฑ

Option A: Use React Native CLI (Recommended)

Open a new terminal window (keep Metro running in the first one) and run:

cd ~/react/DesignStudioApp
npx react-native run-ios

Option B: Use Xcode Directly

# Open the iOS project in Xcode
cd ~/react/DesignStudioApp
xed ios/DesignStudioApp.xcworkspace

Then press the “Run” button (โ–ถ๏ธ) in Xcode.

What Should Happen ๐ŸŽฏ

  1. iOS Simulator opensA virtual iPhone will appear
  2. App builds – You’ll see build progress in terminal
  3. App launches – Your DesignStudioApp will open in the simulator
  4. Metro connects – The app connects to the development server

Expected Output ๐Ÿ“ฑ

You should see the default React Native welcome screen with:

  • React Native logo
  • “Welcome to React Native” message
  • Various getting started links
  • Debug information

Common Issues & Solutions ๐Ÿ”ง

Issue 1: “No iOS Simulator Available”

# List available simulators
xcrun simctl list devices

# If no simulators, create one in Xcode:
# Xcode > Window > Devices and Simulators > Create Simulator

Issue 2: “Build Failed”

# Clean and rebuild
cd ~/react/DesignStudioApp
npx react-native run-ios --clean

Issue 3: “Metro not responding” – not used metro

# Reset Metro cache
npx react-native start --reset-cache

Quick Commands Summary ๐Ÿ“

# Terminal 1: Start Metro
cd ~/react/DesignStudioApp
npx react-native start

# Terminal 2: Run iOS app
cd ~/react/DesignStudioApp
npx react-native run-ios

What You’ll See ๐Ÿ‘€

Your app should display:

  • React Native welcome screen
  • “Welcome to React Native” text
  • Various learning resources
  • Debug information

Testing Your App ๐Ÿงช

Once running, you can:

  • โŒ˜+D – Open developer menu
  • โŒ˜+R – Reload the app
  • โŒ˜+T – Open new simulator
  • Shake gesture – Open dev menu on device

Next Steps After Success ๐Ÿš€

Once your app is running:

  1. Edit App.tsx – Make changes to see hot reload
  2. Add navigation – React Navigation
  3. Add UI components – For your design studio
  4. Add features – Camera, image picker, etc.

Run These Commands Now! ๐Ÿ’ป

Open your terminal and execute:

cd ~/react/DesignStudioApp
cd ios && pod install && cd ..
npx react-native run-ios

This should launch your DesignStudioApp in the iOS simulator! ๐ŸŽ‰

For Android Emulator:

# Start Android emulator first, then:
npx react-native run-android

Step 6: Understanding Core Components ๐Ÿ“ฑ

Let me show you the main React Native components we’ll use:

Basic Components:

  • <View> – Like <div> in React web
  • <Text> – Like <p> or <span> in React web
  • <Image> – For displaying images
  • <ScrollView> – Scrollable container
  • <TouchableOpacity> – Touchable button
  • <TextInput> – Input field
  • <FlatList> – Efficient list rendering

Example App.tsx:

import React from 'react';
import {
  SafeAreaView,
  ScrollView,
  StatusBar,
  StyleSheet,
  Text,
  View,
  TouchableOpacity,
  Image,
} from 'react-native';

const App = () => {
  return (
    <SafeAreaView style={styles.container}>
      <StatusBar barStyle="dark-content" />
      <ScrollView contentInsetAdjustmentBehavior="automatic">
        <View style={styles.header}>
          <Text style={styles.title}>Design Studio App</Text>
          <Text style={styles.subtitle}>Welcome to your creative space</Text>
        </View>

        <View style={styles.content}>
          <TouchableOpacity style={styles.button}>
            <Text style={styles.buttonText}>Get Started</Text>
          </TouchableOpacity>
        </View>
      </ScrollView>
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#f8f9fa',
  },
  header: {
    padding: 24,
    alignItems: 'center',
  },
  title: {
    fontSize: 24,
    fontWeight: 'bold',
    color: '#333',
  },
  subtitle: {
    fontSize: 16,
    color: '#666',
    marginTop: 8,
  },
  content: {
    padding: 24,
  },
  button: {
    backgroundColor: '#007AFF',
    padding: 16,
    borderRadius: 8,
    alignItems: 'center',
  },
  buttonText: {
    color: 'white',
    fontSize: 18,
    fontWeight: '600',
  },
});

export default App;

Step 7: Styling in React Native ๐ŸŽจ

React Native uses a StyleSheet API similar to CSS:

import { StyleSheet } from 'react-native';

const styles = StyleSheet.create({
  container: {
    flex: 1,              // Like flex: 1 in CSS
    backgroundColor: '#fff',
    padding: 20,
  },
  text: {
    fontSize: 16,
    color: '#333',
    textAlign: 'center',
  },
});

Key Styling Differences:

  • Use backgroundColor instead of background-color
  • Use flexDirection instead of flex-direction
  • All style properties are camelCase
  • No cascade – styles are component-specific

Step 8: Development Tools ๐Ÿ”ง

Metro Bundler – Automatically starts when you run the app
React Native Debugger – For debugging
Flipper – Advanced debugging tool

Step 9: Common Commands ๐Ÿ’ป

# Start Metro bundler
npx react-native start

# Run on iOS
npx react-native run-ios

# Run on Android
npx react-native run-android

# Clear cache
npx react-native start --reset-cache

# Install dependencies
npm install
# or
yarn install

Step 10: Next Steps for Our Design Studio App ๐ŸŽจ

For the design studio app, you might want to add:

  1. Navigation – React Navigation
  2. UI Components – NativeBase, React Native Elements
  3. Image Handling – React Native Image Picker
  4. Animations – React Native Reanimated
  5. State Management – Redux Toolkit or Zustand
  6. Network Requests – Axios or fetch
  7. Storage – AsyncStorage

To get started right now, run these commands in your terminal:

cd ~/react/DesignStudioApp

npx react-native run-ios  # or run-android

This will create and run our first React Native app! ๐ŸŽ‰

Check our App in Github: https://github.com/MIRA-Designs/DesignStudioMobileApp

Issues: https://github.com/MIRA-Designs/DesignStudioMobileApp/issues


What is NPX? ๐Ÿค”

NPX is a package runner tool that comes with npm (Node Package Manager). It was introduced in npm version 5.2.0 and is now a standard part of the npm ecosystem.

NPX Full Name:

  • NPX = Node Package eXecute
  • It’s a command-line tool for executing npm packages

How NPX Works ๐Ÿ”ง

Basic Concept:

Instead of installing packages globally, npx allows you to:

  • Run packages directly without installing them permanently
  • Execute the latest version of a package
  • Avoid global installation clutter

NPX vs NPM Installation:

MethodCommandWhat Happens
Traditionalnpm install -g create-react-app
create-react-app my-app
Installs globally, then runs
NPXnpx create-react-app my-appDownloads, runs, then removes

Why Use NPX? ๐ŸŽฏ

1. No Global Installation Required

# Old way - install globally first
npm install -g create-react-app
create-react-app my-app

# NPX way - run directly
npx create-react-app my-app

2. Always Latest Version

# NPX ensures you get the latest version
npx create-react-app my-app

# vs global install might be outdated
npm install -g create-react-app  # Might be old version
create-react-app my-app

3. Saves Disk Space

  • No need to store packages globally
  • Temporary downloads are cleaned up automatically

4. Avoids Version Conflicts

  • Different projects can use different versions
  • No global version conflicts

Common NPX Use Cases ๐Ÿ“ฑ

1. Creating Projects

# React Native
npx react-native init MyApp

# React Web App
npx create-react-app my-web-app

# Next.js
npx create-next-app my-next-app

# Vue.js
npx create-vue my-vue-app

# Expo (React Native)
npx create-expo-app my-expo-app

2. Running Development Tools

# TypeScript compiler
npx tsc --init

# Linting
npx eslint .

# Testing
npx jest

# Package auditing
npx npm-check-updates

3. One-time Scripts

# Check bundle size
npx bundlesize

# Generate documentation
npx jsdoc

# Code formatting
npx prettier --write .

How NPX Works Behind the Scenes ๐Ÿ”

When you run npx some-package:

  1. Checks locally – Is the package in node_modules/.bin?
  2. Checks globally – Is it installed globally?
  3. Downloads temporarily – If not found, downloads to temp folder
  4. Executes – Runs the package
  5. Cleans up – Removes temporary files

Example Flow:

npx create-react-app my-app
  1. โœ… Check: Is create-react-app in local node_modules? No.
  2. โœ… Check: Is it installed globally? No.
  3. โฌ‡๏ธ Download: Downloads latest create-react-app to temp folder
  4. โ–ถ๏ธ Execute: Runs create-react-app my-app
  5. ๐Ÿ—‘๏ธ Cleanup: Removes temporary files

NPX Command Options ๐Ÿ› ๏ธ

Basic Syntax:

npx [options] <command>[@version] [command-args...]

Useful Options:

# Force download (ignore local/global)
npx --ignore-existing create-react-app my-app

# Use specific version
npx create-react-app@4.0.0 my-app

# Check what would be executed
npx --version create-react-app

# Run from specific package
npx -p typescript tsc --init

NPX vs NPM: Key Differences ๐Ÿ“Š

AspectNPMNPX
PurposePackage managerPackage executor
Installationnpm installNo installation needed
StoragePermanent (node_modules)Temporary
UsageInstall, then runRun directly
UpdatesManual (npm update)Always latest

Real-World Examples ๐ŸŒŸ

For Our React Native Project:

# Create the app
npx react-native init DesignStudioApp

# Instead of:
npm install -g @react-native-community/cli
react-native init DesignStudioApp

Development Workflow:

# Start Metro bundler
npx react-native start

# Run on iOS
npx react-native run-ios

# Run on Android
npx react-native run-android

Other Useful Commands:

# Check React Native version
npx react-native --version

# Upgrade React Native
npx react-native upgrade

# Doctor (check environment)
npx react-native doctor

Benefits Summary ๐ŸŽ‰

For Developers:

  • โœ… Cleaner system – No global package clutter
  • โœ… Always updated – Latest versions automatically
  • โœ… Faster setup – No pre-installation needed
  • โœ… Less conflicts – No version conflicts

For Projects:

  • โœ… Consistent environments – Everyone uses same versions
  • โœ… Easier setup – New team members can start quickly
  • โœ… Better CI/CD – Consistent builds

Pro Tips ๐Ÿ’ก

  1. Use NPX for project creation – Always use npx for scaffolding tools
  2. Check before installing globally – Ask yourself: “Do I need this globally?”
  3. Use specific versions when needednpx package@version
  4. Great for CI/CD – Ensures consistent tool versions

NPX is essentially a way to “try before you buy” – run packages without the commitment of installing them permanently! It’s become an essential tool in modern JavaScript development. ๐Ÿš€


Let’s see in Part 2.. Happy React Native Development ๐Ÿš€