Profiling CPU Instructions on iPhone - ios

I would like to be able to profile a particular C function within an iOS application to see which CPU instructions it uses, and how often they are used. What is a simple way to go about doing this?

You'll want to check out the Time Profiler tool in Instruments. Check out the User Guide for some detailed information on how to best make use of it.

Related

Getting Started with iOS Newsstand App Automation

I am currently testing few features of a newsstand app manually. The kind of testing I do is pretty basic. To list a few:
Launch and exit the App
Launch, Navigate to menus and Login, Logout
Launch, take screenshot of splash screen
Launch, test the color of some text.
and so on. As there are 100s of tests like this, I want to automate these.
I do not have a Mac. Are there any tools (open source preferably) for achieving this?
Please note that I am kind of learning this myself and my company would not provide the cost required at this time. Its more of a PoC. So, when I have something concrete they will support eventually.
Please advice what tool I can use to achieve this (I hear a lot of things about Cucumber but I dont know Ruby. I am willing to learn, if that is the only best tool available).
Also, a sample code snippet on how to launch a newsstand app on the real device through an automated way would be cool.
Thank you!
Apple provides a Automation f/w as part of Instruments.
There are various tutorials/getting started guides available. Try searching "UIAutomation getting started" in google.
Some other third-party options for iOS application test automation:
Monkey Talk
Calaba
Telerik Test Studio
UI Spec
I had evaluated these tools some time back and decided to use Apple's UIAutomation f/w. It has many flaws but we have been able to use it successfully.
You will need OSX and XCode for automation. All UIAutomation frameworks are based around the instruments executable provided by Xcode.
I can also recommend the Illuminator framework which I wrote to overcome a lot of the bugs and shortcomings in Apple's UIAutomation.

How does Instruments collect data from iOS without DTrace being available?

I am trying to understand the inner workings of XCode's Instruments. On MacOS, it can rely on DTrace to gather all kinds of profiling data. On iOS, it is also capable of lots of things, but I have read repeatedly that DTrace has not been ported to iOS.
So how does that work?
The Apple documentation on DTrace isn't telling me much about the inner workings here. I have noticed, however, that when profiling my own App from XCode using Instruments, XCode seems to build it differently. Could that mean it links some standalone DTrace providers with my code?
Thanks in advance!
/e: I would bounty this question with my ENTIRE 6 REPUTATION POINTS if only i could...
For iOS apps running inside the Simulator, obviously the Simulator is a Mac OS X program, so it can use DTrace to monitor everything the Simulator does.
For iOS apps running on an iPhone, I agree the documentation provides little insight into what's happening. It's probably either loading monitoring code into the target process on iOS (either by adding the code at compile time or by linking it in at runtime) or there is an "traditional debugger" running on iOS against the target process to implement the tracing. Those are pretty much the only options if there is no kernel-level support for using DTrace.
I've never used Instruments, but the main thing that jumps out at me is that they're able to collect seemingly-OS-level statistics about I/O, which would not normally be measurable without DTrace. I'm not sure because I haven't used it, but it's possible these statistics are only tracking I/O from easy-to-detect entrypoints (ie I/O-related syscalls from the specific target process), or that there are other iOS-specific statistic sources which are published by the OS. For instance, many system statistics can be gotten from Mac OS X by calling sysctl. Depending on what statistics are actually being collected, Instruments could just be using simple counters like these to do most of the work.
If you're really determined to find the answer, it would be a fun DTrace challenge to figure this problem out by DTracing Instruments itself. Good luck :-)

How to prevent ipa file/iphone application from being cracked to source?

from one of the stackexchange questions Here,its proved that we can decompile the iphone application to its source,Now here comes the question how can we protect the ipa file/iphone application from cracking to its source?i have already verified this answers
here 1
method 2
but sad thing is it fails to protect the code,any updates to prevent app to source code
You can't really.
The iOS runtime on the device needs to be able to interpret the binary, so the binary has to be there, unencrypted and ready to run.
You could obfuscate it, by running it through a tool that scrambles method names, property names and so on. .NET and Java have tools that do this but I'm not aware of any for Objective-C, so I think you're on your own.
(Tools like anticrack, the one you linked to, will work for a short time until someone comes up with a way to reverse what anticrack does - but because your app eventually has to be there in a format the runtime is ready to run, all you can do is make it more difficult. It's like the age-old arms race of pirates vs protection mechanism in desktop applications).
This has been much discussed. Generally, you make more money spending time improving or promoting your app, then spending time trying to prevent it from being cracked in any way.

Instruments and Shark

I've finally reached the end of app creation.
I know that Instruments and Shark can be used to test for memory leaks and other such "bad stuff" in your apps. Unfortunately I can't find any good tutorials on how to use these tools.
Especially for Shark, how should I go about using these tools?
Additionally, are there any other similar tools that may be more powerful or easy to use? Thanks you!
One way to find memory leaks and other problems is to use static analysis. If you're using Xcode, there's an integrated tool that's located in Product->Analyze.
Shark is no longer really used, use the Time Profiler instrument instead.
Currently your best bet is reading through the Apple documentation on Instruments.

secure ios app from hack - objective-c

Is it possible to make app not launchable if it has been cracked and installed from installous? I don't want to see my app in installous
It's not that easy and it not answerable within some words or code snippets.
But you might check this:
http://www.shmoopi.net/ios-anti-piracy/iphone-piracy-protection-code-tutorial-2/
http://www.cocos2d-iphone.org/forum/topic/7667
http://thwart-ipa-cracks.blogspot.com/2008/11/detection.html
The read also here:
http://www.learn-cocos2d.com/2010/05/ignore-everything-youve-heard-about-app-store-piracy/
There are ways to detect whether your app is running on a jailbreaked device or whether your app has been modified (aka cracked). Take a look here and here for example.
From my point of view all you are getting by using these methods is a waste of time. Maybe you can make it harder for potential crackers and keep away the script kiddies. But you won't get that far that no talented cracker on earth would be unable to crack your app. Even one single cracker on earth who's able and motivated to crack your app is enough to upload it to hundred's of sites.
If really big companies fail at protecting their apps I really doubt that you will achieve it... so: wasted time which should be better spend on improving your app.
Probably not, because the part of cracking your application is to remove all restrictions (registration, detection of jailbreak, ...).

Resources