react-native ios build xcode 12/13 (react-native run-ios) failed with PhaseScriptExecution and CompileSwiftSources error - react-native

i am trying to build react-native on ios, but it is throwing error
versions:
react-native info
info Fetching system and libraries information...
System:
OS: macOS 11.4
CPU: (4) x64 Intel(R) Core(TM) i3-8100B CPU # 3.60GHz
Memory: 12.08 GB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 14.16.1 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.1.0 - /usr/local/bin/npm
Watchman: 2021.11.01.00 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7678000
Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
npmPackages:
react: 17.0.1 => 17.0.1
react-native: ^0.64.2 => 0.64.2
npmGlobalPackages:
create-react-native-app: 3.5.3
react-native-asset: 2.0.1
react-native: 0.60.6
In Xcode build it fails here in below location:
Details:
if you run
react-native run-ios
it says two commands have failed just like above, they are :
The following build commands failed:
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'FBSDKCoreKit' from project 'Pods')
PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/user204444/Library/Developer/Xcode/DerivedData/xUI-awhgnkdgdnqqhybhizmenofqnvvg/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-50E87D65053FE4ADFF2772B365B2C6E0.sh
(in target 'FBReactNativeSpec' from project 'Pods')
(2 failures)
Any help would be greatly appreciated

1. To fix the first error try:
`rm -rf ./node_modules`
`yarn install` // or npm install
`cd ios && rm -rf ./Pods && rm -rf Pofile.lock && pod install && cd ..`
`npx react-native run-ios`
2. To fix the second error:
try to remove/comment flipper in Podfile
Make sure you have excluded the arm64 architecture for simulators
Note: I had a PhaseScriptExecution error showing up after upgrading Xcode to 13.1:
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.67.dylib.
I fixed it with:
brew update and brew install.
If still not working please attach to your question:
full content of Podfile
result of pod install command
full log for react-native run-ios command
Your errors are too generic to debug without the full the full error log.

I always run into this problem. Follow these steps to remove the error.
From the root of the project, do cd ios
pod deintegrate
pod install
If this doesn't help then remove node_modules and then try above after npm install or yarn install, as follows.
On the root of the project, do the following
rm -rf node_modules
npm install / yarn install
cd ios
pod deintegrate
pod install
cd ..
react-native run-ios

Related

Latest Install for Apple M1 react-native

