iOS simulate Application and log events - iphone

I want to install and simulate iOS applications and find their malware intentions. See if connects to an IP address, downloads something, API call logs and soo on... kind of everything it does on the system. Does iOS Simulator log this events, or is there any online project that does that. If not then I should do it from scratch, do you have any advice how to do this? I only have the application file, not the entire Xcode project.
ALL i have is a bunch of applications(not the projects) that i have to test. All i want is to run them and log their actions in an automated way. Just like running a windows application on a virtual machine and log api trace, internet connections, memory, registry, disk actions... IN AN AUTOMATED WAY.
Thank you.

In the iOS simulator apps simply run on Mac, but their output is shown in the iOS simulator. This means that any tool that allows you to audit Mac applications will allow you to do the same with the iOS simulator.
Check your Activity Monitor, you'll see that the app is simply listed there. I think the standard Xcode Instruments will work fine for you.

If you have the Xcode project, then look at the code and the debugger while it is running. Other than that, if you run it in the iOS simulator you will only see the GUI portion of the app, unless you are running it side by side from Xcode (then you can use Instruments or the debugger). This documentation should allow you to run the apps on the simulator.

Related

Accessing iPhone app logs from Ad Hoc build OR transferring project build to another machine

I'm developing an iPhone application with Xcode 4.5.2, and when I run the app on a device or in the simulator, via Xcode, the logs are showing in the Xcode Console.
My question is, when I build an Ad Hoc distribution build and install the app on a device and run it from the device, is there any way to watch the log output? I need to tech support the app remotely and want the tester, who is elsewhere, to be able to see the logs.
Question two, can one build the project and and export the build, import it to Xcode on another machine and just execute it from Xcode without building? This would solve the problem since the tester would be able to run the app from Xcode and thus see the logs.
The problem is that I'm using Sencha Touch, which isn't that easy for the tester to set up so that he can build the project locally. In short, I need the tester to access the log output so he can inform me of it, without having to build the project in Xcode.
Question one, answer one: If you use NSLog and you can not change this in the code then there is no way to see the log output right on the device. However it is possible to see the same log output as you see in the debug output window also without XCode. Download the (free) iPhone Configuration Utility for Mac or Windows. Once the device is connected you can select the device and switch to the Console tab to see all debug output messages, including that one of your app.
Question one, answer two: if you can modify the logging code I strongly suggest you to use a logging framework. There are a lot of them out there and they allow you to save your log lines to files, upload them to a server or let the user email them, etc. etc. features vary. Two examples are CocoaLumberjack and SNLog but it is likely that you find another one that suits even more your needs.
Question two: Yes, it is possible, but the guy whom you send the app will need a Developer Certificate (or the key of your Ad Hoc certificate which I guess you don't want to give out) to be able to install the app on his phone. The format that you should use is xcarchive. Select Product -> Archive from Xcode. When the archiving has finished the Organizer will open with your new archive selected. Select Distribute -> Export as XCode Archive. You send the resulting xcarchive to your tester, and when he clicks on it (having XCode installed) it will import your compiled app as an archive in XCode organizer exactly the same way you see it. Then your tester still needs to sign it before installing on his device (by selecting Distribute / Save for Ad Hoc deployment).

How to view logs from iPhone?

I have place several NSLog() in my iOS application, is it possible to see all the logs later on my Mac that was generated when the app ran on iPhone handset even when iPhone was not connected with Mac.
Thanks
No. You can however redirect NSLog to a file, using something like this: http://blog.coriolis.ch/2009/01/09/redirect-nslog-to-a-file-on-the-iphone/
Then you can access the file via Xcode, or upload it with your app. File usage and privacy issues apply.
Keep in mind that NSLog is supposed to be turned off in published apps, so you may want to use a different logging app. A number of NSLog alternatives are available.
Unfortunately this is not possible.
The only thing that you can get is a Crash Log.
If you need a better logging system, I suggest to take a look to CocoaLumberjack, a very powerful logging framework that gives you the opportunity to save log in files and, eventually, send them to a server.
You also have many different levels like: log info, log error, log warning, etc...
You can view crash logs from your iPhone in the Organizer.
If you want to view your own log statements, you could consider TestFlight ( http://testflightapp.com ). They offer an SDK which includes features for remote logging.
I'm fairly certain that's not possible. The device needs to be connected to the Mac in order to run in Xcode's debug mode, and you need to be in debug mode to view the console, which contains your NSLogs.
There is a crash log for every crash that occurs on the phone, which is readable after connecting to your mac. These NSLog's don't appear in this log nor do they appear anywhere else in a (semi) permanent manner.
It's possible using custom macros and a custom class which will write each message in the documents directory in a file.
If the file sharing is enabled in the app you can later download them in iTunes.
Seeing the logs in mac might not be possible. But you can send the log to testflight using TFLog(). But you will need to distribute your app through testflightapp. And integrate the sdk. I think that is what you are looking for. try out - testflightapp.com

Finished Running on iPhone

I am trying to test my app on an iPhone 4S. When I build and run from Xcode, the project is successfully compiled but after that Xcode says:
Finished running MyApp.app on MyiPhone
The app perfectly work on the simulator and the provisioning profile works correctly (I tried to load an empty app and it works).
If I try to manually load the app I get this message:
The Info.plist for application at
/Users/*/Documents/App/AppName/DerivedData/AppName/Build/Products/Release-iphoneos/AppName.app
specifies a CFBundleExecutable of AppName, which does not exist.
Where is the problem?
The connection that XCode creates with the device is rather fragile, and can easily be corrupted if anything goes amiss in the debugging test, most commonly if the developer stops a build, while it is being moved to the device.
I have a routine of things I go through, when this occurs. If one doesn't work, I go further down the list.
Check your signing certificates
: This error can occur if you mess around with the certificates too much. Make sure your current scheme uses the Debug signing when making a debug build, and check in your application settings if the current debug signing certificate is a debug certificate. (Not AppStore, AdHoc or Enterprise).
Reestablish connection with the device
: Look under devices in your Organizer. Check if the device you are using is present and marked with a green bullet. If orange or grey, reconnect the device with the USB. For precaution, wait a couple of seconds from taking the cable out before you insert it. It should make no difference if you eject the cable from your mac, or the part connecting your iDevice.
Reactivate development on the iDevice
: Being unaware why this happends, some devices revert to a non-development stage from time to time. Clicking the "Enable development" under Organizer > Devices seems to clear this off.
Flushing XCode device connections
: Something that often is needed, you can simply shut down XCode (and to be safe, close the iPhone simulator as well) and start it up anew. Deleting the debug application present on the iDevice is also a good idea.
Restart your iDevice
: Tedious as it might seem, restarting your iDevice is sometimes needed, since the pipe held on the device might be corrupted.
Restarting your developer machine
: If everything else fails, a restart of your mac is often required. I have never experienced this error without having it fixed by now.
I hope this checklist will help you through.
Try cleaning the project.
SHIFT+CMD+K
Found the same bug in XCode 9 while running the project on iPhone 5s. Clean the project and it will work.
Clean.
Build.
Run.
It's work for me.
I had similar issue. When I run program on iPad2 it compiles and installs app on device, wait for some time, and display an alert. Then I followed steps below
1) Removed that application from device.
2) Disconnected iPad and tried again.
Then it successfully run in device. If this not resolved your issue, do
Rename your application to some thing else and try to run. It will run. Lastly you can make an "ipa" file with Ad Hod distribution and can test on device.
Looks like you are trying to run a release product on the device. You are probably signing it with production key. Run it as debug.
Maybe I'm totally off with this guess but the last time I got the same message was when I had some required hardware capabilities set in the Info.plist which the target device didn't comply with. (E.g. requiring a camera and trying to run the app on an iPad1.)
I've just finished chasing down a similar problem.
An app that worked on the device (iPad 1) and on the simulator stopped loading on the iPad but continued to function as before on the simulator. When "run" with the device as target, it compiles and then goes immediately to "Finished Running...".
I did all the usual bits - removed the app from the device, ran Product/Clean, removed derived data, shut computer and device down cold, but with no luck. Other development apps loaded and ran fine.
This app uses GameKit. When I removed the gameKit requirement from Info.plist, the app loaded and ran correctly on the device again - including the GameKit functionality (no kidding). When I added gameKit back in, it failed again. When I added the gameKit requirement to other apps, they failed to load to the device as well. It appears that something has happened to the gameKit setting on the device, although gameKit is there and functions as always. I'm suspicious that this one has to do with the state of the sandbox.
I've got to make a few changes to get the app running on the iPhone and I'll test that as well. I'll repost if I sort it out.
Si it seems that XCode build, ran and finished but the app failed to be deployed and was not even copied to the device.
In fact, there should be something in the XCode project that is broken. This is easily corrupted. The best move is to build a new project from scratch. Don't forget to add armv6 support if needed.
It works well for me!
Check the device log
It may occur, that you are using a provisioning profile, which does not allow one of the entitlements, listed for your target.
For example
entitlement 'entitlement-name' has value not permitted by provisioning profile 'Your Profile Name'
For me, the usual culprit is that I have an app store build already on my device.
Different/same version numbers might make things worse. I haven't looked into it too deeply since deleting the version that is already on my device usually fixes the issue.

Running blackberry app into multiple emulators at the same time

I am developing a blackberry application and I'm trying to get to devices to communicate. I am trying out the SocketDemo app and it shed light into the socket process (which is no different from any other platform so far).
Only problem is I can't test the app since I can't get the app into two different emulators. How do I accomplish this?
If you do not need to hook the second simulator into the debugger (for breakpoint setting, etc), then getting your application to run simultaneously on two simulators can be done fairly easily.
Build your application, and run it from the JDE; standard procedure.
Then, outside the JDE, start another simulator (it cannot be the same one), and, when that's up and running, choose FILE->LOAD JAVA APPLICATION from the second simulator's window menu. Select the .COD of the application you just built. The application will then be installed onto the second simulator, and will either start automatically, or you can start it by clicking on its icon (depending on how your project is set up).
With two simulators on the same machine, with applications that need to communicate through the network, it may be needed to change the ports in the .BAT file that launches the second simulator, before starting it -- otherwise, the second simulator may not be able to bind to the same ports on the machine.
Indeed, with some simulator models, you will not be able to do this unless the second simulator is from a different simulator package (different directory), because the process grabs a lock when it runs.
If you are using a built-in simulator package that only contains one simulator, you can download a second simulator, ideally a different model, from RIM's developer site: http://www.blackberry.com/developers/downloads/simulators/
Have you tried installing different JDE's and trying to run emulators from them?

iPhone Device Debugging

Is it possible to actually use the Xcode debugger when running an iPhone app on the device rather than the simulator? i.e., can I have the device stop at breakpoints that I set in my code and step through the code as it runs on the device?
EDIT: I should mention that I am a registered developer with Apple and have a valid certificate. In fact, I can build and run iPhone applications on my device just fine. However, even in Debug mode, my application will not stop on breakpoints or output to the console when I run it on my device. If it helps, my application will function normally in debug mode (e.g., stopping at breakpoints) when I run in the simulator.
EDIT 2: I've tried resetting my phone, completely removing and reinstalling Xcode, creating a new project, changing all the settings mentioned in the answers on this page (as well as others), cleaning and building my project, Build and Debug... If I click Pause, it says "Error from Debugger: Quit". :( Maybe I'll try to debug on this device using Xcode on another computer and see what happens.
EDIT 3: Well, I tried using another computer using a fresh install of Xcode in a new project, and I still can't get device debugging to work. I have a suspicion that it's my iPhone or cable perhaps? I'd like to think that I'm not so incompetent that I've missed something so embarrassingly obvious, but I've double- and triple-checked all of the suggestions mentioned here.
EDIT 4: FINALLY got device debugging to work. I have a feeling that something low-level on my device was causing issues...nothing I did worked on my system. However, I installed Xcode on another system and device debugging on the same device (with the same cable) worked flawlessly. Directly after that, device debugging began working on my original machine, leading me to believe that some strange hardware flag was screwed up and somehow "reset" on the second machine. In any case, it works now... Thanks for all the help. :)
Also, I'm unsure if it's better to leave this question unanswered or pick the most "helpful" answer...
Yes -- just use a device build. You have to get certificates and provision it.
This is a good description:
http://boga.wordpress.com/2008/07/16/debugging-ipod-provision-profilescertificates/
Make sure to start debugging by pressing "Cmd-Y"... and not "Cmd-R" :-)
You may try last trick in case nothing can help.
If your application launched successful on your device from XCode but did not stop at breakpoints - try press "pause" button after start in debug mode. If you will see application paused properly (do not react to user's action) add new breakpoint then press "run" to continue application execution. In some cases it may helps to stop at new breakpoint.
Yes, just set your project to build for the Device.
If you need to setup debugging for jailbroken iPhone (up to 2.2.1) (not pay 99 to Apple yet) follow next steps:
Install MobileInstallationPatch for your iPhone via Cydia (use Search Tab)
Switch off PROVISIONING_PROFILE at XCode: Go to /Developer/Platforms/iPhoneOS.platform/Info.plist, add next keys:
<key>PROVISIONING_PROFILE_ALLOWED</key>
<string>NO</string>
<key>PROVISIONING_PROFILE_REQUIRED</key>
<string>NO</string>
You may also add these keys to any
project particularly at XCode, Project
Build Settings, User-Defined
variables.
Add key to your project Info.plist at XCode
SignerIdentity = Apple iPhone OS Application Signing
Don't forget to install and add to your project settings self-signing certificate from Apple
http://developer.apple.com/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html#//apple_ref/doc/uid/TP40005929-CH4-SW2
"Build and Go", you can connect iPhone and start debugging.
Important! You may need to install and launch at least one legal app (any free one) from App Store first (before "Build and Go" step). Otherwise your application will be successfully installed by XCode to your device but may not be launched. Try this troubleshoot first in case of problem with app launching.
Yes. Debugger and performance tools work fine on the device. That's where I do most of my debugging.
Xcode>preferences>debugging uncheck load symbols lazily
fixed the breakpoints not holding in device problem for me.