Ionic - view console.log in iOS emulator - ios

I am working on an ionic app for iPad. In order to test the app on Mac, I am using the emulate command
ionic emulate ios
This launches the application in iOS Simulator. However, I am not able to find the console.log that I have printed in the Ionic application. After launching, it prints the following logpath in the terminal. However, the console.log file does not exist in this path
logPath: /Users/kayasa/myIonicApp/platforms/ios/cordova/console.log
Upon some research I found that in order to view the console.log message, emulate command needs to be executed with -lc command. However, this command does not even start the application in Simulator correctly. The application launches with the white blank screen.
Then I also tried launching the app from within xcode itself. It does launch the app in Simulator but I can't find a way to see the console.log here as well.

Related

Getting IOS console from Capacitor

Does anyone know how to view console.log() from the Xcode simulator using capacitor? I am aware that you can view the system logs via iOS Simulator > Menu Bar > Debug > Open System Log (How can I get the console logs from the iOS Simulator?), but this does not show any of the console.logs when using capacitor to run an ios application.
I couldn't get the Ionic instructions to give any output via Safari's dev tools.
However, Capacitor's solution is its built-in Console API https://capacitorjs.com/docs/v2/apis/console
The Console API automatically sends console.debug, console.error,
console.info, console.log, console.trace and console.warn calls to the
native log system on each respective platform. This enables, for
example, console.log calls to be rendered in the Xcode and Android
Studio log windows.
I was able to see the logs in Xcode's logging as long as the build isnt broken in some way.

Quasar VueJS app with Cordova loads application on iOS simulator with blank page only

I am trying to deploy an iOS app from VueJS Quasar framework using Cordova. When I load the application on the dev environment ( with quasar dev ), it runs the application through a browser and works fine.
However when I "export" to cordova project on iOS platform, in xCode I get the following error in the console: "Failed to load webpage with error: Could not connect to the server" and the simulator loads an empty white blank page only.
The app has been built and tried on an iPhone as well, and it's the same reason: empty blank page.
We are using API in the background from another server as well, where we have set the CORS to allow *.
Note: exported to android platform it works nice.
Did anybody have this problem, and knows what the solution is? Thanks!

How to restore functioning simulator when "react-native run-ios" stops working

