I cant get my ionic app to open in iOS emulator - xcode

My new ionic app won't run in the iOS emulator.
Its a fresh install of ionic and Xcode, these are my steps:
npm install -g ionic
ionic start myApp tabs
ionic cordova platform add ios
ionic cordova build ios
ionic cordova emulate ios
Then I get the following error:
No target specified for emulator. Deploying to undefined simulator
/localhost/myApp/platforms/ios/build/emulator/MyApp.app/Info.plist
file not found.
According to this thread (Fresh Ionic Fails to Emulate iOS 12 - Info.plist file not found) it should work with the following command:
ionic cordova emulate ios -- --buildFlag="-UseModernBuildSystem=0"
But then I get the following error:
No target specified for emulator. Deploying to undefined simulator
Device type "com.apple.CoreSimulator.SimDeviceType.undefined" could not be found.
And then according to this thread (Issues starting iOS simulator from CLI) it should work by updating ios-sim like this:
cd platforms/ios/cordova && npm install ios-sim#latest
But I still get the following error:
No target specified for emulator. Deploying to undefined simulator
Device type "com.apple.CoreSimulator.SimDeviceType.undefined" could not be found.
Ionic:
ionic (Ionic CLI) : 4.10.2 (/usr/local/lib/node_modules/ionic)
Ionic Framework : #ionic/angular 4.0.1
#angular-devkit/build-angular : 0.12.4
#angular-devkit/schematics : 7.2.4
#angular/cli : 7.2.4
#ionic/angular-toolkit : 1.4.0
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib#8.1.1)
Cordova Platforms : ios 4.5.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 4 other plugins)
System:
ios-deploy : 1.9.4
ios-sim : 7.0.0
NodeJS : v10.15.1 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS Mojave
Xcode : Xcode 10.1 Build version 10B61

The problem lie with ios-sim package which couldn't detect running simulators.
Updating to 8.0.1 with the following steps resolved the issue for me.
force update ios-sim to a working version
IMPORTANT needs to be done from inside the platforms/ios/cordova directory.
cd platforms/ios/cordova && npm install ios-sim#8.0.1
check if devices are now listed, takes a few seconds
ionic cordova emulate --list
installs appscript if not installed already
ionic cordova build ios
try to deploy to simulator
ionic cordova emulate --release --prod --livereload ios -- --buildFlag="-UseModernBuildSystem=0"
This will find any running simulator and deploy the app

Try just building the project and then running it from Xcode instead first.
ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0"
Then open the platforms/ios folder in Xcode and you'll be able to run it from there plus see any errors there may be with the project. When you eventually decide to push the app to the store you'll need to do this anyway.
EDIT
Then try targeting a specific emulator:
ionic cordova emulate ios --list get list of available targets to copy into the next command.
ionic cordova emulate --livereload ios -- --buildFlag="-UseModernBuildSystem=0" --target="iPhone-X, 12.1" example targeting iPhone XR.

The issue is related to a breaking changes on Xcode 10 not already reflected on ios-sim. You can check on ion-sim repo issue "List empty of devices simulator with Xcode 10".
The issue have already been fixed but is waiting for a new release submission.
You can continue running your App on emulator directly from Xcode.

Related

Xcode XCBuild support error for ionic build

I have a ionic project that I am trying to build on iOS.
When running ionic build ios, it gives this error:
FIXME: Implement XCBuild support for macros in overriding parameters
with condition sets:
CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Developer
Error: Error code 1 for command: xcodebuild with args:
-xcconfig,/Users/Person/ProjectA/platforms/ios/cordova/build-debug.xcconfig,-project,ProjectA.xcodeproj,ARCHS=i386,-target,ProjectA,-configuration,Debug,-sdk,iphonesimulator,build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=/Users/Person/ProjectA/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/Person/ProjectA/platforms/ios/build/sharedpch
I have tried:
Remove platform and add platform
Change CODE_SIGN_IDENTITY[sdk=iphoneos*] from iPhone Distributor to iPhone Developer in build-release.xcconfig
Re-did signing from xcode to try both automatic and manual signing
but all were not successful.
I am running:
Cordova CLI: 6.1.1
Ionic Framework Version: 2.0.0-beta.4
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.0.0-beta.20
ios-deploy version: 1.9.4
ios-sim version: 5.0.8
Node Version: v4.4.7
Xcode version: Xcode 11.1 Build version 11A1027
It is an old ionic version but able to run on my old macbook air (OS: High Sierra). I am now using a new macbook air (OS: Mojave) and trying to setup the environment.
Any suggestions?
I was getting this error after re-adding the iOS platform to my project with cordova#8.1.2/cordova-ios#4.5.4, even with a build.json file included in my project. I manually upgraded to cordova-ios#5.1.1 (by specifying the version in the cordova platforms add ios#5 command) and the error went away.

