They say it’s your birthday…

No technology related news or views today, just wanted to wish Joe Bonamassa a Happy 40th Birthday!

Watch out for #ifdef TARGET_IPHONE_SIMULATOR

I just wanted to take a moment before the sands of time in the April hourglass run out for a friendly reminder for those iOS developers who are working in older Objective-C code bases. Watch out for #ifdef TARGET_IPHONE_SIMULATOR, as at some point, a newer version of the iOS SDK broke this check. In the current TargetConditionals.h file, TARGET_IPHONE_SIMULATOR resolves to either a 0 or a 1 (eventually, see below), which means that no matter where you run the code, TARGET_IPHONE_SIMULATOR will be defined, hence the code inside the #ifdef will always run.

The solution is of course to use the following line instead:


Keep in mind that TARGET_IPHONE_SIMULATOR itself is marked as deprecated in the iOS 10 SDK TargetConditionals.h file, so I suppose to be future-proof, you should instead use:


BTW, Happy Honesty Day to my U.S. readers. All you need to know about Honesty Day is that I think it is one of the best days on the calendar.

macOS VPN adventures

I use a VPN to connect for work, and have been having some macOS VPN adventures with my MacBook Pro. Mostly my problem was that, on occasion, the internet connectivity would not work, as I could connect to the VPN just fine, but any internet requests would just return with a failure.

The way I found to work around this issue was to go into the advanced settings for the VPN and hard code the DNS server of in there. After doing that, it seemed to work much more solidly.

As a bonus tip, if you happen to use VMware Fusion on your Mac to run a Windows VM, I would also recommend going into the network adapter settings for your VM (all of them if you have more than one) by launching your VM and selecting Settings from the Virtual Machine menu, and select the Internet Sharing “Share with my Mac” setting instead of going directly to your Wi-Fi or Autodetect under Bridged Networking, or otherwise your VM will not communicate through the VPN you have running on your Mac at the same time.

Find the bundle ID of an app in the App Store

Have you ever had to find the bundle ID of an app in the App Store? Well if you have, there does not seem to be a direct way to do it, so here is how I found the information.

First, use the iTunes Link Maker to search for iOS apps, find the app you need to discover the bundle ID for, and click on it. This will pull up a screen with an embed code link, find the numeric ID code.

Then, visit this URL, replacing the X’s with the numeric ID you just found:

After you plug in your numeric ID, the Apple site should spit back a JSON file in response, look for the bundleId entry.

BTW, I am a day late, but Happy 40th Anniversary to Slap Shot, one of the finest cinematic masterpieces of all time.

Eliminate noise from the iOS Simulator console

If you find that you are getting a lot more stuff showing up on the console when debugging your app in the Simulator, you are not alone. Luckily, there is a way to eliminate noise from the iOS Simulator console output.

To do this, go into the scheme editor for your target, select the Run Debug option on the left, select the Arguments tab on the right, and under Environment Variables, click the + button to add a new one called OS_ACTIVITY_MODE, and set its value to false.

BTW, a posthumous Happy Birthday to the King, Elvis Presley.

Advent of Code 2016

Well folks, it is the holiday season once again. That only means one thing… Advent of Code 2016 is upon us!

Once again, I have decided to do this undertaking in Swift to help me get familiar with the language and the transition from Swift 2 (that I used in last year’s exercise) to Swift 3.

It seems harder this year than last, as I am struggling to keep up. If you want to check out my lame progress, please visit:

BTW, Happy Holidays everyone!

Log all SQL statements in an Android app

If you are using SQLite as your data store in an Android app, and you want to try and trace through the SQL statements that are occurring, it can be painful, especially if you are working with a large code base that you may not be 100% familiar with.

Luckily, there is a super easy way to do this with no code changes. Once you have opened the simulator, go to the terminal and execute these commands:

adb shell setprop log.tag.SQLiteLog V
adb shell setprop log.tag.SQLiteStatements V
adb shell stop
adb shell start

Then, in the Android monitor, you will probably want to filter by SQLiteStatements to see the relevant entries.

Ignore warnings in a specific file in Xcode

If you use any 3rd party or open source code in your iOS or macOS application, you know how deflating it is to get your code all compiling with no errors or warnings, only to have your open source code spit out lots of warnings. If only there were a way to ignore warnings in a specific file in Xcode…

Well as it turns out, you can go into the Build Phases section in your target’s settings, find the file or files you want to disable warnings for, double click on the Compiler Flags, and add in the following entry:

-w -Xanalyzer -analyzer-disable-all-checks

This entry will have the additional benefit of also disabling the Clang static code analysis warning messages for the files, which can be just as annoying as the warnings.

BTW, Happy 60th Birthday to the Wizard, Jordan Rudess of Dream Theater. Jennifer and I saw them here in Columbus tonight as they performed The Astonishing live, and the show was great.


I have a lot more projects that I am working on at my new gig, and as such, I am always looking for my METHOD_LOG definition. It is a quick define that I put in my Objective-C code so that I can log what class and method I am in, without having to type out a description of the class and method into an NSLog statement.

So here is the code for METHOD_LOG, along with a DebugLog define that I use quite often instead of NSLog:

#if defined(DEBUG)
    #define METHOD_LOG (NSLog(@"METHOD_LOG: %@ %s", NSStringFromSelector(_cmd), __FILE__))
    #define DebugLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
    #define METHOD_LOG
    #define DebugLog(...)

BTW, Happy International Caps Lock Day.

View the Android activity stack

Have you ever been developing an Android app, and wanted to find out what activity you were looking at on the screen without spelunking through mountains of source code? Well luckily, there is a quick way to view the Android activity stack.

(Please note that these instructions are for use on a Mac. The corresponding Windows way of doing things is undoubtedly similar.)

If you have ADB installed and running on the command line, then go into Terminal and enter the following command:

adb shell dumpsys activity | grep -i run

Upon doing this, you should see a listing that looks something like this:

mbp:~ user$ adb shell dumpsys activity | grep -i run
    Running activities (most recent first):
        Run #5: ActivityRecord{3d31e5ec u0 com.yourcompany.yourapp/.ui.CustomerDetailActivity t211}
        Run #4: ActivityRecord{18b02af2 u0 com.yourcompany.yourapp/.ui.CustomerListActivity t211}
        Run #3: ActivityRecord{517ab43 u0 t180}
        Run #2: ActivityRecord{2e389c3c u0 t179}
        Run #1: ActivityRecord{8583e3d u0 t153}
        Run #0: ActivityRecord{14e94b15 u0 t153}
(more stuff after, not important)

If you look at the top of that list, you will see that the CustomerDetailActivity class is at the top of the activity stack.

Keep in mind that you may need to get ADB set up on your Mac, the easiest way is to install the tools through brew, and here are the Terminal commands necessary to do this:

1. Install homebrew:

ruby -e "$(curl -fsSL"

2. Install ADB:

brew install android-platform-tools

3. Test ADB:

adb devices

That last command above will just verify that you have a device hooked into your computer. This also appears to work with the Android emulator provided by Android Studio, but if you are using Genymotion, it should work fine with that one as well.

BTW, Happy 50th Birthday to Star Trek, which debuted on American television on this date way back in 1966.

P.S. Credit where credit is due: View activity stack in Android – Stack Overflow and Installing ADB on MAC OS X – Stack Overflow were obviously key.