Ionic emulate Ios fails to run The session does not open my app - ionic-framework

Ionic emulate ios failed on Mac OS Yosemite. Their have some cases were the ios device emulated, but shortly after the terminal console shoots up the error message below.
** BUILD SUCCEEDED **
No target specified for emulator. Deploying to iPhone-6 simulator
An error was encountered processing the command (code=146):
Invalid device state
An error was encountered processing the command (code=146):
Exception encountered connecting to CoreSimulatorBridge: Unable to connect to CoreSimulatorBridge
ENOENT, no such file or directory '/Users/yay/Library/Logs/CoreSimulator/2CAA2C39-7F22-4AF2-BBDE-86609188F37C/system.log'
Error code 1 for command: ios-sim with args: launch,/Users/yay/code/myApp/platforms/ios/build/emulator/myApp.app,--devicetypeid,com.apple.CoreSimulator.SimDeviceType.iPhone-6,--stderr,/Users/yay/code/myApp/platforms/ios/cordova/console.log,--stdout,/Users/yay/code/myApp/platforms/ios/cordova/console.log,--exit
Error: /Users/yay/code/myApp/platforms/ios/cordova/run: Command failed with exit code 2
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

The issue is because you used sudo to create and/or build the project.
Just input these commands (without the $ of course):
1) Remove with sudo
$ sudo ionic platform remove ios
2) Add iOS back without sudo
$ ionic platform add ios
3) Run iOS emulator
$ ionic emulate ios
Source: https://github.com/driftyco/ionic/issues/4052 (rajkotecha's comment)

Do NOT use sudo when creating or building the project.
Please see https://github.com/driftyco/ionic/issues/4052

I've encountered this issue before, and I believe you messed up with your permission. However, I managed to solve it by reinstall everything from scratch (NOT reformat OS). I suggest you may try to remove all your Xcode, ionic, cordova, and ios-sim content and reinstall again.
Delete your Xcode from your Mac OS.
Remove everything inside:
/usr/local/bin
/usr/local/include
/usr/local/lib/dtrace
/usr/local/share/man/man1
/usr/local/share/systemtap/tapset/
Delete the folder:
/usr/local/lib/node_modules
Once you done the instruction above, kindly use your spotlight to search for keywords such as node, cordova, ionic, etc... to see whether it is still exist or not. Please also ensure yourApp within your Users/username folder is deleted.
You may also try to use your terminal input:
npm -v
cordova -v
ionic -v
It will shows nothing/not found if you've deleted everything completely.
Now you can download and install Xcode from App Store, and wait for Xcode is fully installed in your Mac, then proceed to here to start again your ionic project.
Lastly, once you begin to create an ionic project, by right you no need to use any sudo commands anymore in creating or building this project.
Example:
ionic build ios
Instead of:
sudo ionic build ios
It should be working unless you are not the root user.
Happy coding and have a nice day! :D

Related

Flutter simply showing 'sysctl -n hw.optional.arm64' returned unexpected output: ''

