Posts Tagged Software_Development

IDE Feature Wish List – Comments in Project File

More things for the IDE (Integrated Development Environment).  Xcode is the one I use for iPhone development,  so hint, hint Apple.

Provide space to comment settings provided to the compiler by the IDE.

We can specify compiler macros and such in lots of IDEs. One example is a preprocessor flag named “DEBUG”.  Yet there may be definitions for preprocessor macros that do not explain themselves.  A deliberately bad example may be  “MAKEOBSCUREOPERATIONSALLOWED”.

If there is a place in your work where you as “why did someone do that?” then you have a need for more information.  And that information should travel with the thing it describes, not in some separate file where it may be lost (or never found).

If there is a slot to make a decision (especially a decision for another file), then there needs to be a slot to record the reason for the decision.

Tags: ,

Finding Xcode’s Pre-defined Macros for iOS Devices

I regret not making better notes about exactly why I was looking for a full list of the pre-defined macros Apple made available for iOS development.  I usually like starting an entry talking about why I was trying to solve a particular problem.  While I made a note to write up what I found, I did not note why I needed it at the time.  Assuming you are reading this because you need or might need such a thing, I’ll write on.

Some of the pre-defined macros are published in Apple’s documentation, but not all.  (Well, as far as I remember anyway.)  I feel the most confident that I didn’t miss one that could solve a problem when I get the list from the compiler itself.

While searching the internet I found instructions to use

I changed ‘i386’ to ‘armv6’ and ‘armv7’ but that failed on my setup.  I don’t really know if I messed something up in the /Developer folder or if this line just generally won’t work for ARM.

The error message mentioned a missing file and after finding it, I changed the above command to this:

For Xcode 3.2.5:

For Xcode 4.2.1

Change the “armv6” to “armv7” and vice-versa as needed.

Tags: , , , , ,

Fix to Symbolicate System Symbols in iOS 5.0.1 (9A405) Crash Logs

I found this one many weeks back and had it in my to-do list for the blog.  Now that 5.1 is out, I feel guilty I didn’t write it up sooner.  But then, my day job is keeping me very busy.

I had a long period where I could not fully symbolicate crash logs that were made by iOS 5.0.1 devices.  The symbols of my app would be symbolicated, but the system symbols of the device would not.  I was especially frustrated because a coworker with the exact same version of XCode could symbolicate those system symbols with no problem.  Neither of us knew why.

After a huge amount of searching with Google and reading items on StackOverflow.com,  I finally found a note saying the symbols in the iPhone 4S were corrupted somehow and they should be replaced with symbols from another device.  I don’t know if there was a problem with all the iPhone 4S devices, or just some of them or just early ones.

As much as I tried to do this,  I still could not symbolicate properly.  I triple-searched my computer for all copies of symbols for 5.0.1 (9A405) and removed them.  (You can compress them into .zip files if you want to keep them just in case.)

What I needed to know was to look in ~/Library/Developer/Xcode/iOS DeviceSupport   Xcode 4.2 had been putting device symbol information in there.  Once I got rid of that folder, and attached a device, XCode pulled a new copy of the symbols and symbolication worked like a charm.

Top top it all off,  something about the symbolication script in XCode 4.2 works better than any of the previous symbolication scripts, either from Apple or from any developer site.  While symbolication inside XCode can be horribly slow, it does work pretty well.

Hope that helps

Tags: , ,

Solid Code: Mixing Objective-C and C++

If you’ve noticed that there’s been a long time between this post and the previous one,  you are right. My day job has been keeping me busy.  But that’s why I can get on with the topic: mixing legacy C++ with Objective-C.

After trying things a few ways,  I’m finding that one basic assumption difference between the languages can trip you up: the assumption about calling a method or function with an object pointer to zero (a.k.a. nil or null or NULL).

Since the C++ will generally be legacy code,  its natural for Objective-C objects to wind up containing pointers to C++ objects.  After that, its pretty easy to wind up calling C++ functions almost directly from accessors like:

This is functional,  but from a solid-coding standpoint,  it is too bug-prone and too hard to debug.  If the above statement crashes, which part of it failed?

Objective-C assumes that calling member methods with nil object pointers is OK.    (i.e., a nil ‘self’ pointer is not an error.)  Any such attempt just automatically returns zero.

C++ however, assumes that member functions will never be called against a NULL pointer.  (i.e., a NULL ‘this’ pointer.)  Any such attempt will probably crash an iPhone with EXC_BAD_ACCESS.

My point here is you should put the pointer into a variable, then call the function from that variable:

Now the language assumptions are clearly separated.  Nil pointers in the first line can be safely assumed to have zero method results. And the C++ in the second line can be more easily debugged if it fails.  (And we can easily check our C++ pointer for NULL before calling its function.)

