Read console/errors of iPhone app without new build via Xcode - ios

I developed an app and already tested it in Xcode and on my physical iPhone device.
After a lot of testing on my iPhone the app quits after starting.
I guess this is because of an empty array, but I am not sure.
Is there a possibility to read the console of my already built app on my iPhone? Because when I am testing the app on Xcode everything works fine - I guess the error occurs in only very specific cases...
I don't want to build the app again on my physical device, because I am pretty sure everything works fine then and I won't be able to recreate the exact situation.
So I would like to connect the phone to my macbook and run the app on my phone in Xcode without rebuilding it first.
Any ideas?

Connect your phone to your system and open Xcode.
The Window menu in Xcode Select Device and Simulators from the
Window menu.
Select your device from the left panel.
The toggle logs button Make sure that the logs are expanded. If they
are not, press the small up arrow in the bottom left corner of the
main pane.
Click the Save Console button (at the bottom right) to save the log
information within the console.

If you use a free Apple Developer account it is normal, it has not crashed.. it simply refuse to run.
Apple has imposed 'new' limitations on the 'free' provisioning profiles, whit this limitations you can run the app on a physical device for 7 days, then you must recreate a new profile with a new deploy on the device.

Even without XCode you can get the logs by using iOS Console which is free and works exactly as XCode's console.
As for starting the app again without rebuilding from XCode, you can use ⌃⌘R to speed up your tests.

Related

How to debug react-native iOS app crashing on startup after a week or so

I started messing around with react-native. I've built a small application and it seems to work fine (package.json). I can work on it in Debug or Release mode, using the simulator or my iPhone 6S device, and all is well.
This app is just for me so I don't pay for the Apple Developer thing, and I just run the app in Release mode on my device, and it...seems to be fine? I can quit xcode and go places and the app works fine.
After a week or so, it's hard to tell, the app stops loading. It'll display the splash screen for a split second and then it's gone back to the home screen.
I setup Rollbar, but it doesn't catch anything. I look in the Privacy -> Analytics area and don't see anything there either.
I'm not really looking for an answer to my exact problem since various SO questions and other places suggest it's probably something weird and specific. My main problem is I don't know even where to look/how to debug this kind of thing. If I build the app and run it on device again, it'll run fine. I need to try to debug without loading new code, and have no idea how that works on iOS. I've tried poking around at the Debug -> Attach to Process by Name, but the app never gets far enough to do anything with that.
Alternatively, I throw react-native in the garbage and use something that works...
App provisioning with a free developer license (?) is 7 days. See: Why does my free XCode Provisioning Profile only last 7 days?
You can likely verify this by looking at error messages in the console window. Connect your device, and in Xcode go to Window/Devices and Simulators/Open Console, then launch your app.

When you build an iOS app for testing, can you have it end up in a folder?

This has been a really difficult question to Google: When you click on build, and Xcode puts the app on your physical iPhone, is there a way to force that app into a folder, rather than just the first open spot on the springboard?
No. There is no way to tell Xcode where to install the app on your iOS device the first time you send the app to the device.
Of course after the initial installation you can put the app where you want it on the iOS device and then it will stay there each time you update the app through Xcode. But if you remove the app from the iOS device and then do a build through Xcode, the app will get put in the first open spot again.

Debug WatchKit on real Apple Watch - Nothing happens

