Dark Magic for Debugging your iOS app

Opensource libraries that aid development and you should keep them in your toolbar

James Tang
iOS Apprentice

--

Apple Xcode is a wonderful tool for development and debugging. iOS 8 brings whole new power to the embedded tool like Instruments, iOS Simulator, and Playground, etc.

However, one size doesn’t fit all…

There’s always something missing in our tools or features that our SDK will never enables. Luckily the development community knows their own pain points and develop their own solution. Here, we focus on libraries that integrates into the project that can aid debug/development.

FLEX

It’s like having the power of Reveal App within your app. You can:

— Inspect a UI element
— Adjust frames for them, etc

For more secrets from Flipboard team, go watch the video iOS Tools at Flipboard — Evan Doll.

OHHTTPStubs

Stubs your network requests. It allows you:

— Test your apps with fake network data
— Simulate slow networks
— Write unit tests with fixtures

It’s a great tool to speed up development when the server is not ready and you need to mock data for local development.

NSObjectIntrospection

Allow for runtime introspection for any NSObject, you can:

— List out methods and properties for a class in runtime
— or through debug console

You can also use as runtime magic if you’re creative enough.

Tweaks

Tweak small adjustments with no code changes and no computer. It allows you:

— Toggle any hidden settings and application behaviours
— Adjust any small values on-the-fly such as a color or animations

It’s pretty useful to coordinate small adjustments between designers and developers, so the former can tweak values until fully satisfied, and then export to the development team to finalize the changes. Also, here’s a great video on how Facebook team build the Paper app.

MMLayershots

Converts your iOS screenshot into a layered photoshop (PSD) file. It lets you:

— Iterate visual changes can often be much faster
— Works with framer.js for rapid prototyping with animations

I hope someone create a library for Sketch.

CocoaLumberjack

(added at July 27, 2014)

A better logging framework for OSX and iOS. It allows you to:

— Add color to the debugger console (requires XcodeColors plugin and can be installed via Alcatraz)
— Provide different levels of logging
— Write custom formatters for your logs

It has been for a while, if you’re looking for a better and more advanced logging system, this most probably is for you.

Aspects

Aspect Oriented Programming in Cocoa. It enables:

— Swizzle methods with ease
— Add code to existing class or instance in common insertion points (e.g. before/ instead/after)

It could be useful for things like debugging and adding analytics methods.

RHObjectiveBeagle

(lldb) po beagle(@"UISwitch")
<__NSCFArray 0x8f2e6c0>(
<UISwitch: 0x8f73aa0; frame = (93 226; 51 31); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8f73bd0>>,
<UISwitch: 0x8e6fa50; frame = (171 226; 51 31); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8c6a760>>
)

A debugging aid that sniffs out instances of a specified class in your running process. You can:

— List all instances of a class and it’s subclasses
— List all instances of a specified (exact) class
— Find the first instance of a specific class
— Lookup and list all the subclasses of a specific class

It’s like a better -[UIView recursiveDescription], but as stated in the README you should only really use it for debug purpose.

The list goes on, but it quite a bit for now, hope you find it useful.

Talk to me anytime at my Twitter @jamztang, and you can continue to read my other articles in my iOS Apprentice Collection.

--

--

James Tang
iOS Apprentice

Sketch Plugins and iOS UX Engineer. Opensource projects contributor, share on Twitter. @jamztang