Under the Bridge

Roundup: Debugging Goodies

So there’s been a number of interesting tools, tips, and tidbits of the fixing and fussing sort floating by recently, let’s collect them all up shall we?

TOOLS:

PonyDebugger we’ve mentioned before but can’t do enough; network traffic debugging, Core Data browsing, view hierarchy displaying, so cool it’s downright frosty.

superdb: The Super Debugger by @jasonbrennan brings real time dynamism to your debugging:

The Super Debugger (superdb for short) is a dynamic, wireless debugger for iOS (and theoretically, Mac) apps. It works as two parts: a static library that runs built in to your app and a Mac app to send commands to the app, wirelessly. Your app starts up the debugger via this library, which broadcasts itself on your local network. The Mac app can discover these debug sessions via Bonjour and connect to them.

You can then send messages to your live objects as the app is running on the device (or Simulator). No need to set any break points. Any message you can send in code can also be sent this way. This allows you to rapidly test changes and see their results, without the need to recompile and deploy.

The debugger will even let you rapidly resend messages involving numeric values. When trying to tweak an interface measurement, for example, you can just click and drag on the value and see the changes reflected instantly on the device…

Between the two, that’s enough coolness to send global warming shuddering into reverse, doncha think?

markd2 / GestureLab is good stuff for debugging gesture recognizers.

UIView+DTDebug.m detects those annoying background drawing calls that always seem to slip in somewhere.

garnett / DLIntrospection makes examining objects at runtime convenient.

Which reminds us of the DCIntrospect UIKit interface examiner you might have forgotten our last mention of.

Did you know weak properties are not KVO-compliant? Debug usage of Objective-C weak properties with KVO.

The debugger of royalty introduces

… step one on the road to sanity: the debug proxy. This is useful when you want to find out how a particular class gets used, e.g. when it provides callbacks that will be invoked by a framework. You can intercept all the messages to the object, and inspect them as you see fit…

tomersh / NanoProfiler is a super lightweight individual function profiler.

siuying / IGWebLogger is a CocoaLumberjack logger which logs to the web in realtime.

Log Leech is a nifty-looking log formatter “Because System Logs Should be Beautiful.” Indeed.

TIPS:

Debugging Tips video presentation is the single best introduction to the basics we’ve seen (h/t: iosdevweekly!)

How to Use Instruments in Xcode is an excellent introduction to that, should you need one.

Intermediate Debugging with Xcode 4.5 has good stuff on leveraging breakpoints.

Xcode LLDB Tutorial introduces how to use predicates and KVC in the debugger;

Querying Objective-C Data Collections is the don’t-miss followup.

Stack-trace-dumping regular-expression-based symbolic breakpoints in LLDB

Hooked on DTrace, part 1 and part 2 and part 3 and part 4 are must-reading for when you want to get below the Instruments level. Also check the comments for pointers to good stuff like Top 10 DTrace scripts for Mac OS X and this DTrace book.

Analysing iOS App Network Performances on Cellular/Wi-Fi shows how to create HAR files so as to take advantage of its various nifty helper tools.

There’s somewhat of a certain symmetry here: going down just as far down as it’s possible to go debugging in “Assembly Dissembling” was what the first post we made after signing up to guide development of the Atimi Mobile Sports Framework was about, and after doing so from support of seven teams and two sports to thirteen teams and five sports across iOS, Android, and BlackBerry 10, it’s about time to shake things up a bit; and here we are, our first post after leaving is about debugging too! Great place for a full time job, Atimi, we encourage you to check out their positions if you’re looking for one; but we’re off now to focus on a more equity-involving opportunity. Not completely, though, a little variety on the menu is always welcome; so if you have any little bite-sized projects that need some chewing, drop us a line and we’ll see what we can fit in!

UPDATES:

MattesGroeger / MGBenchmark for timing operations hard to profile with Instruments

This Xray Editor “The missing visual feedback tool for iOS developers” looks mighty cool.

This Spark Inspector thingy looks like it might be even more cool than that when it comes out.

Tool For Quickly Launching, Deleting And Seeing Details Of iOS Simulator Apps

To avoid debugging unavailable or obsolete API usage, try DeployMate.

Continue Reading →
0

URL Scheme Tidbits

Been a while since we noted anything much about URL scheme fun and games around here, ’tisn’t it? To refresh your memory, here’s a couple still worthwhile posts:

handleOpenURL.com mentions places to find databases of app’s URL schemes;

x-callback-url described an excellent initiative for standardizing those schemes.

But unfortunately, x-callback-url hasn’t been adopted all that widely so far. But with this new library you have no further excuse not to:

tapsandswipes / InterAppCommunication

x-callback-url made easy

Inter-App Communication, IAC from now on, is a framework that allows your iOS app to communicate, very easily, with other iOS apps installed in the device that supports the x-callback-url protocol. With IAC you can also add an x-callback-url API to your app in a very easy and intuitive way.

IAC currently supports the x-callback-url 1.0 DRAFT specification

If, on the other hand, you have complicated URL schemes that you’re not interested in supporting that with, there’s another new library for you too:

joeldev / JLRoutes

JLRoutes is advanced URL parsing with a block-based callback API. It is designed to make it very easy to handle complex URL schemes in your application without having to do any URL or string parsing of any kind.

  • Simple API with minimal impact to existing codebases
  • Parse any number of parameters interleaved throughout the URL
  • Seamlessly parses out GET URL parameters and passes them along as part of the parameters dictionary
  • Route prioritization
  • Scheme namespaces to easily segment routes and block handlers for multiple schemes
  • Return NO from a handler block for JLRoutes to look for the next matching route
  • Optional verbose logging
  • Pretty-print the whole routing table
  • No dependencies other than Foundation

Look like a good pair of candidates for a mashup, don’t they?

In other news, here’s a clever tip for using URL schemes to activate experimental facilities:

Letterpress 1.4 includes experimental support for Spanish. Type in “letterpress:experimental” in Safari on your device (or just tap that link) to enable the dictionary options. You can then switch the dictionary under More / Language…

We are definitely going to start exposing things like that in our apps. Debug-related functionality is a particularly fertile field; we can think of many occasions indeed when a command like “myapp:throwupdiagnostics” would have been mighty handy indeed to stick in a support reply.

And just to remind you of another clever URL scheme trick, checking to see if they’re handled is a good way of knowing if an app is installed, as demonstrated to slick effect in a Collect Them All Feature!

UPDATES:

Courtesy of @viticci, “People doing stuff with URL schemes:”

Convert Text Action

The URL Creation Workflow

iOS URL Schemes

Create A Local Evernote URL on the iPad with Pythonista

UTI definitions are another approach to the problem of data sharing: Using Custom File Types to import data into your iOS Apps

Open Source iOS Library Providing An In-App URL Router

Continue Reading →
1

Sequencer: Async Flow Control

Here’s a sweet library for getting rid of those annoyingly deeply nested block constructs:

berzniz / Sequencer

Sequencer is an iOS library for asynchronous flow control.

Sequencer turns complicated nested blocks logic into a clean, straightforward, and readable code.

Sequencer *sequencer = [[Sequencer alloc] init];
[sequencer enqueueStep:^(id result, SequencerCompletion completion) {
    NSLog(@"This is the first step");
    completion(nil);
}];
[sequencer enqueueStep:^(id result, SequencerCompletion completion) {
    NSLog(@"This is another step");
    completion(nil);
}];
[sequencer enqueueStep:^(id result, SequencerCompletion completion) {
    NSLog(@"This step is going to do some async work…");
    int64_t delayInSeconds = 2.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        NSLog(@"finished the async work.");
        completion(nil);
    });
}];
[sequencer enqueueStep:^(id result, SequencerCompletion completion) {
    NSLog(@"This is the last step");
    completion(nil);
}];
[sequencer run];

What does the above code do?

A Sequencer was created. There is no need to retain/hold-on-to-it. Trust me.

Four steps were enqueued to the Sequencer. The third step is async, but all the rest are plain sync code.

Each step finishes by calling completion() with a result object. This result is sent to the next step (in our case the result is nil).

We run the sequencer.

Note: Break the steps by just removing the call to completion(nil). Everything will be cleaned-up auto-magically.

Simple, elegant, and functional: What more could you ask for?

h/t: ManiacDev!

Continue Reading →
0

Review: Creating Games with cocos2d for iPhone 2

So as promised in our cocos2d survey a couple days back, we’ve been reading the latest from Packt,  Creating Games with cocos2d for iPhone 2:

9007OS_9007OS_Cocos2d for iPhone Hotshotcov.jpg.png

and why yes, we quite like the approach it takes. Most books we read go through pieces of a big project where the newbie finds themselves easily overwhelmed, or are snippets without a context so you need to be able to grasp their application on your own; what this one does is present nine complete but small enough to be easily graspable games of popular genres — and bundled them up to the App Store too, where you can check them out to see if you’re interested in seeing the code:

Pack 1 – Mole Thumper, Brick Breaker, Pool

Pack 2 – Memory, Match 3, Snake, Scrolling Shooter, Endless Runner

Pack 3 – Cycles of Light

The theory behind that is explained on the cocos2d blog here:

… Most developers learn the basics of cocos2d for iPhone v.2.0, and subsequently hit a wall. We have all these interesting classes that are really powerful, like CCLayer, CCSprite, actions, etc. How can we put these things together and make something equally interesting out of them?

That is the “gap” this book aims to fill. Rather than take the beginner’s book approach, where we spend several pages explaining what a sprite is, how it is drawn, etc. “Creating Games” skips many of the generalities and jumps right into the reason we are here: building games. This is the book I wished I had in hand when I was first exploring cocos2d for iPhone.

Class by class, method by method, the text explains the “good parts” of why we are building the code in this fashion. All the “good parts” are explained in detail: from building with Box2D to GameKit Bluetooth integration, and even how to build in “artificial randomness” into a Match 3 game, so you never run out of moves.

Each chapter is a complete game, and all source code is available as a download from the publisher’s web site. The games cover a wide variety of game types, and the games become more intricate and complex as the book progresses…

Can’t add to that really, except to observe that why yes the book is pretty much perfectly positioned to help cover that jump from reading the API to figuring out how to actually use it. So if you’re a complete newbie, we’d still recommend The iPhone Game Kit; but if you’ve got a bit of programming background but are new to cocos2d and/ot game programming, yep this is an excellent choice. Or if you’re interested in checking out the approach the author takes to the covered game genres, which are

  • Chapter 1: Memory
  • Chapter 2: Match 3
  • Chapter 3: Mole Thumper
  • Chapter 4: Snake
  • Chapter 5: Brick Breaker (with Box2D)
  • Chapter 6: Cycles of Light (iPad with Bluetooth integration)
  • Chapter 7: Pool (with Box2D)
  • Chapter 8: Scrolling Shooter (using Tiled)
  • Chapter 9: Endless Runner

One quibble you might have is that why isn’t v2.0 out of date already? Yep, but not by much, and download notes to bring it up to speed are on the author’s site. And while you’re there, check out the video. Definitely the best trailer we’ve ever seen for a programming book. (Pretty sure it’s the only trailer we’ve ever seen for a programming book, so the bar’s low there, but hey.)

So overall? Well, we like to reserve five stars for books that qualify as “absolutely essential fundamentals”, and it’s not quite that, but it is definitely a well done guide with far more coherence than you’ll find hunting down tutorials and samples on the web. Solid four stars, with the particular recommendation that if you find yourself in the position of being able to install cocos2d and run the samples but are having trouble gapping that over to getting started on your own game, this is the absolutely perfect book for you!

Continue Reading →
0

State of cocos2d Address: 2013

So just over one year ago we took a look at developments in the cocos2d world in the previous year while gearing up to review Packt’s latest book on the subject, and why look; we’re doing the exact same thing now! This year, it’s Creating Games with cocos2d for iPhone 2:

9007OS_9007OS_Cocos2d for iPhone Hotshotcov.jpg.png

… and in very short order we trust, we’ll have opinions for you on it!

Meanwhile, the most surprising — although in hindsight obvious — news of 2012 in cocos2d land was the announcement of the explicit refocus from iOS gaming to a cross-platform development suite:

… Our goal is to provide a complete toolchain for developing multi-platform games both for Web and Mobile, all the way from rapid prototyping to a finished high performing game. The main components of our stack are:

For the Web, we are using pure JavaScript code, while for Mobile we are using JavaScript on top of native engines for maximum performance…

Apparently 2012 was also a good year for altering common understandings of terms like “maximum”. But snarkiness aside, yes it’s pretty likely that many iOS-centric developers are willing to compromise as much as Zynga to improve cross platform development efficiency; so this is no doubt A Good Thing™ for them. Latest coordinated release as we type here was four days ago, release notes here.