Ionic Unexpected key "NSMainNibFile~ipad" while parsing <dict/>

I am having an issue while using add platform ios command to build ios app in ionic project. The project builds successfully in android but not is IOS.
Command used:
ionic cordova platform add ios
Error:
Using cordova-fetch for cordova-ios#~4.5.4
Adding ios project...
Creating Cordova project for the iOS platform:
Path: ../../documents/a-copy/platforms/ios
Package: com.qodelogix.assurant
Name: Assurant Drive
iOS project created with cordova-ios#4.5.5
Installing "cordova-android-support-gradle-release" for ios
Installing "cordova-plugin-braintree" for ios
Embedded Frameworks in cordova-plugin-braintree
Added Arch stripping run script build phase
Installing "cordova-plugin-camera" for ios
Failed to install 'cordova-plugin-camera': Error: Unexpected key "NSMainNibFile~ipad" while parsing <dict/>.
Ionic Info:
Ionic:
ionic (Ionic CLI) : 4.5.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
#ionic/app-scripts : 3.2.0
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib#8.1.1)
Cordova Platforms : browser 5.0.3
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 1.2.0, (and 12 other plugins)
System:
ios-deploy : 1.9.4
ios-sim : 5.1.0
NodeJS : v8.11.4 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000
Please help me fix this error. Any help is appreciated.

cordovaProject.projectConfig.getFileResources is not a function in ionic project

I get this error, when trying to run an ionic app on android with livereload.
cordovaProject.projectConfig.getFileResources is not a function
When I try to re-install cordova, I get the same error. (npm install -g ionic cordova).
I removed the platform.
cordova platform rm android
and added it again:
cordova platform add android --save
All that changed nothing.
This is my ionic info output:
Ionic:
ionic (Ionic CLI) : 4.0.0
Ionic Framework : ionic-angular 3.9.2
#ionic/app-scripts : 3.2.0
Cordova:
cordova (Cordova CLI) : 6.3.0
Cordova Platforms : android 7.0.0
System:
Android SDK Tools : 26.1.1
NodeJS : v8.11.4 (C:\Program Files\nodejs\node.exe)
npm : 2.15.12
OS : Windows 10
Environment:
ANDROID_HOME : C:\Users\lars\AppData\Local\Android\Sdk
Android Studion is up 2 date...
How can I get rid of that error?
Many Thanks

Invalid image path Xcode:7.2.1

I am doing ionic app debugging. After the debug and all. I am trying to release an update to app store, but It works perfectly in iPhone6 emulator. The following errors shows up.
This error shows up when i am trying to add this to app store.
I have already sent few updates before this, and there were not such errors.
Ionic use cordova and since cordova 6.0, there is a bug on the iOS builder 4.1.0.
You can temporally downgrade cordova or iOS builder until this bug will be fixed
to downgrade cordova (and so downgrade iOS builder)
sudo npm uninstall -g
sudo npm install -g cordova#5.4.1
OR
to downgrade only ios
sudo ionic platform rm ios
sudo ionic platform add ios#3.9.2
to check iOS version
sudo ionic platforms
It didn't find any icon for one of the resolutions your app supports
Try by regenerating icons from Ionic CLI:
$ ionic resources --icon
Build again for the iOS plateform
After this make sure there is icons in the resources folder of your app:
ios - App name folder - Resources - icons
Another solutiion try to delete the CFBundleIconFile from the info.plist file : Reference

IOS emulator working app is not installed on it

I have started the IOS emulator through apache cordova CLI and it works, says the build is successful. I can interact with the emulator however my app is not installed on it?
Is there a command that im missing to install my app on this emulated device?
Thanks
To build
cordova build ios
To run in emulator
cordova emulate ios
To run in device
cordova run ios
It might be a bug in Cordova CMD. Try the following commands from your project root directory:
1) cordova build --emulator
2) ios-sim launch platforms/ios/build/emulator/<your_app_name>.app --devicetypeid "com.apple.CoreSimulator.SimDeviceType.iPhone-5s, 8.1"
If you don't have ios-sim install it: npm install -g ios-sim

Resources