I am struggling with debugging my WatchKit Extension/App on a real Apple Watch. Debugging both the iPhone App and the WatchKit Extension using the simulator the simulator is not problem:
Select the WatchKit App Profile and run in Simulator ==> App is launched on in Watch Simulator and I can use breakpoints in the Extension code to debug.
To debug the iPhone app as well I launch the app in the simulator and attach the debugger manually ==> I can use breakpoints in the iPhone Code to debug.
It is no problem to observe both the work of the iPhone app and the watch app. At least not in the simulator.
I would like to do the same thing on a real Apple Watch. But when I select the WatchKit App Profile and my real iPhone (instead of the Simulator) and click on "Run" nothing happens. This means Xcode seems to build and start the app but nothing happens on the devices. The status field in Xcode shows:
Building MyApp WatchKit App: MyApp WatchKit Extension
Building MyApp WatchKit App: Finishing...
Running MyApp on My iPhone 6
This is all. No debug Window, breakpoints are ignored or do not work and the app is not launched neither on the iPhone or on the Apple Watch.
I found other questions about problems with debugging on real devices (e.g. here) but they all deal with installation and signing issues. In my case both the iPhone App and the WatchKit App are installed without any problem. When I click the app icon on the Watch I can start and use the app. Problem is that I cannot debug this process.
Why do I need to debug the process on real devices? Well there is one thing I cannot test using the simulator: What happens when the Watch App tries to contact the iPhone app using openParentApplication:reply: when the iPhone app is not already running? This works perfectly in the simulator but on real devices the Watch Apps seems to get no reply from the iPhone app and simply waits forever.
I already found hints to solve this but without being able to debug the Watch App and to see how the code is executed I cannot be sure what is going on...
thank you for your answers. I finally managed to get the debugging running (most of the time) on my real Apple Watch. However it is quite cumbersome and not very reliable. There is not enough space in the comments so I will use this answer to describe my solution. Maybe it is help full to other:
Make sure, the App on your Watch is not running (as BalestraPatrick described). Launch the app and hold the side button a few seconds to bring up the "Turn off your Watch" dialog. Hold the side button for another few seconds to close the app and to return to the Watch homescreen.
Make sure the iPhone is not locked.
Select the WatchKit App target and your real iPhone and run the project.
Running the Watch App resulted quite often in an error SPErrorInvalidBundleNoGizmoBinaryMessage. Re-starting Xcode and cleaning both the Watch App and the App target solved this.
If the build of the Watch App succeed there will be a short message in Xcode but nothing on your iPhone or Watch. If you have made changes to the Watch App it will take a few seconds to refresh the app on the Watch. This is indicated by the progress-circle overlay over the app icon. If you made no changes ore once the app has been transfered: Launch the watch app manually by tapping the icon. There will be no automatic launch.
In most cases Xcode will recognize the app launch and attach its debugger to it. This will allow to use breakpoints, inspect the code, etc.
In my case I whanted to inspect how the iPhone App handles the application:handleWatchKitExtensionRequest:reply: call when the app was not active before. This is important because this cannot be done using the simulator. If the app takes to long to handle the request the Watch will receive no valid response.
After following the steps described above Xcode is only attached the watch app and will not hold on breakpoints in the iPhone app code. To do this, one has to manually attach the Debugger to the iPhone app process that is started when the watch app sends its call.
To be able to attach the debugger I added a delay to the apps main function: [NSThread sleepForTimeInterval:5]:
Select function in Watch App that will start the call to the iPhone App
The iPhone App will be launched in background. The delays gives you 5 seconds to attach the debugger.
Choose Debug\Attach To Process\Likely Targes\Your iPhone Appin Xcode to attach the debugger.
After the 5 seconds delay the process will continue and you will be able to use breakpoints in your iPhone app code as well.
Do not forget do remove the delay code when you finished testing :-)
NOTE:
You will not be able to see NSLog output (or any console output at all) from the iPhone App since attaching the debugger does NOT re-route the console output.
Happy testing with this awesome new Apple product :-P
I am having the same kind of issue but to improve a little bit the debugging experience I usually restart my devices a few times. Try to restart your Apple Watch or your iPhone.
Before launching your app from Xcode, make sure that the app is completely closed on your Apple Watch (not stuck in the loading screen for example). To do that, you have to force close the app: enter your app, keep the side button pressed until the menu to turn off the watch appears, then press the same side button for a few more seconds until the watch will go back to the homescreen and force close your app.
Now you can try to build and run the app from Xcode and it should work more reliably.
watchOS 3+:
The force quit is done by pressing and holding the side button (the button just below the Digital Crown) until the shutdown screen appears, and then
let go of the side button, then press and hold the Digital Crown.
Here's a technique that seems to be be the most reliable for me, even though it still only works about 25% of the time (Xcode 7 beta 4, 7A165t):
Run the phone target in debug (on your actual iPhone of course)
While the iPhone app is still running, switch to the watch target and run that in debug.
Keep an eye on your watch homescreen as the app installs. Once the app has installed, tap it to open it. This will sometimes "kickstart" the watch app and allow the debugger to catch it. At this point you should be able to debug both your iPhone app and watchOS app together.
This question has different answers. All are good.
The reason is: in my experience there are at least two different problems that prevent debugging on a real watch. Both require a different strategy.
This answer tries to help you to decide when to use which strategy.
XCode installs, tells you it is running for a short time and then stops showing "running...".
start with the answer of BalestraPatrick:
restart your devices.
Do not forget to restart your iPhone. This did the trick the first time I had this problem.
XCode installs, tells you it is running for a longer period of time: "running <projectName> on Apple Watch of <yourname>.
start with the answer of Jay Hickey or Andrei Herford
starting the watch app manually probably does the trick.
I also had times when XCode was able to start my watch app without any help from me.
Bonus:
Starting with XCode 7.1 it seems XCode doesn't always compile all necessary Swift files (more often than before). This is not watch specific, it also applies to iOS apps. The symptoms can look similar to those of this question. -> clean your project and then restart XCode.

Debugging Corona SDK application on device

I am working with Corona SDK for some time, and i really like it, but there is one thing, that i cant figure out: How to debug my code on a real device?
At the point, when my code runs great in the simulator, i usually compile it, and try it on the phone. But when there is some error, that doesn't bother the simulator, but pisses the phone off, i simply see an error message:
"This application encountered a Lua error (see logs) etc."
Me and my boss spent a whole day figuring out, that i made a require with a capital instead of lower case.
My question is: How to actually "see" that log? I tried to connect my device to DDMS, but i saw no relevant output. Is there a way to access that log (I'm testing on an android device)? Or is there a way to simulate the EXACT behavior of the phone in the simulator? Usually the phone freaks out because of i/o operations, and when using the wrong case.
The best way to debug on iOS devices is to use XCode's Organizer with your device plugged in via the USB port. On the left hand panel of Organizer, there will be a block for each device that XCode knows about. You may have to click on a button "Use device for debugging" or something similar so XCode can gather all the information it needs.
Once done, then you can use XCode to install the app to the device (you don't need to make an .ipa file, just copy the app to the device via Organizer). In that panel on the left, there is a link for "Console Log", click that and you can your print statements and other errors issued by Corona SDK.
Rob
If you don't have Xcode, you can try iPhone configuration utility. It is more light-weight than the xcode plus you can also use it on a windows machine.

Is it possible to test ready ipa file by instruments

I have an application built in IPA file by Adobe Flashbuilder (with AIR) the app works smoothly on iPad. Well.. worked smoothly until I had encountered some memory leaks. Is it possible to monitor this application's memory usage with Apple's Instruments?
For now I am deploying this app by dragging IPA file into iTunes and synchronize then.
I need to monitor this app. Is it possible? What should be eventually done to make it working?
Yes. you can analyse using instruments.
Install your app in your device.
Connect your device to your Mac.
Open Instruments and select Leaks (you can select any option infact, like Allocations etc.,) in the dialog that appears.
In the Top Left corner, you will see "Choose Target". the first two options are your device and your Mac. Select your device.
In the same menu, the 5th option is again "Choose Target". There you will see all the installed applications in your device. Select the app you want to analyse.
Finally, Press Record, and you will see your app running in the device and Leaks/Allocations (whatever you have selected) being shown in the instruments.
Hope this helps you.
Try running Instruments and select an installed app on your device, if you get this message, you know what's happening
Target failed to run: Permission to debug com.fantageek.MyApp was
denied. The app must be signed with a development identity (e.g. iOS
Developer).
I believe it's possible through the Xcode organiser. It outputs events happening on the device to a log. Don't quote me on that though

Resources