What are the latest installation instructions for Apple M1 Macbook Pro? (this works just fine on Ventura Intel)
I've tried several things and can't get the basic
npx react-native init mainapp
✔ Downloading template
✔ Copying template
✔ Processing template
✖ Installing CocoaPods dependencies (this may take a few minutes)
✖ Installing CocoaPods dependencies (this may take a few minutes)
error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./mainapp/ios && pod install".
CocoaPods documentation: https://cocoapods.org/
then changing to the ios folder and issuing "pod install" yields:
Fetching podspec for hermes-engine from ../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec
[!] Failed to load 'hermes-engine' podspec:
[!] Invalid hermes-engine.podspec file: undefined method `exists?' for File:Class.
from mainapp/node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec:46
VERSIONS
pod --version
1.11.3
node -v
v19.4.0
npm -v
9.2.0
npx -v
9.2.0
yarn -v
1.22.19
ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin21]
(yet in /Library/Ruby/Gems/2.6.0/ is listed?)

React Native Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0

after installing some packages like react-native-safe-area-context or react-native-screen, I always have this problem: can't run the app
when I run yarn android:
> Configure project :react-native-async-storage_async-storage
Subproject ':react-native-async-storage_async-storage' has location 'D:\ewm\git\itc\node_modules\#react-native-async-storage\async-storage\android' which is outside of the project root. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0.
> Configure project :react-native-safe-area-context
Subproject ':react-native-safe-area-context' has location 'D:\ewm\git\itc\node_modules\react-native-safe-area-context\android' which is outside of the project root. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0.
> Task :react-native-safe-area-context:compileDebugKotlin
w: D:\ewm\git\itc\node_modules\react-native-safe-area-context\android\src\main\java\com\th3rdwave\safeareacontext\SafeAreaView.kt: (50, 23): 'getter for uiImplementation: UIImplementation!' is deprecated. Deprecated in Java
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
* What went wrong:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 26s
when I run react-native info:
OS: Windows 10 10.0.19044
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU # 2.60GHz
Memory: 3.90 GB / 15.96 GB
Binaries:
Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.3.1 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 29, 30, 31, 32
Build Tools: 30.0.1, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0
System Images: android-Tiramisu | Google Play Intel x86 Atom_64
Android NDK: Not Found
Windows SDK:
AllowAllTrustedApps: Disabled
Versions: 10.0.18362.0, 10.0.19041.0
IDEs:
Android Studio: Version 2021.1.0.0 AI-211.7628.21.2111.8193401
Visual Studio: 16.11.32106.194 (Visual Studio Community 2019)
Languages:
Java: 17.0.2
npmPackages:
#react-native-community/cli: Not Found
react: Not Found
react-native: Not Found
react-native-windows: Not Found
npmGlobalPackages:
*react-native*: Not Found
use ./gradlew clean to delete all previous build and rebuild
In my case the issue was to do with duplicate files in android resource folders. I used below commands to remove the duplicates.
rm -rf ./android/app/src/main/res/drawable-*
rm -rf ./android/app/src/main/res/raw
See: https://stackoverflow.com/a/57975287/10030693

Error: ENOENT: no such file or directory, open 'fs.js

I am working in React Native using expo-cli.
All I did till now is
expo init myapp
And after adding a text to my app.js file, I tried to do
npm start
which gave me this error
Error: ENOENT: no such file or directory, open 'fs.js
I have not used anything related to fs.js and as far as I can see from the errors page, the error is in
.../node_modules/metro/src/Server.js:99:24)
And other file stack system is referring it to metro.
I am using VS code and Linux Mint for development. My expo version is: 4.3.0
The result of expo diagnostics
Expo CLI 4.3.0 environment info:
System:
OS: Linux 5.4 Linux Mint 20.1 (Ulyssa)
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 10.19.0 - /usr/bin/node
npm: 6.14.4 - /usr/bin/npm
npmPackages:
expo: ~40.0.0 => 40.0.1
react: 16.13.1 => 16.13.1
react-dom: 16.13.1 => 16.13.1
react-native: https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz => 0.63.2
react-native-web: ~0.13.12 => 0.13.18
npmGlobalPackages:
expo-cli: 4.3.0
Expo Workflow: managed
try to start as an administrator with sudo yarn start
I managed to solve it here but I'm not sure what caused this problem.
first i restarted the computer, when i did this another error similar to this one appeared
How can i make this working. I tried giving sudo permissoins
so I ran
chmod -R 0777 / tmp
But it didn't work. so I deleted the node module and ran
sudo yarn install
yarn start --reset-cache
And the problem was solved

There are no Libraries linked in iOS project of react-native

I have tried to create a new project in react-native, After creating when I have opened the iOS project, in libraries folder I could not any libraries and i am not able to run the iOS Project.
I have tried react-native run-ios
Got error like "error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening AppName.xcodeproj."
Steps To Reproduce
Lis
cd AppName
open ios/AppName.xcodeproj inxcode and build.
react-native init AppName
I have tried to create multiple projects, but still no luck of getting libraries
react-native info logs
System:
OS: macOS 10.14.5
Binaries:
Node: 11.3.0 - /usr/local/bin/node
Yarn: 1.5.1 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.5 => 0.60.5
npmGlobalPackages:
react-native-cli: 2.0.1
I have fixed the issue, by searching over SO and found a solution
In React-native 0.60 +, you need to install pods
Step1: cd ios
Step2: pod install
Step3: pod update
After completion you can run.

react-native eject error Unrecognized command "eject"

I'm trying to eject my app to generate Android folder. I knew it worked before, but when I type react-native eject in my React Native project's root directory I'm getting:
can-mbp:MyApp can$ react-native eject
warn Your project is using deprecated "rnpm" config that will stop working from next release. Please use a "react-native.config.js" file to configure the React Native CLI. Migration guide: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
warn Package "bugsnag-react-native" is using deprecated "rnpm" config that will stop working from next release. Please notify its maintainers about it.
warn Package "react-native-onesignal" is using deprecated "rnpm" config that will stop working from next release. Please notify its maintainers about it.
warn Package react-native-onesignal has been ignored because it contains invalid configuration. Reason: Unknown option dependency.platforms.ios.sourceDir with value ""./ios"" was found. This is either a typing error or a user mistake. Fixing it will remove this message.
error Unrecognized command "eject".
info Run "react-native --help" to see a list of all available commands.
I've searched for it but every answer points out to that react-native eject is simply the correct form and I couldn't find anything regarding that it doesn't work.
Here is my system info from react-native info command:
System:
OS: macOS 10.14.5
CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU # 3.10GHz
Memory: 62.21 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.4.0 - /usr/local/bin/node
Yarn: 1.17.0 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 10.2/10E125 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.0-rc.2 => 0.60.0-rc.2
What am I doing wrong?
Since create-react-native-app is deprecated this functionality is no longer needed.
Due to this pr it's gone!
Personaly I don't like it but run npx react-native init YourProjectName and copy over what's necessary.
Update :
I copied to removed code and made a small package : https://www.npmjs.com/package/react-native-eject
Always working for me, first install in your project
yarn add react-native-eject
and then run
react-native eject
make sure you have install yarn in your pc
Type the following command
npx react-native eject