Appcelerator Titanium iOS Debugging with XCode

Appcelerator Titanium iOS Debugging with XCode

Appcelerator Titanium iOS Debugging with XCode

Earlier this week, I was debugging and I was reminded of the sheer power of the XCode developer tools, even in the context of a not-quite-native application like a titanium application.

The Problem

Andrew was working on an application that will load in a large number of images and PDFs from a remote server and display them to the user, in-app. However, when we got to the point that we would be displaying a certain one of our images, we saw this in the Titanium console:

[ERROR] invalid image type. expected TiBlob, String, TiFile, was: TiBlob -[TiUIImageView setImage_:](TiUIImageView.m:687)

Sorry, what? It seems like something odd is happening at a native level, and Titanium is getting too confused to return a sensible error message. Well, guess it’s time to open a support ticket with Appcelerator and wait for them to figure out what the issue could be, right?

Wrong. One of my favorite things about Appcelerator Titanium is its open-source nature. What we can do from here, is open up the native project generated by Titanium and debug it with the normal native debugging tools. When you build a Titanium application for iOS, a (pretty much) normal XCode project is generated from your project, compiled, and run on whatever test device you have selected. In situations like this, we can take that project and manually re-build it in XCode for debugging purposes.

Opening your project in XCode

To open your project in XCode, first run

ti build -p ios --build-only

in your project’s directory. This will ensure you have a native project generated for your Titanium project. From here, all you need to do is open XCode, and open up the XCode project in the build/iphone folder.

Path to a Titanium project's compiled XCode Project

Setting Native Breakpoints

Now that we’ve got the project in XCode, we need to set up a native breakpoint so that we can see what the issue is with the Objective-C code that Titanium is executing on our behalf. Fortunately, the message that Titanium printed out gave us a selector name:

-[TiUIImageView setImage_:]

. Let’s go ahead and set up a symbolic breakpoint for that selector:

Add a breakpoint in XCode by clicking the second icon from the right in the side bar, and then clicking the plus in the bottom right

Add the symbol from the error as the symbol name

Enter the XCode debugger

Now that we’ve got our breakpoints set up, we can run the project in XCode, and execution will stop when our breakpoint is hit in the Titanium SDK code.

The debugger will automatically pause execution when you hit a breakpoint.

Let’s go ahead and step over a few commands and see if we can figure out exactly what’s going wrong.

Step Over

Huh, it looks like we’re having some issue turning our Titanium file into a UIImage that we can apply to the native UIImageView. Let’s use the variable inspector to figure out exactly why we’re failing to convert this into an iOS image.

XCode variable inspection

Well, one look at the MIME type is enough to see exactly what’s wrong. Our file isn’t an image! Even though this didn’t tell us exactly where the issue was, it was enough to direct our debugging (we eventually figured out that we were accidentally saving a PDF file as an image – oops!). Issues like this are why I’m very quick to reach for XCode when I see a native iOS issue – it makes it much easier to figure out what parts of your code might be incorrect when you can easily trace through Appcelerator’s code!

iPad or Surface to rule the enterprise? You make the call.

iPad or Surface to rule the enterprise? You make the call.

On the heels of a major upgrade to their mobile software, Apple recently unveiled their newest version of the world’s the most popular tablet.  The new “iPad Air” is a thinner, more powerful version of the company’s flagship device.  But will the combination of the sleek new operating system and more eye-appealing tablet translate to the enterprise as the new go-to tech for the workers on the factory floor to the board room?

Gartner analyst Mikako Kitagawa recently said that demand for PCs has declined. So does that mean that Apple, Windows and Android based tablet devices are replacing PCs as work devices?

One of the tell-tale signs of health of the PC industry, the back-to-school surge, was actually the worst single period for new PC sales since the global economic collapse of 2008.  While Kitagawa expects the PC sale slump to level out in the United States, tablets and Android devices in particular are seeing a big jump.

“Consumers’ shift from PCs to tablets for daily content consumption continued to decrease the installed base of PCs both in mature as well as in emerging markets,” Kitagawa stated.  “A greater availability of inexpensive Android tablets attracted first-time consumers in emerging markets, and as supplementary devices in mature markets.”

While Android’s price point might appeal to new consumer entrants to the space, what about at corporations?  Reuters reports the real showdown for enterprise should come between Apple and Microsoft.  Carolina Milanesi, another Gartner analyst — who is a little more frank about the competitive benefits of devices — said that “the iPad Air will compete with Surface Pro.  Not some rinky-dink Android tablet.”

We wrote last month that Apple’s iOS7 made technological advances that will resonate with the enterprise, specifically around security.  Interestingly, security might not be a determiner at least among upper management and might have more to do with ego.  Many analysts believe that the iPad will remain the preeminent product among those in upper management.

“They [senior executives] will continue to prefer the Apple devices over their competitors; even over the Microsoft Surface 2 devices that have been released recently,” Forrester analyst Tim Sheedy told Computer World.

“There are some IT shops looking at the Microsoft devices and thinking ‘these might be a nice IT-friendly device’. However, the reality is when looking at these new tablets, the lightweight iPad Air, you are going to see senior people in the organisation continue to bring these into businesses and ask or demand for them to be supported by the IT department.

“I don’t see shift to Microsoft Surface replacing the iPad, particularly at the executive level.”

But there are only so many executives in the enterprise and the power of mobile devices at the front line stands to make a more profound impact on the business.  So when considering moving away from PCs to extend the tablet within the enterprise at the factory floor level, Microsoft might be the more attractive option for CIOs when it comes to their staff.  The old do as I say, not as I do trope might apply here.   Matthew Oakeley, global IT head of Schroders, told Computer Weekly in an interview that he does not think the iPad will ever be a true corporate device throughout the enterprise.

“I bet a lot of people bought iPads for work but don’t use them for work,” he says.

“The real problem is that, if you run a Microsoft Windows estate, you want something that can talk to it.

“At an event I asked Steve Ballmer: ‘When are you going to solve the iPad problem? When are you going to make it that the iPad can talk natively to Microsoft?’

“And he said, ‘Probably never; we are not friends.’”


Microsoft has made an empire on strategic plays like the one Ballmer is said to have outlined for Oakeley above.  Because Microsoft software is so firmly entrenched in the enterprise space, there’s no reason for them to leave their high ground by creating iOS connection points.  Surface devices are quietly helping Microsoft hedge their bets against Apple’s dynamic and attractive product explosion of the last ten years.  Still Apple’s growth has been largely consumer driven and doesn’t have the history of twenty years of software developments tailored to enterprise that Microsoft offers.

So who will rule the enterprise? As Microsoft VP Frank Shaw demonstrated, both sides have valid arguments for why their tools should be the standard, but in the end it is going to be a matter of perspective.  Hopefully, an organization will look at what set of functions matter most and will work best for their corporate culture.  Both sets of products have their merits and knowing one own’s unique organizational needs will be the key to making what might be a better/best decision for an organization.

Those are the decisions that we at Shockoe help our customers to determine every day.

How can we help you with your plans for a mobile enterprise?

Shockoe and Shaka Smart Basketball Camps Team Up

Shockoe and Shaka Smart Basketball Camps Team Up

Any young organization that experiences explosive growth invariably runs into many of the same problems. Building a scalable infrastructure while offering the best customer service are two challenges that faced Shaka Smart Basketball Camps, LLC as they strive to provide the best basketball experience for its campers and parents each summer since 2009 in Richmond, Virginia.

Smart is the head coach of the surging Virginia Commonwealth basketball program, the college basketball Cinderella story of 2011 and the success of his program has driven greater attendance to his summer camps in the Central Virginia region. With the added campers came scalability concerns for the staff in 2011 and 2012 and with more campers in store for 2013, the team had to huddle to come up with a winning result.

The mission of the basketball camp is to “encourage self-esteem and a love of fitness and nutrition” through a fun and informative week-long camp. As part of that mission, the camp’s curriculum teaches its attendees lessons about practical financial responsibility through a camp “bank account” that the children can use to purchase items from one of a number of the camp’s stores.

For Shaka’s staff, registering each camper, tracking who was in attendance each day and the unique challenge of monitoring the balances of each camper’s “bank account” across a five day basketball camp presented problems. Keeping up with the swelling number of campers over the past few years with a paper process found difficult and time consuming.

After last year’s camp, the staff needed a better way to supply right-time account balances, perform inventory control, provide updated balances to the staffers at the camp store and then offer reports for parents to reinforce the camp’s lessons of fiscal responsibility. To accomplish this, Shaka Smart Basketball Camps teamed with us at Shockoe Mobile Application Development to come up with a solution for the staff. To meet the team’s needs, we created a back-end database built to automate inventory control, track camper attendance, and track camper account balances all while providing an intuitive front-end display on iPads for camp staff to quickly learn and efficiently access the system. The devices were then integrated with Square payment software to make payments as simple and accessible as possible.

Last week was the camp’s first of three weeks and was the first real test of how smooth and scalable the application could be for the staff. So how did it work?

With the new application, registration went more quickly, attendance was efficiently tracked and there were no discrepancies in balances at the various camp stores based around the location of the camp, Virginia Commonwealth University’s Siegel Center. Reports were then provided back to parents on how their children spent their allowances during camp for additional reinforcement of sound financial management.

With the new application in-hand, Smart’s staff of administrators and educators were able to focus on what matters most, teaching children the fundamentals of basketball while establishing a healthy lifestyle resulting in a win-win for everyone involved.


Founded in April of 2009, the mission of Shaka Smart Basketball Camps LLC is to encourage high self-esteem and a lifelong love of fitness and nutrition through fun, high-quality basketball instruction and games. The camp provides a wealth of experiences for its attendees including both current and former Virginia Commonwealth University basketball players, youth coaches from around the nation, conditioning experts, medical staff and VCU graduate assistants from the Center for Sports Leadership. This year, the camp will run for three week long sessions providing instruction and learning to hundreds of campers. Learn more about the camp at


Beginner’s Titanium: Titanium DisplayCaps on iOS

There are now a multitude of device resolutions and densities running iOS, how can you make sure your content appears how you want it to appear regardless of which device your users have? This is, of course, one of the trickier areas for mobile applications. Fortunately, Titanium Studio has tools to help us attack this problem. Initially I thought that the DisplayCaps properties I could access through the Titanium API would produce the exact pixel dimensions of the device my App was running on. Upon a more careful inspection of the Titanium documentation these properties will produce values of “density-independent pixels (dip) on iOS”. I went ahead and ran a few tests on the simulator to determine what values I would receive on each device:

[cc]“height: ” + Ti.Platform.displayCaps.platformHeight);“width: ” + Ti.Platform.displayCaps.platformWidth);

iPad (non-retina): height: 1024 width: 768
iPad (retina): height: 1024 width: 768
iPhone (non-retina): height: 480 width: 320
iPhone (3.5 inch retina): height: 480 width: 320
iPhone (4 inch retina): height: 568 width: 320

Also keep in mind that the values are relative the the orientation of the UI (not necessarily the physical orientation of the device). Another useful property of Ti.Platform is the dpi property which can provide useful information about whether the device has a retina display or not. This information helped clear up some issues for me and enabled me to better plan layouts for multiple devices, I hope the information was helpful for your App Development as well!