3

When working with iOS, I sometimes have values I need to test with. I may adjust these values 30 times, and have to rebuild/rerun 30 times to test them. This is an obvious hassle.

So I was wondering (using the iOS SDK) if it was possible to tweak small parameters/data at the app's runtime? Just to make life convenient.

Monolo
  • 18,205
  • 17
  • 69
  • 103
MCKapur
  • 9,127
  • 9
  • 58
  • 101
  • You are being a bit vague... – Rui Peres Mar 22 '13 at 14:26
  • 2
    If you mean using the debugger, check this answer: http://stackoverflow.com/questions/9907387/how-to-change-variables-value-while-debugging-with-llvm-in-xcode – James P Mar 22 '13 at 14:27
  • 1
    I've never tried that, it should work if you can test what you need against simulator reading "parameters/data" from files. To do that you replace the files at documents folder (or even at bundle) located on your disk, then let the app to read updated files. If you need to use a device for testing, there's still a similar solution using something like iExplorer, don't know if it's possible to automate copying for such apps though. – A-Live Mar 22 '13 at 14:41

2 Answers2

7
  1. Set a BreakPoint
  2. In lldb debug area type:

Example 1:

expr (void)[aView setBackgroundColor:(UIColor*)[UIColor redColor]]

Here, aView is an UIView for which I want to see its frame at runtime. I am calling the setBackgroundColor method of an UIView at runtime. Any method could be called like that.

Example 2:

expr nsstringVariable = @"yourRunTimeValue"

Here, I am changing a string variable at run time.

For more help on expr type

help expr

I highly recommend people to read this tutorial by Brian Moakley Intermediate Debugging with Xcode 4.5

Monolo
  • 18,205
  • 17
  • 69
  • 103
Warif Akhand Rishi
  • 23,920
  • 8
  • 80
  • 107
3

Yes, with Injection for Xcode:

Using Injection it is possible to make a change to the implementation of an Objective-C class and have it take effect as soon as the class is saved without having to restart the application. This feature works for OS X and iOS applications in the simulator and on iOS devices.

Jano
  • 62,815
  • 21
  • 164
  • 192