On the other hand, if you understandably recoil in quivering horror at the thought of sullying your iOS-centric vision with accommodations to those other, lesser, platforms, then 2012 brought you the full blown fork “KoboldTouch”. That seems to be chugging along nicely as well so far.

Tools-wise, the landscape of essential goodies really didn’t change during the year aside from the anointing of CocosBuilder mentioned above, but keep your eye on Spriter and ArtPigEditor as possible supplements. This tools list from July looks still pretty much up to date, and of course the mothership’s Editors/Tools forum is always worth keeping an eye on. Oh, and when you get around to marketing videos, Kamcord looks pretty nifty.

On the learning resources side, the only brand new book of 2012 is the one above; but Mr. KoboldTouch brought out a third edition “Learn Cocos2D 2″, and our still #1 recommended getting started resource is The iPhone Game Kit, now updated for iOS 6 and cocos2d 2.0. ‘Course, soon as you get your feet wettish with those, you should head directly to RayWenderlich.com, who definitely wins the Internet as far as iOS tutorials go. Notable cocos2d posts/updates are

Other miscellaneous tidbits, tips and tricks from around the web (ok, mainly ManiacDev.com) of interest:

Example: Easily Creating Particles In Cocos2D That Can Both Fade In And Out

krzysztofzablocki / CCNode-SFGestureRecognizers – “a category designed to simplify adding UIGestureRecognizers support”

Exporting Flash Animations to Cocos2d Actions

Open Source: Library For Importing Flash Animations Into Cocos2D iOS

Tutorial: How To Easily Create A Cocos2D AI Controlled Actors With A Finite State Machine Compiler

Example Source Code: Easy Cocos2D Sprite Floodfill Class

List of Open Source Cocos2d Projects, Extensions and Code Snippets

18 Tools and Source Code Components for Cocos2D iOS Game Development

Tutorial: How To Make Jagged Drawn Lines Smooth In Cocos2D

How to Zoom In on a Cocos2D Node

Example: Open Source iOS Castle Destruction Game Using Cocos2D And Box2D

Cocos2D and Storyboards

nerdcave / PESprite – “a CCSprite extension for cocos2d that supports collision detection”

CloudBomber – Cocos2D deformable terrain example project

Pixel based destructible ground with Cocos2d

A Magnifying Glass for Cocos2D

Open Source Cocos2D Based Framework For Creating Highly Interactive iPad Books

Building a depth map for cocos2d in Photoshop

Tutorial: Build An Angry Birds Style Game Quickly W/Cocos2d, LevelHelper and SpriteHelper

sceresia / CCAutoType – “cocos2d-iPhone class to add RPG-like auto typing dialog”

Simple Fractal terrains [in] cocos2d

Tutorial: Create A Character With Ragdoll Physics Using Chipmunk And Cocos2D

Strategies for Accessing Other Cocos2D Nodes In The Scene Hierarchy

The Four Ways of Implementing a Scrolling View with Cocos2D Explained

Example: Displaying A 3D .OBJ Model In Cocos2D iPhone v2.x (W/Zooming, Rotation, And Movement)

Example: An Open Source iOS Pokemon/Pet Type Game Created Utilizing Cocos2D

UPDATES:

Open Source Pinch To Reveal Animation using Cocos2d

Continue Reading →
1

Overloading C Functions

Did you know that the latest versions of Clang let you overload C functions? We’d completely missed that!

Clang provides support for C++ function overloading in C. Function overloading in C is introduced using the overloadable attribute. For example, one might provide several overloaded versions of a tgsin function that invokes the appropriate standard function computing the sine of a value with float, double, or long double precision:

#include <math.h>
float __attribute__((overloadable)) tgsin(float x) { return sinf(x); }
double __attribute__((overloadable)) tgsin(double x) { return sin(x); }
long double __attribute__((overloadable)) tgsin(long double x) { return sinl(x); } 

Given these declarations, one can call tgsin with a float value to receive a float result, with a double to receive a double result, etc. Function overloading in C follows the rules of C++ function overloading to pick the best overload given the call arguments, with a few C-specific semantics…

That’s one of the vanishingly few things we still occasionally miss from our C++ days. Kinda awesome to get that for Objective-C!

