Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toggle slow animation while debugging with iOS Device

Tags:

xcode

ios

ios5

I'm using xCode 4.3.1 and I need to use the option that the iOS Simulator has => Debug -> Toggle Slow Animation but while debugging with the iOS Device.

Is it possible?

like image 431
fabregas88 Avatar asked Apr 19 '12 13:04

fabregas88


3 Answers

It's not possible in exactly the same way as with the Simulator, but there is a good way to accomplish the same effect using lldb.

Use the debugger to pause code execution, and then enter the command:

p [(CALayer *)[[[[UIApplication sharedApplication] windows] objectAtIndex:0] layer] setSpeed:.1f]

into the debugger.

Thanks to this link for the solution.

like image 171
Tim Arnold Avatar answered Oct 18 '22 19:10

Tim Arnold


In Swift 3:

UIApplication.shared.windows.first?.layer.speed = 0.1

Or, if you're anywhere in your AppDelegate and you only use one window, you can do this:

window?.layer.speed = 0.1
like image 25
JAL Avatar answered Oct 18 '22 19:10

JAL


For Swift Apps:

Halt your code with a breakpoint and enter the following lldb command:

(lldb) p UIApplication.shared.windows.first?.layer.speed = 0.1


Alternatively you can obviously also change the speed somewhere in you code. For example with an #if preprocessor macro at application launch

func application(application: UIApplication,
   didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 
{
    ...

    #if DEBUG
        application.windows.first?.layer.speed = 0.1
    #endif

Don't forget to set the DEBUG symbol in the "Swift Compiler - Custom Flags" section, "Other Swift Flags" line. You add the DEBUG symbol with a -DDEBUG entry.

like image 18
dreamlab Avatar answered Oct 18 '22 17:10

dreamlab