react-native run-ios keeps on failing - ios

after updating MacOS to Big Sur and since Legacy build is deprecated
react-native run-ios does not work anymore, I've tried so many solutions but no progress I've been suffering with this for around 3 days.
side note that build on xcode succeeded
versions:
react-native: 0.59.10
xcode: 12
and I'm using iPhone 11 simulator and I also tried a real iPhone 11 device
result of npx react-native run-ios
on simulator:
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 myapp.xcworkspace
** BUILD FAILED **
The following build commands failed:
Ld /myapp/ios/build/Build/Products/Debug-iphonesimulator/myapp.app/PlugIns/myapp.xctest/myapp normal
(1 failure)
another one on the simulator:
info ** BUILD SUCCEEDED **
info Installing DerivedData/Build/Products/Debug-iphonesimulator/myapp.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
error Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier DerivedData/Build/Products/Debug-iphonesimulator/myapp.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
on device:
info ** BUILD SUCCEEDED **
info installing and launching your app on Menna’s iPhone...
info ** INSTALLATION SUCCEEDED **
but the application doesn't appear on the device and I don't know how is that even possible?!
any help would be appreciated

SOLVED
in xcode, go to Project Settings > change build system to new build system
click on Advanced, then choose Custom (Relative to workspace) and specify locations as following:
Products: build/Build/Products
Intermediates: build/Build/Intermediates.noindex
in vs code, open node_modules/#react-native-community/cli/build/commands/runIOS/runIOS.js
and change DerivedData/Build/Products/${configuration}-${device}/${appName}.app
to build/Build/Products/${configuration}-${device}/${appName}.app;
delete ios/build and DerivedData content
run react-native run-ios again

try:
sudo npm install -g ios-deploy --unsafe-perm
and next:
yarn ios --device "YOUR_DEVICE_NAME"

Related

react-native build failing due to PhaseScriptExecution error

Environment
Mac OS X Version 12.1 (Apple M1 chip)
Xcode Version 13.2.1
Simulator Version 13.2 (972.2)
react-native-cli 7.0.3
node v18.4.0
The Issue
This is my first time working on developing an app using React Native. I am trying to run my React Native project on Xcode's simulator, using npx react-native run-ios. However, I am encountering this error message.
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 MCompass.xcworkspace.
Command line invocation:
/Users/brx/Downloads/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace MCompass.xcworkspace -configuration Debug -scheme MCompass -destination id=DC3C75E6-19FD-4B80-87B1-62BF6404ED20
...
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/brx/src/projects/test/MCompass/ios/build/MCompass.build/Debug-iphonesimulator/MCompass.build/Script-00DD1BFF1BD5951E006B06BC.sh (in target 'MCompass' from project 'MCompass')
(1 failure)
Between the first error message and ** BUILD FAILED **, there were many lines of output listing exports.
I've installed dependencies using both yarn and npm. I've also looked at several other threads with this same issue, but none of the solutions (such as having only one version of nvm or running react-native upgrade) have been successful. Does anyone have any tips?
I had my root folder name "REACT NATIVE", changing it to "REACT_NATIVE" fixed the error as the folder that contains your react native project cannot contain white spaces.
The second solution would be running Xcode with rosetta. This is only applicable for M1 chip macbooks as there are few times Xcode projects fail because of this reason. Please refer to below link for reference:
https://penny-huang.medium.com/xcode-how-to-run-ios-simulator-on-m1-mac-66101b9fccd8

Build of reactNative app fails on IOS using CLI and xcode

I tried to build a simple reactNative app for ios using CLI and xcode.
Both builds fails with a different error.
Prior to both builds, I ran the following
npm install
pod install
Build using CLI
The steps are:
npx react-native run-ios
Having done so I found some errors on the log file which I am attaching
manish.basdeo#AMAC02SNHPHFVH3 Top100 % npx react-native run-ios
info Found Xcode workspace "Top100.xcworkspace"
info Launching iPhone 11 (iOS 13.3)
info Building (using "xcodebuild -workspace Top100.xcworkspace -configuration Debug -scheme Top100 -destination id=37E2E23C-60E2-42D4-8053-525A907ED979")
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 Top100.xcworkspace. Run CLI with --verbose flag for more details.
Build settings from command line:
TOOLCHAINS = com.apple.dt.toolchain.XcodeDefault
Prepare build
note: Using legacy build system
<unknown>:0: error: no such file or directory: '/Users/manish.basdeo/Desktop/Top100/Top100/ios/Pods/#/Users/manish.basdeo/Library/Developer/Xcode/DerivedData/Top100-etyxtwwnmplrdtdxgkmuhxstoudh/Build/Intermediates.noindex/Top100.build/Debug-iphonesimulator/Top100.build/Objects-normal/x86_64/Top100.SwiftFileList'
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
** BUILD FAILED **
The following build commands failed:
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(1 failure)
2) Build using XCODE
How can I fix both errors?

react-native run-ios Could not find iPhone X simulator | XRPackageModel 9.0.omo