The crash from the C++ code will most likely happen when the member function tries to dereference a member variable.  An instance’s member variable is held at an offset from the pointer, so if the pointer is zero, the member equates to an address that is near zero.  Addresses near zero are invalid on the iOS.

So there you go,  if you have to mix Objective-C and C++,  avoid mixing them on the same line.

Tags: , , , ,

XCode 4 – Stopping in the Debugger on NSAssert

I’m not sure if XCode 4 makes this technique unnecessary. Since I originally wrote this, I’ve seen XCode 4.0.2 stop at NSAssert on its own, without me setting this breakpoint. But it may be helpful to someone somehow. So here it is:

Xcode 3: Run Menu -> “Manage Breakpoints”
XCode 4: Go to the breakpoint navigator.

Click the + button at the bottom of the navigator, select “Add Symbolic Breakpoint…” from the contextual menu that appears.

In the “Symbol” box, enter

Then click “Done”. (NOTE: this is the default assertion handler. If you are using a custom assertion handler, you probably need to specify a symbol for its object and method.)


Now execution will break immediately on assertion failure. And very usefully, XCode shows the nearest source code of the stack, not the assembly of the assertion handler.

Tags: ,

XCode Problem “expected specifier-qualifier-list before

Solution:  check that you included appropriate frameworks in your project and target.

I had this just now while building a new project and forgot to put the frameworks into the project.

Tags: ,

XCode Giving Incorrect Error Messages after Upgrade to 3.2.2

A few days ago,  I was helping upgrade a Mac’s XCode environment from 3.1.4.   After the upgrade, the first attempt to build and run a project resulted in strange errors.  “Security Policy Violation”  came back from the device along with problems with the entitlements.

After much poking and prodding, I noticed that the Base SDK for the project was set to “iPhone OS 2.0 (missing)”.  The base SDK for the project was no longer available in XCode after the 3.2.2 upgrade.

Resetting the BaseSDK to 3.0 solved the issues and the build and run was fine.

Tags: , ,

iPhone Pattern: The ID Device?

I’ve seen stories lately that make me think another app pattern is emerging: iPhone as an ID. (Not news to you? Gotta love intelligent readers.)

It does make some sense.  In cases where serious identification is not crucial, the iPhone can be used.  With a full iPhone, you can bet people don’t just loan them out to people indiscriminately.   On days when I’ve forgotten my wallet, I still didn’t forget my iPhone.

Think about these:

  • Companies are sending account information, such as passwords or password reset info to the mobile phone recorded in the account.
  • RSA has a “SecurID” app for the iPhone.  Its used just like the cards and keychain dongles that give a code number once a minute.  That’s 2-factor authorization.
  • iPhone and iPhone apps are being used to pay for physical goods and services. A hotel reportedly issues iPod Touches to guests.  The guests uses them to order food and drinks by the pool and pay on the room account.  (They give the devices back at checkout time.)
  • Apps are used to exchange contact information.

Tags: , , , ,

Mysterious iPhone status bar icon?

Last night I was attending the iPhone SIG of the Florida Macintosh Users Group (FLMUG).

One of the members was asking about an icon in his status bar he couldn’t identify.  It looked like a landline telephone’s receiver with a keyboard underneath.  We scratched our heads for a minute until Phil said “wait, that’s gotta be the TTY setting”.  He quickly looked in Settings under “Phone” and yes, the TTY setting was on.  The icon went away when the setting was turned off.

Kudos to Phil for deducing the answer based on the “phone” and “keyboard” clues.

So today, I had to go lookup the other icons which may be displayed, just in case. 🙂  They are listed by Apple as “status icons” here: http://support.apple.com/kb/HT1558

Walt

Tags: ,

iPhone App Approval Took 12 Days

I got my first iPhone app,  ChronoGami, approved for download on the App Store.  And, the approval process did take 12 days from submission to approval.

There’s a lot more to the story than that of course.  I have worked on apps for other people that have shipped out through the App Store before ChronoGami.  But I began work on ChronoGami before I worked on those, so I still think of it as my first app.  I use it myself to track time on various bits of work and my life.   (I’ve got several upgrades to deliver when I finish testing already.)  I intend to be using ChronoGami exclusively for this in the near future. Adjusting to the iPhone keyboard still proves to be a challenge for note-taking.

An ironic part of the story that makes me laugh:  I checked the status of ChronoGami just before leaving for an interview to talk about possible Mac and iPhone work.  Late in the interview, during a break, I got online and checked again.  It had been approved!  Now I had one more point to talk about in the rest of the interview.  🙂

Tags: ,