Overloading C Functions with Clang demonstrates how to use this for a single map function for NSDictionary and NSArray; and by way of that, if you’re not overly familiar with functional language conventions, here’s a good article on Understanding map, filter, and fold.

h/t: @romainbriche!

Continue Reading →
0

STTweetLabel

This is certainly conveniently timed; yesterday they decided they’d like player names to be tappable to bring up the player’s card everywhere they’re displayed in Atimi’s sports apps — and why look, today we have an example of just how to go about that!

SebastienThiebaud / STTweetLabel

A custom UILabel view controller for iOS with certain words tappable like Twitter (#Hashtag, @People and http://www.link.com/page)

screenshot.png

h/t: iOS Dev Weekly!

Continue Reading →
1

CMUnistrokeGestureRecognizer

Ever tried to write a UIGestureRecognizer? Kinda hard, wasn’t it? Well, check out CMUnistrokeGestureRecognizer:

How would you go about recognising a gesture like this star shape in an iOS app?

star_gesture.png

This was the problem posed to me recently while working on a project … Created by three clever chaps at the University of Washington back in 2007, the $1 Unistroke Recognizer was designed to recognise single path (unistroke) gestures, exactly what I was looking for. Not only that, but design goals for the technique make it an ideal candidate for use in mobile applications…

CMUnistrokeGestureRecognizer is my port of the $1 Unistroke Recognizer to iOS. I’m not the first to implement this recogniser in Objective-C but none of the existing implementations met my requirements. I wanted the $1 Unistroke Recognizer to be fully contained within a UIGestureRecognizer, with as simple an API as possible.
So the CMUnistrokeGestureRecognizer implements the $1 Unistroke Recognizer as a UIGestureRecognizer. It features:

  • Recognition of multiple gestures
  • Standard UIGestureRecognizer callback for success
  • Template paths defined by UIBezierPath objects
  • Optional callbacks for tracking path drawing and recognition failure
  • Configurable minimum recognition score threshold
  • Option to disable rotation normalisation
  • Option to enable the Protractor method for potentially faster recognition

Looks like just the thing for adding complex gesture support into your apps, doesn’t it now?

h/t: iOS Dev Weekly! (Yes, we just read the Dec. 14th issue. Getting back up to speed, slowly…)

Continue Reading →
0

iPhoneTrip.com

So we’re just back from going walkies about southwest Europe for the Christmas break, and before we get into checking out just what all we missed in development circles whilst away, we have a recommendation for staying connected on your next trip:

iPhoneTrip.com

Pretty much as simple as it gets: pick the country you’re going to, or “World”/”Europe”/”Asia” for multiple countries, the dates you want it, and whether you want 50/100/500 (“Unlimited”) MB a day; and they’ll mail (or FedEx, if you’re as last-minute as our planning always seems to work out) you a SIM and a backup. Worked out about a fifth the price of what our carrier costs us for roaming data travel packs, plus better coverage; besides various mainland countries, we wandered off to outlying bits and pieces from Madeira to Melilla — and absolutely everywhere we had any cell signal at all, our “Europe” SIM worked flawlessly. You could probably shave off a few more bucks by hunting down local carrier data SIMs each place you visit sure, but for sheer convenience? No beating these guys. Check out the Engadget review for more discussion.

Another handy piece of kit for the inveterate road-tripper we can recommend from experience: this auto/air power inverter from Kensington.

Kept our iPhone, iPad and baby Macbook Air running nicely all through the trip. Some of the Amazon reviews claim it’s noisy, but not the unit we got; can’t tell if it has a cooling fan at all, for all we ever heard from it. If you’re going to be on the move constantly like us, highly recommended indeed.

Continue Reading →
1

UI Screen Shooter

This is an interesting — and handy! use of UI Automation:

jonathanpenn / ui-screen-shooter

This is a set of scripts to demonstrate how to take screen shots for your iOS app for the App Store automatically using UI Automation. It shows how to take screen shots, extract them from the automation results and change the language in the simulator with shell scripts. This saves quite a bit of time since we need to generate screens for the 3.5″ display, the 4″ display, and both iPhone and iPad if your app is universal–not to mention that you have to do this for every localization you support in the store.

You can see the script run against one of my apps in this video

Some more handy UI Automation tips here.

h/t: iOSDevWeekly!

UPDATES:

Automating iOS App Store screenshots

Continue Reading →
0
Page 2 of 106 12345...»