I first started my project with Expo and ejected it. Now, I'm trying to run the command react-native run-ios and it comes back with this error:
CoreData: annotation: Failed to load optimized model at path '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/Frameworks/InstrumentsPackaging.framework/Versions/A/Resources/XRPackageModel.momd/XRPackageModel 9.0.omo'
Then it gives another error:
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 blahblahblah.xcworkspace
$ react-native run-ios
info Found Xcode workspace blahblahblah.xcworkspace
CoreData: annotation: Failed to load optimized model at path '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/Frameworks/InstrumentsPackaging.framework/Versions/A/Resources/XRPackageModel.momd/XRPackageModel 9.0.omo'
info Launching iPhone X (iOS 12.2)...
info Building using "xcodebuild -workspace blahblahblah.xcworkspace -configuration Debug -scheme weather -destination id=E05006E8-DEB3-4317-967B-40759D275997 -derivedDataPath build/weather"
info User defaults from command line:
info IDEDerivedDataPathOverride = /Users/blahblahblah/Desktop/blahblahblah/ios/build/blahblahblah
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 blahblahblah.xcworkspace
Any help would be greatly appreciated!
Thank you!
use this.
react-native run-ios --simulator="iPhone 8"
This issue:
https://github.com/react-native-community/cli/pull/414
was fixed on #react-native-community/cli v1.9.8:
https://github.com/react-native-community/cli/releases/tag/v1.9.8
A bump in your yarn.lock to some version over 1.9.8 should fix it.

react-native run-ios: The bundle identifier of the application could not be determined

I am playing with React-Native and trying to build a Hello-world app, however, I am still unable to run the app. If I run react-native run-ios, I get this error:
...
Build system information
unexpected service error: The Xcode build system has crashed. Please close and reopen your workspace.
Build system information
error: unexpected service error: The Xcode build system has crashed. Please close and reopen your workspace.
** BUILD FAILED **
The following commands produced analyzer issues:
Analyze /Users/adam/react-native_dev/JustATributeApp/node_modules/react-native/React/Base/RCTModuleMethod.mm normal x86_64
(1 command with analyzer issues)
The following build commands failed:
Analyze /Users/adam/react-native_dev/JustATributeApp/node_modules/react-native/Libraries/Text/RCTTextAttributes.m normal x86_64
(1 failure)
Installing build/Build/Products/Debug-iphonesimulator/JustATributeApp.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22):
Failed to install the requested application
The bundle identifier of the application could not be determined.
Ensure that the application's Info.plist contains a value for CFBundleIdentifier.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/JustATributeApp.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
I found quite a few topics with this error, but none of them led to solving it.
Here is some additional information:
react-native-cli: 2.0.1
react-native: 0.56.0
xcode 10.0 beta 2 (10L177m)
How do I debug/fix this issue?
Thank you
The key piece of the error message is Ensure that the application's Info.plist contains a value for CFBundleIdentifier. Here's how we can fix that.
Open yourprojectname.xcodeproj in Xcode, and check the bundle identifier under the 'General' tab. It should have a value. Mine is com.yourprojectname.app.ios.triplets . If that field is blank, set the bundle identifier to something. Modifying this field will make the changes to your info.plist.
I suggest restarting React.
To do so, just run the following commands:
# Kill current processes
killall node -9
# Start React - Native
react-native start
# Run android
react-native run-android or react-native run-ios
That should do the trick.

Ionic Emulate iOS/Android command not working

Context: I am currently on Ionic version 3.15.2. The 'ionic serve' command works. The 'ionic cordova emulate ios' and 'ionic cordova emulate android' do not work. I have tried deleting/reinstalling certain packages and dependencies from Ionic but nothing has helped. I have a feeling I need to delete/reinstall Xcode all together but I figured I would ask for help here first. This is the error message I get on my terminal when I try to use the Ionic simulator/emulator:
Command /usr/bin/codesign failed with exit code 1
** BUILD FAILED **
The following build commands failed:
CodeSign build/emulator/****app.app
(1 failure)
Error: Error code 65 for command: xcodebuild with args:
-xcconfig,/Users/*****/Desktop/*****/platforms/ios/cordova/build-debug.xcconfig,-workspace,****app.xcworkspace,-scheme,****app,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS
Simulator,name=iPhone
5s,build,CONFIGURATION_BUILD_DIR=/Users/*****/Desktop/****/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/****/Desktop/****/platforms/ios/build/sharedpch
[ERROR] An error occurred while running cordova emulate ios (exit code 1).
Note: I used the asterisks in place of the path for privacy reasons
It's weird that ionic serve works but the other two commands don't...
Even ionic info should fail with the latter error.
It's because of the module #ionic/cli-plugin-proxy. As soon as I uninstalled it I could successfully run ionic info. But it detected IONIC_HTTP_PROXY in my environment and asked me to install it again.
So I did manually later, but the error returned. So I installed the missing module using npm install -g #ionic/cli-framework. After that I could successfully run ionic info again.
Therefor I guess it's an unresolved dependency issue inside the #ionic/cli-plugin-proxy module.

Resources