Yesterday, I was working on my app and all was well. I had discovered two commands that would reliably start the remote debugger and run the iOS simulator. These two commands had been working reliably for about 48 hours, and I was so happy that I saved these commands in a text file on my desktop for easy access:
open "rndebugger://set-debugger-loc?host=localhost&port=8081"
react-native run-ios
Then I made a terrible mistake: I went to sleep. When I woke up, the commands no longer work. The first command launches the debugger, but the second command ("react-native run-ios") produces a variety of results, none helpful (see note below). At best, the simulator launches, but my app is a white screen.
After trying various things (listing processes to see if there is something to kill, rebooting the machine multiple times, etc) I decided to nuke my app and start over. So, I archived my app and created a new app with "create-react-native-app AwesomeProject" etc. I changed into the project directory and then almost ran "npm start" (as the docs suggest) but the terminal output suggested "yarn start" so I went with that. This gave me a QR code for an expo, but I still wanted the simulator on the screen. So I went back to the commands that were so reliable for about 48 hours:
open "rndebugger://set-debugger-loc?host=localhost&port=8081"
react-native run-ios
But they just don't work anymore. At best, I can get a simulator on the screen, but if I navigate to my app in the simulator, it is a white screen. I have tried "Erase all content and settings" in the Hardware menu for the simulator, quit the simulator, etc.
Will I ever be able to view the simulator on my screen again? Do I need to uninstall expo to get the on-screen simulator back? Should I just not sleep anymore? Will I ever reach I point where I can just wake up in the morning, quickly start the simulator and then be an app developer? Should I just give up on the simulator and adapt my workflow to use a physical device as the simulator?
Edit: To clarify, the variety of results include: simulator not appearing on the screen; simulator appearing and opening to the desktop of the iPhone, but when I navigate to the app and open it, it's a white screen; simulator appearing and app starting without my navigating to it, but it's a white screen.
Edit 2: Here is another data point. Just now I deleted my app again and created a new one with create-react-native-app. I then changed into the project directory and ran npm start. I then get a QR code and have confirmed I can open the app in my device using expo. And I see this error in my terminal, which might be unrelated to this issue:
2:31:11 PM: Error: './assets/icons/icon.png' could not be found, because './assets/icons' is not a subdirectory of any of the roots ('/Users/me/Apps/MyAwesomeApp')
2:31:11 PM: at /Users/me/Apps/MyAwesomeApp/node_modules/metro/src/Assets/index.js:192:11
2:31:11 PM: at Generator.next (<anonymous>)
2:31:11 PM: at step (/Users/me/Apps/MyAwesomeApp/node_modules/metro/src/Assets/index.js:329:347)
2:31:11 PM: at /Users/me/Apps/MyAwesomeApp/node_modules/metro/src/Assets/index.js:329:507
2:31:11 PM: at <anonymous>
So I have a working app and can test it with my device, but it would be nice to have the simulator on my monitor. However, "react-native run-ios" is not giving me that.
(Alas, this process below is not working reliably. It worked once. Then I tried to integrate opening the debugger into this process. A short while after posting this StackOverflow answer, I ran 'open "rndebugger://set-debugger-loc?host=localhost&port=8081"'. This seems to have broken the simulator, though the app still works in my device. I am now again trying to figure out how to get the simulator working. For a moment, the following seemed like the correct answer but it's no longer working -- now I get a "Runtime is not ready for debugging" red screen.)
I found a process that in this particular case gets the simulator working again (Update: It doesn't work. See my note at the top of this answer). I have expo on my Mac and on my devices, so these instructions assume you have the expo app:
In terminal, create an app with create-react-native-app. Do not sudo. No need to be root. Just a normal user.
Then, just like the react native docs say, change into the project directory and run 'npm start'. The terminal output suggests 'yarn start', but 'npm start' works for me.
When the expo QR code appears in the terminal output, use it. That is, install your app on a device by using the expo app to read the QR. Then, I think my next step was to open the expo app and then tap "Go to expo home" and then tap on my app to open it. And the app started up just fine.
Then, the real magic happens... I change into the project directory in a separate terminal tab and run "react-native run-ios". And then the simulator opens on my monitor and my app starts right up.
Thus, it appears that perhaps I had to run the app on my device first before I could open simulator on my Mac. Running the app on my device seems to get something unstuck.
Install the Chrome browser. Expo expects Chrome to be installed. With Chrome installed in Mac OS, a remote debugger will open in Chrome any time you run the simulator with react-native run-ios.

How to run hybrid applications ionic/nativescript in the simulator ios?

Tried to run a variety of applications, including the base is generated at the project initialization nativescript, ionic (2) framework.
Compiling succeeds after xcode runs the simulator and it opens the app or I'll open it by clicking on the icon opens the icon background and hangs indefinitely, and at the end of the log is always the same error regardless of the framework:
CoreLocation: Error occurred while trying to retrieve motion state update: CMErrorDomain Code:104
This error Google, but at the moment I only found an open topic without solutions.
Could this be due to the fact that in macos virtualke and if so, how?

Where does the trigger.io forge.logging.log (etc) output go when running on the real device (IOS or Android)?

Where does the trigger.io forge.logging.log (etc) output go when running on the real device (IOS or Android)?
Example,
forge.logging.log('inside my app');
For iOS, the log output is visible in the XCode organiser: click on Console under your device on the left sidebar.
For Android, if you started the app on the device using forge run android the output is piped into your terminal. If you didn't start the app from our tooling, the log output is still available: run adb logcat in a terminal.
In both cases, make sure you have your logging module configured properly. If you have the level set to ERROR, debug level messages will not appear!

Resources