Not sure which details are relevant so I'll include as many as possible.
Had to upgrade flutter today and instead of working when I typed in 'flutter upgrade' into android studios terminal/Iterm2/terminal zsh I was met with the following response.
'sysctl -n hw.optional.arm64' returned unexpected output: ''
When I search for this issue the only thing i can find is this post which states that sysctl can't be found. The path does appear to be in my .zshrc but still not working. I can't use which or where sysctl as it just says 'sysctl not found'
When I try to upgrade flutter through brew (brew install --cask flutter) it downloads fine but on installing it throws the following error:
==> Purging files for version 3.3.5 of Cask flutter
Error: It seems there is already a Binary at '/opt/homebrew/bin/dart'.
I can't continue working as I need the new flutter version and it seems the web doesn't have much to show for this particular error.
I can't flutter --version, flutter doctor or anything of the sort as I just get the same message.
I'm using:
MacOS monterey 12.6 macbook air.
Android studios
Iterm2
Ohmyzsh
When I open android studios it shows me the following:
"Flutter device daemon #1 exited (exit code 1), stderr: 'sysctl -n hw.optional.arm64' returned unexpected output: '' in a pop up window.
Pubspec has been edited > get dependencies > Upgrade depenedencies: Both of which have the same error as in the title.
The current configured flutter SDK is not known to be fully supported. Please update your SDK and restart intelliJ which I think is what I've been trying to do.
This is an answer I hope will be helpful for others who have the same issue.
Other answers suggested a fix by just updating the path document (.zshrc) but this is what helped me as that did not and my paths were up to date.
Sadly, it's as simple as manually deleting all my flutter SDK files locally. Downloading them again (this time the latest one) and unzipping it into the same place. Didn't even have to update the path).
Worked a charm, issues appear to be all gone except that the dialogue in android studios is still saying that there are dependencies that need getting and upgrading (but doesn't go away even when I've run it).
I solved it by removing the old flutter SDK, downloading the latest version, and setting it up again.
it works perfectly for me!

flutter stuck on Compiling, linking and signing

Flutter project is stuck in Compiling, linking and signing... i dont just understand why this is stuck here...
even using verbose i dont get any stack trace on why this is stuck...
Launching lib/main.dart on iPhone 13 Pro Max in debug mode...
Running pod install... 11.6s
Running Xcode build...
└─Compiling, linking and signing...
The problem should be in the existing project created on previous environment (old versions) and has to be resolved by creating a new one and moving content in.
Move all my custom contents from existing my project (assets, fonts, lib folders and config files...) to this new project and ran the command : the flutter build ios command works well now !
following this : Fixing Xcode 9 issue: "iPhone is busy: Preparing debugger support for iPhone"
I TRIED :
On Xcode:
Go to "Window" -> "Devices and Simulators"
"Unpair iPhone" (on the side list, right clic)
Then:
Unplug and plug again the USB cable
Press Trust in the prompt message in the device
in Flutter Terminal, paste and enter :
flutter clean
flutter pub get
cd ios
pod install --repo-update
cd ..
Then run the app.
==> Worked only 1st time for me.
My work around for launching IOS devices for now:
Each time I want IOS device,
I COPY/ PASTE and press ENTER on the Terminal:
flutter clean
flutter pub get
cd ios
pod install --repo-update
cd ..
flutter run

Error with Spawned command: npminstall

I am trying to run a sample application from
https://ionicframework.com/getting-started/.
But I am getting the error - there was an error with the spawned process: npminstall every time I try to run the application. Any help is highly appreciated.
For me it was only to upgrade to new version of npm
npm install -g npm
Spawned command error comes when you try to start a new ionic or cordova app, that gets downloaded from git. This error occurs because your network proxy blocks download a new blank app from git.
To avoid such kind of error try removing the proxies.
1. If you are in a company using their proxy its not possible to do that, so use your own data to do that.
Try downloading a blank app from git using your own data, don't use company network which has proxy enabled.
It will download but while installing the app you will get error like:
Error with start undefined.
Error with spawned command npminstall.
Don't worry a folder will be downloded,
Go to cmd and go inside that app directory and run ionic serve
It will give error like ionic.config.json file didn't find.
create a file with the name ionic.config.json inside the app file.
inside that file paste the following:
{ "name": "your app name", "app_id": "", "v2": true, "typescript": true }
now try running the command ionic serve
your app will run.
I had the similar problem but it worked for me.
install npm globally
npm install -g npm
create a app without installing its packages
ionic start app --v2 --skip-npm
seems ok till now?then
cd app
install packages
npm install --save
done!try to start your ionic app
ionic serve

Command Line Tool - Error - xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH

I am getting this error while building the SwiftJSON framework to the Some Xcode project through Carthage Dependency Manager.
Sivaramaiahs-Mac-mini:GZipDemoApp vsoftMacmini5$ carthage update
--platform iOS
*** Fetching GzipSwift
*** Fetching SwiftyJSON
*** Checking out GzipSwift at "3.1.1"
*** Downloading SwiftyJSON.framework binary at "3.1.3"
*** xcodebuild output can be found in /var/folders/7m/y0r2mdhn0f16zz1nlt34ypzr0000gn/T/carthage-xcodebuild.apLXCc.log
A shell task (/usr/bin/xcrun xcodebuild -project
/Users/vsoftMacmini5/Desktop/GZipDemoApp/Carthage/Checkouts/GzipSwift/Gzip.xcodeproj
CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES -list)
failed with exit code 72:
xcrun: error: unable to find utility "xcodebuild", not a developer
tool or in PATH
I solved that problem by setting the Command Line Tools in Xcode. Go to:
Xcode > Preferences > Locations
And select the command line tool from the dropdown. If you have only one version of Xcode installed, there should be only one option. If you have several versions of Xcode, then you must choose the one you need.
Update (added image for reference)
The simplest fix is from CLI:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
(this should be path to your Xcode.app)
By the way this can happen even if you have only one version of Xcode . It happens when you instal homebrew before the first Xcode installation (which makes sense because you may want to install Xcode through mas install 497799835 and mas needs homebrew).
Following command worked for me
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

"ERROR : No emulator images (avds) found" running ionic on osx 10.10

This is the full error message I got after running ionic emulate android
*running cordova emulate android
Running command: /Users/DeadLift/Documents/ionic/myApp/hooks/after_prepare/010_add_platform_class.js /Users/DeadLift/Documents/ionic/myApp
add to body class: platform-android
Running command: /Users/DeadLift/Documents/ionic/myApp/platforms/android/cordova/run --emulator
ANDROID_HOME=/usr/local/Cellar/android-sdk/24.1.2
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
/Users/DeadLift/Documents/ionic/myApp/platforms/android/cordova /node_modules/q/q.js:126
throw e;
^
ERROR : No emulator images (avds) found.
1. Download desired System Image by running: /usr/local/Cellar/android-sdk/24.1.2/bin/android sdk
2. Create an AVD by running: /usr/local/Cellar/android-sdk/24.1.2/bin/android avd
HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver
Error: /Users/DeadLift/Documents/ionic/myApp/platforms/android/cordova/run: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23) *emphasized text*
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)*
I follow all the above by creating an avd and it give me the same message again.
Thanks.
Vikas's answer is pretty spot on, however (sometimes) just running android avd won't work, which is what I found out after hours of trying to get it working.
When ever I ran android avd in my terminal it would give me the following error:
zsh: command not found: android
This is because I needed to add the Android SDK paths for the platform-tools and tools to my zshrc file (you might be running bash or something else on your terminal).
Simple fix was to add these files to my zshrc PATH environment, You can do this too by using your favourite text editor and depending on what shell you're using.
This link: http://docs.phonegap.com/en/2.8.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android helped me out a hell of a lot getting this fixed.
So I used subl ~/.zshrc (because sublime is my text editor and i've setup symlinks)
I Found my exports PATH and changed it to represent the following:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/dev/.rbenv/versions/2.2.3/bin/ruby:/Users/dev/Library/Android/sdk/platform-tools:/Users/dev/Library/Android/sdk/tools:$PATH"
I then saved the file, closed down sublime and ran source ~/.zshrc in my terminal window, and now I can run android avd and it now opens the Android Virtual Device Manager with no problems.
A reminder your shell might be different to mine (i.e. not running with zsh)and your exports PATH might look different as well, but it's pretty easy to figure out, and the link above will also help if you get stuck.
Actually it is not able to find AVD (Android virtual device). You have to create one.
Type "android avd" from Command Promt to use the graphical manager to setup an emulator image to work with for running your app on. The graphical tool is fairly straight forward to use.