Re-signing iOS apps

I am occasionally presented with a packaged iOS .ipa archive by a third-party developer, which is intended for in-house distribution (using an Apple Developer Enterprise certificate), or for App Store distribution using a different developer account.

Re-signing is a quick and simple way of delivering an app when a developer won’t provide you with their Xcode project source from which to spin your own build.

I previously used the iReSign utility to accomplish this, but found that this wouldn’t work in all cases, in particular when the app includes linked frameworks or libraries (which results in errors such as “DYLD, Library not loaded“).

To solve this I wrote the shell script below. It takes an existing .ipa archive, embeds your own developer provisioning profile, replaces any existing code signatures and packages it again for distribution.

Please use with my compliments and leave a comment if this helps you out.

(Note: This script has a dependency on command line tools such as PlistBuddy and codesign, so you will likely need to install Apple’s Xcode developer tools)

Replace DEVCERT with the Common Name of your own Apple developer certificate.

#!/bin/bash
# Re-sign an IPA with specified developer certificate (present in keychain)

DEVCERT="iPhone Distribution: Your Developer Cert Name"
TMPDIR="tmpwork"
SOURCEIPA="$1"
MOBILEPROV="$2"
BUNDLEID="$3"

if [ $# -eq 0 ]

then
  echo "Usage: $0 [app.ipa] [provprofile] [bundleid]"
else
  if [ ! -e "$SOURCEIPA" ]
  then
    echo "Error: $SOURCEIPA not found"
    exit
  fi

  if [ ! -e "$MOBILEPROV" ]
  then
    echo "Error: $MOBILEPROV not found"
    exit
  fi

  SIGNEDAPP=`echo $SOURCEIPA | awk -F".ipa" '{ printf ("%s-signed.ipa", $1) }'`
  unzip -qo "$SOURCEIPA" -d $TMPDIR
  APP=$(ls ${TMPDIR}/Payload/)

  if [ ! -z "$BUNDLEID" ]
  then
     echo "Changing Bundle ID to ${BUNDLEID}";
     /usr/libexec/PlistBuddy -c "Set:CFBundleIdentifier $BUNDLEID" "${TMPDIR}/Payload/${APP}/Info.plist"
  fi

  cp "$MOBILEPROV" "${TMPDIR}/Payload/${APP}/embedded.mobileprovision"
  security cms -D -i "${TMPDIR}/Payload/${APP}/embedded.mobileprovision" > Entitlements_full.plist
  /usr/libexec/PlistBuddy -x -c 'Print:Entitlements' Entitlements_full.plist > Entitlements.plist
  echo "Re-signing with certificate: $DEVCERT"

  for folder in `find -d ${TMPDIR} \( -name "*.app" -or -name "*.appex" -or -name "*.framework" -or -name "*.dylib" \)`; do
    /usr/bin/codesign --continue -f -s "$DEVCERT" --entitlements "Entitlements.plist" "$folder"
  done

  echo "Package the signed IPA"
  cd $TMPDIR
  zip -qry ../${SIGNEDAPP} *
  cd ..
  rm -rf $TMPDIR
  rm Entitlements_full.plist

fi

What Innovation?

Apple reinvents the phone

I was having a discussion with an old friend who declared that there has been no innovation in mobile devices for years now. I immediately took exception to this claim and set my mind to disproving his assertion.

There is no disputing that Apple “reinvented the phone” in 2007 when they launched the original iPhone to an expectant world. I’ll never forget the looks of joy and amazement when I first demonstrated the iPhone’s touch screen interface and clever pinch and zoom gestures.

Let’s not forget how tired and utilitarian other ‘smart’ phones of the time were!

2007 Smartphones

Apple’s early dominance in the smartphone market has been successfully challenged by Google’s Android operating system and the countless slab clones churned out by Far Eastern manufacturers, but do any of them truly innovate?

What have we seen in mobile phone design in the last six years which could be considered innovative? We’ve had different form factors, sizes, colours and storage capacities, but the fundamental iPhone design concept has hardly changed.

Certainly display technology has improved, with more vibrant colours and pixel densities higher than the human eye can distinguish, but that’s evolution not innovation.

Processor power has increased, the latest smartphones boasting quad-core CPUs with dazzling performance, but this is standard Moore’s Law territory.

Camera technology has gradually improved, with manufacturers attempting to out-gun each other in the megapixel arms race. Fundamentally though it’s still a digital camera on a phone.

Mobile apps are the emperor’s new clothes, but this is just a trendy new name for what we used to call ‘computer programs’ or software.

A few new features have appeared like voice recognition, Near Field Communication (NFC) and wireless inductive charging, but these technologies have been around for years and are just being retro-fitted to mobile devices.

The sad truth though is that there hasn’t been any innovation since the original iPhone. Yes there have been gimmicks and incremental improvements, but the iPhone’s simple touch screen design and user interface has remained largely unchanged and unbettered.

Unless Apple regains the ability to surprise and delight with the unveiling of their 7th generation iPhone later on today, I’ll have to concede that my friend is right.

Please don’t leave us in 2007.

Macworld 2007 Teaser

iPhone 5

An industry insider told me that sales of Samsung’s Galaxy S III sky-rocketed the day after Apple’s big reveal of the iPhone 5. Evidently potential customers were holding off their upgrades until they had seen the new product, but what they saw disappointed.

I probably shouldn’t be admitting this, but I have already used the iPhone 5 and I was underwhelmed too. iPhone has become the safe (even boring?) option, something you would confidently give to your Mum and Dad. Apple’s runaway success has become the de facto smartphone, but the commercial imperative not to alienate their mainstream customer base has stifled innovation.

The original popularity of iOS (then iPhone OS) was due to its perfect blend of technology, form and function. Often it wasn’t possible to customise something to your liking, but that was by design and the intention was to keep things deliberately simple.

I look at iOS 6 and wonder where Steve Jobs’ painstaking obsession with simplicity has gone. I never expected CEO Tim Cook to share the same ethos, but since Jobs had apparently described Sir Jonathan Ive as being his “spiritual partner” there was a hope that he would carry forward Jobs’ legacy. It’s likely however that Ive’s control only extends as far as the hardware design, not the operating system, which is the responsibility of Scott Forstall.

Watching the official iPhone 5 promo video, it’s hard not to be impressed by Apple’s manufacturing techniques and the obvious attention that has gone into the hardware design (like crystalline diamond-cut chamfers!), but it doesn’t detract from the hard truth that to the average customer the new iPhone just doesn’t seem all that different.

With each new iPhone Apple usually succeeds in generating enough excitement and desire to persuade existing customers to follow the natural upgrade path, but they also lose some customers to Android – and they rarely return. I don’t know anyone (including myself) who has switched to Android and then gone back to an iPhone. Once you’ve broken away from the closed iPhone ecosystem it feels quite liberating to have the freedom of open services and a wide range of devices.

Conversely with each evolution of the Android platform the gap has been closing and arguably the Android 4.1 ‘Jellybean’ release has leapfrogged iOS by delivering a simple intuitive user interface and powerful features – much like the original iOS.

Samsung are seizing the opportunity to capitalise on the apathy surrounding iPhone 5 with a marketing campaign directly comparing their two flagship products:

Apple fanbois have responded with their own parody advert, but when the best they have to brag about is ‘fits all pockets’ and ‘elastic bounce back’ (the subject of Apple’s recent patent dispute with Samsung), it doesn’t bode well.

It’s certainly not all doom and gloom for Apple. They will of course sell iPhone 5 by the millions, but the shine is starting to fade.

I do have an answer to their predicament. Apple needs another product with which to dazzle and showcase their technical excellence and suppressed innovation.

Dear Tim, how about you add a new model to the iPhone range? Call it the ‘iPhone X’, pack it with enough fancy gizmos and new technology to satisfy the Android crowd and demonstrate what the biggest company in the world can really do.

LTE, 4GEE and sleeping giants

For many years Vodafone and O2 have been regarded as the heavyweights of the UK’s mobile operators, but the status quo is changing.

First to set the scene with a bit of telecomms history.

In the beginning there were two UK cellular radio operators – Vodafone and Cellnet. They operated TACS analogue radio in the 900MHz band, but this radio technology didn’t make the most efficient use of radio resources and it was open to eavesdropping. Five years later a new standard for digital cellular communications (GSM) was introduced.

Vodafone and Cellnet launched GSM networks in the 900MHz band and gradually migrated existing customers onto the new service. In 1990 the GSM standard was updated to support the 1800MHz band (then known as DCS 1800) and in 1993 two new entrants – one2one and Orange – launched GSM digital services.

The new operators were at a technical disadvantage because the higher frequency of their 1800MHz radio signals didn’t penetrate as far as 900MHz. This particularly affects in-building coverage and it meant they had to build out considerably more network infrastructure than the competition. Despite this one2one and Orange started a mobile revolution and through innovative tariffs and services they can be credited with making mobile phones accessible to the mass market.

In 2000 the UK Government raised £22.5 billion in a spectrum auction for the new 3G mobile standard operating in the 2100MHz band. Licences were won by all four existing mobile operators and Hutchison 3G became the fifth entrant to the UK mobile operator club.

Some rebranding went on at the operators, with Hutchison 3G becoming “3”, BT Cellnet becoming “O2” and one2one becoming “T-Mobile”. There was one constant however and that was the size and dominance of the original two operators, with Vodafone and O2 still sharing over 50% of the total UK market between them.

In 2010 T-Mobile and Orange merged their UK businesses to become ‘Everything Everywhere’. It was initially dismissed by some as a forced marriage of desperation, but by combining their networks under a common umbrella, with double the network capacity and vastly superior mobile coverage, a sleeping giant was born.

This brings us right up to date with the arrival of LTE. This is the latest evolution of digital mobile communications which delivers wireless speeds of up to 40Mbps, but it requires new radio spectrum in which to operate. In the UK Ofcom have reserved the 800MHz and 2600MHz bands for LTE, with another spectrum auction due to take place in 2013.

While the big two operators waited patiently for the forthcoming LTE spectrum auction, Everything Everywhere were busy plotting. They were in possession of more 1800MHz spectrum than they needed to satisfy current demand and so they made a tactical strike. They asked Ofcom to vary the terms of their licence to allow them to re-farm the 1800MHz band for use with LTE.

After a brief consultation period and despite protests from Vodafone and Telefonica (the Spanish owners of the O2 brand), Ofcom agreed to the request:

1.2 On 23 November 2011 we received an application from EE for variation of its 1800 MHz licences to enable it to provide services using LTE technology in those frequencies. The application encompasses all frequencies currently licensed to EE in the 1800MHz band, i.e. the 2×15 MHz that it undertook to divest as a result of its merger in 2010 and the 2×45 MHz it will retain.

1.8 Although we consider it likely that EE will enjoy a competitive advantage during the period before other operators are able to launch their own LTE services, we consider on the evidence available that any such advantage is unlikely to result in an enduring advantage which distorts competition to the detriment of consumers. Our assessment takes account of the impending release of additional spectrum in the 800 MHz and 2.6 GHz bands which will enable other operators to launch competing LTE services during the course of 2013. We have also taken into account EE’s obligation to divest itself of some its 1800 MHz spectrum.

1.9 In light of this assessment, and for the reasons explained in more detail in this decision, we consider that it is in the interests of consumers for us to vary EE’s licences now, in accordance with EE’s request. We have therefore today issued EE with varied 1800 MHz licences with the provisions authorising LTE and WiMAX coming into force on 11 September 2012.

It’s interesting to note that Ofcom made it explicitly clear that the ruling covered the 1800MHz spectrum which Everything Everywhere are required to relinquish.

Shortly afterwards Everything Everywhere announced their immediate plans to launch a LTE service starting in 16 major UK cities, and a week later they agreed to ‘dispose’ of a sizeable chunk of 1800MHz spectrum to 3:

As part of the commitments given when the European Commission approved the merger of Orange and T-Mobile in the UK in March 2010, Everything Everywhere was required to divest 2X15MHz of its 1800 MHz spectrum.

In accordance with these commitments, Everything Everywhere has today announced an agreement with Three to transfer this 2×15 MHz of its 1800MHz spectrum to Three. Ofcom and the European Commission will review whether the divestment satisfies the merger commitments, and a response is expected within the next three months.

This means that 3 might not be far behind in their own commercial launch of LTE in the 1800MHz band, since it does not require a separate application to Ofcom.

Vodafone and O2 were clearly on the ropes, but without a decent range of desirable handsets Everything Everywhere’s LTE rollout would only be in demand from data hungry road-warriors using mobile broadband dongles.

On September 11th Everywhere Everywhere announced their re-branding as ‘EE‘ with their 4G LTE service branded as ‘4GEE’. The following day the final piece of the jigsaw slotted into place with Apple’s public announcement of the iPhone 5.

As expected the new iPhone does indeed support LTE, but only on some frequency bands. The surprise was Apple’s choice of LTE bands for the European hardware variant, omitting support for the 800MHz and 2600MHz bands which are due to be auctioned next year. It does however support the 1800MHz band which EE are using for their 4GEE service. This has effectively handed EE a virtual exclusive on the iPhone 5.

Was this just a fortuitous coincidence for EE? The exquisite timing of EE’s new brand launch and Apple’s iPhone 5 LTE announcement was a marketeer’s dream. I have no doubt that EE and Apple have been working out this arrangement to marginalise Vodafone and O2 for quite some time. The sleeping giant has awoken!

The old guard are guilty of standing still and the tables have been turned while they were napping. There is an argument that Ofcom has not been fair in handing EE a considerable head start and commercial advantage in starting LTE without any competition, but the damage has been done and there is little to be gained from late legal challenges.

Vodafone and O2 will have to accept defeat on iPhone 5, concentrate their efforts into playing catch-up on LTE, then try and win back customers when their EE contracts expire. Whatever happens, the long established landscape of the UK’s mobile network operators has changed and once again Apple have had a hand in shaping it.

Dealing with App Store rejection

In the course of my work I’ve been submitting iOS (originally iPhone OS) apps since 2008, so I have quite some experience in this area.

Although Apple have always been diligent in manually inspecting app submissions and successful in weeding out the chaff, I get the impression that the demands of quality over quantity have gained greater emphasis in recent months.

The App Store Review Guidelines (a living document) have been tightened-up and certainly from my experience the App Review Team have been policing them with increased vigilance.

I’ve read about developers complaining that their app has been unfairly rejected, but in most cases I can sympathise with Apple’s stance. They have the expectations of a enormous customer base to fulfil and a squeaky-clean brand image to protect. If your gut instinct is that your app might be contentious, then Apple will probably think likewise.

Don’t for a minute imagine you are going to reverse their decision by engaging the App Review Board in a battle of wits. It’s Apple’s game and you must play by their rules. If they don’t like your app then they won’t publish it and no amount of picking holes in the App Store Review Guidelines is going to help your case.

Apple doesn’t respond well to legal threats or external publicity. Let’s face it, they haven’t grown to be the largest company in the world by being agreeable with everyone. They retain the best lawyers, designers and technical experts in the world and there is no benefit to be gained by arguing with them.

So enough of the ‘do nots’ and on to my advice.

Do thoroughly read Apple’s developer documentation before embarking on a new development project. The App Store Review Guidelines are actually written in an engaging and almost humorous style, so take the time to digest them fully.

If you feel that your app has been unjustly rejected or perhaps misunderstood then respond using Resolution Center. Ask for further clarifications if required and politely ask for their assistance in identifying precisely what it would take to overcome their objections. Make your responses courteous with a sprinkling of humility and you might be in with a chance.

Some developers might feel powerless going up against the 800 lb gorilla, but I have been successful in reversing some app rejection decisions by using diplomacy and a collaborative approach.

If all else fails, my expert consultancy is available – for a modest fee 😉