How to see NSLog() from console app when using instruments - iphone

I'm using instruments for allocations, but want to see my NSLog messages. In another post they mentioned to look inside /Applications/Utilities/Console for the messages. I can't seem to spot any of them. After you open the Console App, where would you look?

You can view the console of the device using Xcode Organizer.
In Xcode 6, the "Devices" tab was removed from the Organizer into it's own window. To view the console log, you now have to click the tiny little triangle in the lower left-hand area of the device information.

Alternative to Black Frogs answer, you can also use the integrated console from your mac directly without Xcode. All output is forwarded there. Just do a spotlight search (CMD + Space) and type in console.

If you want to use the Console Application, the Xcode log can be found under the FILES section in the Log List (If not visible:Menu -> View -> Show Log List). Look for
~/Library/Logs/iOS Simulator/6.1/system.log
This is actually just a reference to the file system. So you could to a
tail -f ~/Library/Logs/iOS Simulator/6.1/system.log
in the Terminal as well.
Update:
Another option in some newer versions of Xcode can be found in the Xcode 'Debug' menu. Look for the entry 'Open System Log...'.

As of Xcode 6.3.1, I couldn't find the log in any of the above locations when running the Allocations instrument. For me, in iOS Simulator (not Xcode), click Debug -> Open System Log... to get the NSLog messages normally appearing in Xcode.
In case you need it, this log is kept in Library/Logs/CoreSimulator/[device name]/system.log. To get [device name], go to Xcode, Window -> Devices and find the device that you are currently simulating. Look for the Identifier. Compare that against the folder names in Library/Logs/CoreSimulator and you should find a match.

Related

Troubleshooting on device with Titanium for iPhone

On Xcode when you build on device you can troubleshoot the app within the console. How can i do that with Titanium? It's very difficult without troubleshooting
What you can do is use the Ti.API.info('whatever') method to log everything you need and will help in debugging then while you run your app on the device and it is connected to your computer, just open xcode -> go to organizer -> click on your device -> and select console. Every Ti.API.info() log you do in your app will show up in the console.
Titanium's SDK (http://www.appcelerator.com/platform/titanium-sdk) is Eclipse with the Aptana plug-in. You can do the same debugging you'd do in Eclipse: set break points, step through code, set watch points, ...
To run your app in debug mode, start by setting some break points in your app. To do that right-click on the line number that's on the far left of our line of code and select "Toggle Breakpoint". Next, towards the top of the Project Explorer panel are several icons. One of them is debug. Click on that debug's dropdown menu and select the iphone emulator or ipad emulator. The app will compile for debug and run the emulator you chose. From this point on, everything is like debugging on Eclipse.

XCode Locks Up When Launching the iOS Simulator

Lately when I have been deploying any iOS application to the simulator (iPad or iPhone), XCode locks up (Not Responding) and the simulator simply displays a black screen. I have to force quit both.
Steps I have taken so far towards a resolution:
Clean
Reset the Simulator
Deleted the simulator folder
Reinstalled XCode from the App Store
Reinstalled XCode from the developer center
Has anyone else encountered this? Any suggestions for a solution?
Other info:
OSX Lion 10.7.3
XCode 4.3.2
Shibboleet
Thanks in advance for any help.
I had this problem and was able to continue by:
1) Edit the run scheme by clicking on the first part of the App name to the right of the "Stop" button to bring down the scheme list and click "Edit Scheme..."
2) Click on the Run item and change the debugger from LLDB to GDB.
3) Run
I think the problem was that I validated the settings and it offered to automatically change the debugger from GDB and LLDB and I clicked "OK" because the advisor message sounded very self-assured.
Enjoy.
Under Scheme, go to edit scheme, and change launch from wait for App.app to launch to automatically under the Info tab.
EDIT: If you upgraded Xcode, make sure the old separate simulator is uninstalled.
hmmm, weird simulator, instruments issue i had once would work when i command-tabbed back and forth. try deleting derived data?

I am building an ios navigation app that is not opening in the ios simulator

I have this navigation app with several views and no data yet.. however I had a small break from coding over the weekend and have come back to it only to have it not load in the ios simulator.
There are no errors in the xcode output while it runs but as soon as i click to run button it loads the app up but as soon as it opens it closes and goes to the home screen.
I have tried cleaning the build and opening closing everything but just cannot figure this thing out...
Since there is no error messages or indication as to what is wrong I am going to suggest
a few other things you can try out:
Have you tried "iOS Simulator" -> "Rest content and settings".
In Xcode click the "Product" menu in the menubar, hold down the Option key and
you should see "Clean" change to "Clean Build Folder".
Lastly pull up Organizer (Shift+Command+2), select the "Projects" and the then click "Delete Derived Data".
The two last ones should not be directly related to the simulator, but they won't hurt either.
Does your app requires internet connection to run.. if it does, check ur internet connection as well.
I have this kind of problem last time and turn out, if there's no internet connection and you didn't put any exception on that, the app will straight away crash with no errors..

How do I type using my keyboard on the iphone simulator?

I used to be able to type with my real mac keyboard after launching the iPhone Simulator. Typing with the on-screen simulator keyboard is just horrible when testing with large amounts of text.
No matter what I do, I can't get my keyboard to type anymore inside the simulator. Even if I have "Simulate Hardware Keyboard" switched ON, it just won't type anything. Can someone please tell me what I'm doing wrong? Is there no way to type using the real keyboard anymore?
Try trashing the iPhone Simulator preferences file. When my iPhone Simulator stopped responding to keystrokes, this fixed it.
Quit the simulator.
Go to finder and press (command+shift+G) then navigate ~/Library/Preferences.
Move com.apple.iphonesimulator.plist to the trash.
Try launching your iPhone app in the simulator again.
Deleting com.apple.iphonesimulator.plist did not help me under Xcode 6.0.1.
Probably, it worked in old Xcode.
But, what works perfectly for me under Xcode 6.0.1, it is new hot Keys in iOS Simulator:
Shift-Command-K Connect/Disconnect Hardware Keyboard
Command-K Toggle (Show/Hide) Software Keyboard
And, you know, I really suffered for last 2 months, until found it, and it is very convenient now))
Don't trash the iPhone simulator preference files. There's no need to do this.
Look in the simulator's menu Hardware ➔ Keyboard. The menu options are:
iOS Uses Same Layout as OS X
Connect Hardware Keyboard ⇧⌘K
Toggle Software Keyboard ⌘K
Ensure option 2 is checked.
If it's already checked, uncheck it then check it again (you'll probably want to learn the keyboard shortcuts).
If you find that this hides the on screen keyboard, but you also want this to show, use option 3 to toggle it back on.
If rotating the simulator seems to stop the keyboard working, toggle option two off then back on – this seems to resolve it.
I am using iOS Simulator Version 7.0. While the simulator was running I went to iOS Simulator->Reset Contents and Settings... and reset the simulator from there. That seemed to have done the trick for me. Hope that helps.
This is because you have used changing the orientation of simulator using keyboard shortcuts. Just press cmd on the mac keyboard then start typing.
All I needed to do was quit the simulator and launch it again
MY PROBLEM WAS KEYBOARD IS SHOWING AND KEYSTROKES NOT DETECTING. AND I FOUND THE SOLUTION:
You don't need to quit the keyboard.
Try Hardware->Keyboard->Connect Hardware Keyboard directly
Removing com.apple.iphonesimulator.plist worked for me too, but I had to locate it inside the hidden folder /Users/[yourusername]/Library/Preferences/
Shell / Command-Line / Jenkins / CI:
sh "plutil -replace DevicePreferences.${deviceID}.ConnectHardwareKeyboard -bool NO $HOME/Library/Preferences/com.apple.iphonesimulator.plist"
sh "plutil -extract DevicePreferences.${deviceID} xml1 -o - $HOME/Library/Preferences/com.apple.iphonesimulator.plist"
The Device ID can be found via xcrun / simctl, based on the devoce name:
xcrun simctl list | grep ${simulatorDeviceName} | sed 's/).*(.*//;s/.*(//'
I encountered the same problem and tried a lot of different ways which worked mostly but never for sure. Ultimately, I found this. https://stackoverflow.com/a/26057011/1463604
If you are developing a React Native app and you cannot refresh (⌘R) or enable remote debugging (⌘D) from the iOS simulator, while other keyboard inputs work, make sure you are running a debug build configuration. You can check this with:
Product -> Scheme -> Edit Scheme -> Run -> Info -> Build Configuration -> Debug"
I got this tip from here.
Just restart Simulator (close and open the app).

How to change the default Xcode iphone simulator when testing

I don't know why but now the default iphone simulator launched when I build the project is "ipad", but I want it to use iphone 3g instead.
Any way to set this preference?
On Mac, if you right click on the Simulator icon, you can select devices and it will open a new device.
Or go to File -> Open Simulator
In Xcode,
Click Product -> Destination -> iOS Simulator -> Choose Device to run.
Then build and execute Xcode project.
It works..
2022 Fix:
You have two options!
With the simulator running go to File > Open Simulator > iOS [current version] and select the desired device.
With the simulator running, right click the icon in the bottom toolbar, select Device > iOS [current version] and select the desired device
If you are using Expo, after selecting the new device will open in a new window, so you'll have both. Heres how to get Expo to run on the new device:
Close the device window you don't want (cmd + w)
You will now be able to "Run on iOS Simulator" and it will open up Expo Go on the new device.
2020 Fix:
With the simulator running go to File > Open Device > iOS > iPhone 11 and select the device. It will open up the device as another window but there won't be the Expo app.
Close the device window you don't want (cmd + w), then close the window with the device you would like.
Restart Expo (in the command window with it running do ctrl + c then re-run Expo with expo start
You will now be able to "Run on iOS Simulator" and it will open up with the selected device type.
In the chance that anyone reading this is building their app in react-native, the solution is the --simulator option.
For example:
$ react-native run-ios --simulator "iPhone X"
Go to Hardware > Device from simulator menu.
For me works changing active SDK from 3.2 to 4.0. If your project is mentioned to work on iPad and iPhone (or for compatibility matters) I believe the only way is manually switching active executable before running your app on simulator.
Apple:"iPhone OS 3.2 does not support iPhone and iPod touch devices. It runs only on iPad.".
You can select the device from the menu inthe simulator.
Try
Project > Active Executable , and select the one you want the most.
This worked for me. When I already have the app open on an iphone in "Simulator". I click File -> Open Simulator -> iOS 14.0 -> iPhone 8 (or iPad (7th generation))
None of the above worked for me, but the following took care of the issue :
Source:
http://www.cocoabuilder.com/archive/xcode/301182-xcode-3-2-6-keeps-switching-to-ipad-simulator.html
Excerpt:
This works for Xcode 3.2.6. I don't yet use Xcode 4.x so don't know
if this will work for it or not. I would also quit Xcode before doing
this, just in case.
Go to the project folder and find the .xcodeproj file. Right-click
(or Control-click) it and select Show Package Contents. When the
package contents window appears, find the .pbxuser file (there might
be multiple such files if the project was worked on by multiple folks
and/or multiple computers). Open this file, which is XML, in your
preferred text editor. Find the section with the comment "/* Project
object */". There is most likely not a line in that section for the
key "activeSDKPreference". If there is no such key, add the
following:
activeSDKPreference = iphonesimulator4.2;
I found it after the "activeExecutable" key in that section, so I've
been adding it in that same order.
If there is already an "activeSDKPreference" entry, change it to
"iphonesimulator4.2".
Close the editor and the package contents window and then double click
the .xcodeproj file to reopen the project. Now you should have
entries for iPhone Simulator 4.2 and iPad Simulator 4.2 in the project
settings pull down menu, with iPhone Simulator 4.2 probably already
checked.
Additional Notes:
In my particular case, my entry in .pbxuser file had said
iphonesimulator4.3, even though under Project-Project Settings
menu
it said iphonesimulaor4.2!. However, once I changed it to
iphonesimulator4.2 in the .pbxuser file it stop auto selecting
iPad
all the time.
If you use SVN you will not see an "M" in SVN column showing that
you changed the project (even if you refresh/update). However,
just
do a "Commit Entire Project" and your changes to .pbxuser file
will
get updated. I also suggest referencing this post in your
check-in
comment in case you ever need to change it back for whatever
reason.
I finally solved this problem myself.
First, install new version of Xcode, which is Xcode 4.
Then set project scheme to iPhone Simulator and run app in Xcode several times.
And re-install Xcode 3 and the problem will be gone!
Yes, it's annoying. This worked for me:
Open the .plist file in group/folder resources and check the checkbox for key "Application requires iPhone environment".
If you are using Flutter, open the Runner.xcodeproj file in ios/ folder. Then right next to the Runner breadcrumb, you can click >and select what device to launch.
For Xcode Version 3.2.6 the following helps:
Project->Active Executable->iPhone Simulator 4.3
I don't know if it is working for newer Xcode environments.
Gary Tsui has also pointed out this approach previously.