Skip to content

Instantly share code, notes, and snippets.

@andrewsadowski
Last active June 20, 2019 23:12
Show Gist options
  • Select an option

  • Save andrewsadowski/f3b69f125f781f18a20bc5358df714ce to your computer and use it in GitHub Desktop.

Select an option

Save andrewsadowski/f3b69f125f781f18a20bc5358df714ce to your computer and use it in GitHub Desktop.

Common RN errors and fixes

NPM Clean Script:

rm -rf node_modules/ && rm -rf /tmp/metro-bundler-cache-* && watchman watch-del-all

Issue: Android: Unable to load script from assets 'index.android.bundle'

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

Issue: iOS Simulator not opening properly:

 rm -rf /tmp/metro-bundler-cache-* && watchman watch-del-all

Error:: typeError: undefined is not an object (evaluating '_this._setComponentRef.bind')

  • Fix: check bable.config.js, && add module: '@babel/plugin-transform-flow-strip-types' Also run:
react-native start --reset-cache

Unresolved Android Dependencies

  • Fix: Update the build.gradle file in android/app/
android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.micropayments"
        missingDimensionStrategy "RNN.reactNativeVersion", "reactNative55_4"
        minSdkVersion 18
        targetSdkVersion 25
        versionCode 101
        versionName "2.0"
        multiDexEnabled true
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        manifestPlaceholders = [
            FABRIC_API_KEY: project.env.get("FABRIC_API_KEY"),
            FABRIC_SECRET: project.env.get("FABRIC_SECRET")
        ]
    }...

'config.h' solution:

cd ./node_modules/react-native && scripts/ios-install-third-party.sh && cd third-party && cd $(ls | grep 'glog' | awk '{print $1}') && ./configure

Fixing Xcode:

Potential Fix *Note: If using an old version of React-Native but a new version of Xcode, you need to disable the new build system in favor of the legacy one. Follow these steps: -In Xcode, Select File -> Project/Workspace Setting. You will see a Build System option to select the Legacy Build System as shown below

Overview

Sometimes Xcode can get in an odd state. This guide is a progression of steps to reset things. After each step, test to see the problem is resolved.

Clean the Build

If the issue is building, the first step is to clean the build, which will force a clean build from scratch. Choose Product, and Clean.

Reset the Simulator

Launch the iOS Simulator. From the iOS Simulator menu, choose Reset Content and Settings..., and click Reset to confirm.

Delete Derived Data

Choose Window -> Organizer. Select the Projects tab. Select your project on the left. Next to the Derived Data line, there click the Delete button.

When Xcode creates Derived Data when it index your files, among other things.

It can also be deleted manually at the following path: /Users/{UserName}/Library/Developer/Xcode/DerivedData

Delete the Module Cache

Within the same folder as your project's Derived Data is a Module Cache. When Code Completion stopped working, deleting this fixed it.

Close Xcode and delete the ~/Library/Developer/Xcode/DerivedData/ModuleCache directory.

Delete Xcode Preferences

A long-shot next step is to reset Xcode's preferences. In your terminal, run:

defaults delete com.apple.dt.Xcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment