How to debug an app run from the iOS simulator directly? (not from xcode run) - ios

we all know that if we build and run an app from XCode, we can see all the debugging, but what if we want to debug an app preinstalled on iPhone Simulator, I can't seem to find a way to do this, is this possible? how?
I tried iOS Console, but it doesn't seem to even work, the beta has expired.
thanks

If you just want to see the log output (e.g. NSLog()), see the following answer explaining where to find the simulator's system.log file.
https://stackoverflow.com/a/10165649
Note that if you are using Swift, "print" statements will not be written to the log file; they will only be displayed in Xcode's console.

the best way for me was
tail -f /Users/userName/Library/Logs/CoreSimulator/appID/system.log
it prints all data into mac terminal even though if you are not running the app from XCode or something, I wish I knew that before...

Related

how to see NSLog in my SDK project under iOS 10

I have a SDK project which will compile and build a framework. Inside this project, I have my person NSLog shown there. I have another framework test app to using this framework to do my task. After upgrading to iOS 10 and Xcode 8, I notice all the NSLog are gone. I cannot find it anywhere.
I search and find this answer: iOS 10 doesn't print NSLogs, I gave a try for both my SDK project and my framework test app, adding OS_ACTIVITY_MODE "disabled", however, it is still not showing NSLog.
Update: I still have one device which is iOS 9, I gave a try on that one, NSLogs are still shown in device console. Using Mac's console app I can also see my own logs.
This is a MFI project so I cannot directly debug this project, because the lighting cable is always connected with my hardware. I can only use log to see what happened.
OS_ACTIVITY_MODE set as disable remove OS activity state which is printed during the when project is runs. OS_ACTIVITY_MODE is only printed only in the x-Code 8.0 but when you upgrade your x-codefrom 8.0 to 8.1 you can found that it does not print any console for OS. But in overall procedure I have found that NSLog is working properly.
For your confirmation i just update my old project and run it into x-code 8.1. Output as below images
Environment variable
Nslog Code
console print
Suggestion
I have checked your problem in multiple style with multiple project but I didn't found any problem. So I just suggest you
To update your x-code
or
Re-install x-code after removing previous x-code completely.
Because If it is x-code bug them i also have to face the same in my every experiment.
If you still have any query you can ask.
Apple did some changes the way NSLog works and I probably you might not be able to get them.
My recommendation is that you change your NSLog to something that prints to the output console without using NSLog.
I'm the co-founder of a product called Bugfender that might help you, what we do is that we provide a BFLog function that will print the logs to the console and also upload them to our servers, so you can always check the logs without any need to connect the device to your computer.
The only problem our product has is that it's not in real time, but usually there's a delay of a few seconds. Some of our customers are using it to debug the app instead of using the XCode console.
If you set this,you can not see any log in your device ,but you can see that in simulator.

App do not run on second Simulator?

I am trying to run a app on multiple simulators. I did manage to run 2 simulators see link Xcode6: Run two instances of the simulator.
I can run other apps on the two simulators. I did manage to run this app on the two simulators in the past.
For some reason when I try to run a second simulator there is a pause I can see IOS system log trying to open the it just closes.
I searched the IOS Log file found that both simulators have the same data (unhelpfull). I would appreciate it if someone can just point me in a direction where to start searching for the problem?
My Mac memory is fine do not have to few. The start file is also not have anything I can see that might cause this problem.
Thanks in advance.
My problem was localisation that is why the add did not run on default english setting. The add worked correctly throw Xcode because the Sceme helped set the language.

Crashlytics is not sending Crash report from iPhone

I've setup the Crashlytics in my one iOS application and installed the application on a real device. My Crashlytics Dashboard is displaying that, I've successfully added the app. However, it's not sending crash report. My internet speed is not so good. But I can check my emails from this device. Can anybody guess, where is the problem?
Xcode debugger does NOT allow Crashlytics to process crash reports. Yeah, that seem weird even to me when I read that first time but it is a fact (Source). That's is the reason we never see crash report When:
- running app in Simulator
- running app on iDevice by directly build and run from Xcode with debugger on.
To make sure a crash is reported during your testing (copied from Crashlytics support site):
1. Launch simulator
2. Press stop
3. Launch your app and force a crash
4. Relaunch the app from simulator
5. See the crash report in the web dashboard.
EDIT:
Added a reference; Crashlytics also provides a short article on a quick way to force a crash.
My be it's late but work 100%
Make some changes in project build settings like in below image
and follow these instructions.
The primary reason any crash reporter won't work on iOS is due to interference from different crash reporters. However, with Crashlytics specifically there could be something specific to them causing the crash report not getting reported.
Xcode debugger does NOT allow Any Crash Reporter to process crash reports. This is because XCode overrides any hooks into the crash handling call backs. This only happens when:
running app in Simulator (with debugger on)
running app on iDevice by directly build and run from Xcode with debugger on.
To make sure a crash is reported during your testing (http://support.crashlytics.com/knowledgebase/articles/92523-why-can-t-i-have-xcode-connected-):
Launch simulator
Press stop
Launch your app and force a crash
Relaunch the app from simulator
See the crash report in the web dashboard.
While a super old video it's still relevant, here's a video of the steps above (example from Crittercism): https://www.youtube.com/watch?v=sU6Su3PBFH4
For me, the problem was that the device was connected to my Mac :)
From this source:
Also, if you have your device connected to your Mac, XCode's debugger
will step in as well. So just disconnect the device before testing :)
I found solution using following steps
1. Go to Edit Scheme
2. Run -> Info
3. Change Build Configuration to release.
Now run the app crash it. You will receive mail.
We recently ran into this issue and I found that somewhere along the way the build script was removed. Adding it back in with the following fixed the issue for us:
./Crashlytics.framework/run <your_api_key> <build_secret>
Note : When using Cocoapods you will want to us the following instead of the above (source):
./Pods/CrashlyticsFramework/Crashlytics.framework/run
Adding a build script:
To add a Run Script Build Phase in Xcode 6, select your application target in your project, then select "Build Phases".
Click the small "plus" icon and select "New Run Script Build Phase".
You should now see a Run Script section in the middle of your Build Phase options, as shown above.
Inside the body of the Run Script Build Phase, paste in the script.`
The above quote comes from Crashlytics's visual tutorial, referenced in this post.
Note: I originally posted this answer verbatim for Crashlytics error code: 202 when Submitting files.
From the RayWenderlich site:
You won’t get any crash reports if Xcode intercepts the crash event!
To make all the examples below work, you have to build and run the
application, then click the stop button on Xcode. This way you will
have the latest version installed on the the device. Once that is
done, you can launch the app on the device itself, and then crash it
all you want! All the crashes on your iOS device will be caught and
sent to the server component of the service that you have integrated
into the app. Crash reports are usually sent to the server the next
time you start the app, so the steps to follow to generate a crash
report on the server are as follows: Build and run on Xcode. Press the
stop button. Run the app on your iOS device. Make the app crash. Run
the app again.
Crashlytics works for me until now.
I don't know why but now it doesn't work.
You should turn debug-mode on by
[Crashlytics sharedInstance].debugMode = YES;
My problem is here Crashlytics error code: 202 when Submitting files :(
Make sure you are not forcing the crash too early.
Set [Crashlytics sharedInstance].debugMode to YES;
Watch for
Crashlytics] Settings loaded
on the Xcode console logs.
Then force the crash and restart the app, and the crash will be reported now.
I ran into a similar problem when trying the test crash code.
Crashlytics.sharedInstance().crash()
I was running my app from a device, without Xcode, and the crash wouldn't show up on Crashlytics Dashboard. What worked for me was the following tip from Crashlytics website:
Make sure to launch the app after crashing it, so that the crash can
be uploaded
I commented out the above crash() call, and re-ran the app. Then the crash showed up in the Dashboard.
This is for xcode 9, from crashlytics 3.4.0
After doing this, be patient and wait for a few minutes.
Have you tried running [[Crashlytics sharedInstance] crash] on a device and seeing if that gets reported? There are a few reasons why Crashlytics might not work including other crash reporters etc.
If you don't upload the dSYM file, Crashlytics will not show your crash even though the report successfully uploaded.
You could run into this problem, if you have set up your build-script to only run on your CI server. Then if you have copied your app to your phone via xcode and you run it without being attached to the debugger, the report will be uploaded but ignored, because of the missing dSYM file.
Sometimes, it takes some time for the logs to show up. I am able to find them after 15-20 mins
One of the issue I feel that in the Run Script Phase, it should be a separate Run Script Phase for CrashLytics. When had the run script
./Fabric.framework/run
With some of my other script, everything was ok, CrashLytics log show report submitted, but nothing was in the web interface.
When I add another Run script phase only with Fabric run, it appears like a magic :)
My first try was with cocoapods, but that did not work.
When I manually add all the framework and a separate run script phase that worked.
This worked for me,
If you're testing on iDevice, just unplug iDevice with your Xcode and run your app.
Now, If crashed it will be updated on dashboard.
I solved by deselecting "Run Script only when installing" option in Run script (one for Fabric(crashlytics))

Xcode blocked at “Attaching to (app name)” when I launch my app in the simulator

I know there's a lot of posts with the same that problem. I just spent at least 2 hours to read them and I tried everything I saw in the responses but it still doesn't work. I don't know what to do anymore. Can someone help me?
I use Xcode 4.2.1
This problem occurs regularly for me, and the solution was always to kill the process named SimulatorBridge.
And to simplify the solution you can add a custom 'behavior' in Xcode to do the task by following these steps:
Make a shell script file with this command:
#!/bin/sh
killall SimulatorBridge
Save it in ~/Library/Developer/Xcode/UserData/Behaviors/ as KillSimulatorBridge.sh.
Open Xcode > Preferences > Behaviors, and add a new behavior to run the shell script:
Now, you can run this behavior whenever Xcode hangs while trying to attach to your app, and you can even have a keyboard shortcut to run it.
Hope this helps someone.
It can also happen when a different user account has the simulator running on the same computer. In that case, close the simulator on the other user's account and try again.
Restart your computer.
The simulator sometimes gets stuck and this is the only way I know to reset it. The same thing can happen to the device as well and you just have to switch it off and on again.
If that doesn't work, you may have to reinstall the SDK.

ios Simulator Could Not Find The Application To Simulate

I'm having trouble with the iOS simulator. I'm currently on 10.7 and was using the simulator to test my website. During the testing, I switched the iOS version via the tool bar, and the application froze and quit. Upon restarting, I get the following error message, with a finder window, inviting me to choose an application:
"ios Simulator Could Not Find The Application To Simulate"
Here's what I've tried to fix the issue:
1: Attempt to identify the application it needs, but the only thing i could see to open was a printer app and the ios simulator app, which just results in a "only one iOS simulator can run at a time" error message.
2: Restart the Mac.
3: Download the new Xcode tools from the app store.
4: Restart again.
None of this has helped, and I'm really stuck without it at the moment. If anyone knows how to resolve the problem, I would be grateful to hear any suggestions. Thanks.
Give this a shot.
Open up a new shell, and shoot of this command: sudo <Xcode>/Library/uninstall-devtools --mode=all (assuming thats the location of the instal).
Then run the Xcode installer you got from the app store.
This removes all the plist files that were also installed with xcode, which aren't removed when you simply reinstall. This is as close as you can come to a complete xcode refresh without reinstalling your OS.
Here's an alternative solution that worked for me... the answer selected here did not. I created a blank, "hello world" project and simply ran it. When you run the app, it sends the app to the simulator and voila! iOS Simulator has an app to simulate. From that point forward, you should be able to open the iOS Simulator without a problem.
After a while longer trying various things, it seems like I may have fixed it.
When asking for an application to open, I opened Xcode, and (weirdly) that opened up and left the testing shell visible, with the tool bar intact. I then selected the current version from the device options and hit the home button, and suddenly everything appeared.
Weird thing to have suddenly happened, but there you go.
I still can't test in iOS 3, so that's a bit of a problem, but not a disaster either!

Resources