Search code examples
iphoneiosxcodexcode4

Why do I get "could not be added to your itunes library because it is not a valid app" error when trying to install Ad-Hoc build?


I've recently upgraded my Mac to Lion, and also Xcode 4.

In Build Settings, I've set "Code Signing" for "Release" to be "iPhone Distribution" which matches our Ad-Hoc provisioning file (which we've used in the past, on Snow Leopard/Xcode 3).

I have deleted the old Entitlements file (as it's apparently no longer used by Xcode 4).

In the Scheme section, I've set Archive to use the Release build.

I'm building with Product > Archive.

I'm saving the file by going into the Organiser and clicking Share, then making sure the same Ad-Hoc provisioning is selected.

I'm sending the resulting IPA file to my boss, who has previously installed this app. When he tries to install it, he gets the message "[appname] could not be added to your itunes library because it is not a valid app".

I've been trying every combination of settings I can think, but we just cannot get this to work. I can find this error only twice in Google - once from someone with a jailbroken phone and another posted in comments of an article, someone having the same issue, but there are no responses.

Any help would be really appreciated.

Edit: Same thing happens trying to drag the IPA into iTunes on the Mac that created it! :(

Edit2: Just taken another (almost identical) project and tried a build without "Modernizing" the project, or selected any of the new options in Xcode (icons, launch images, orientation etc.), and this build works. I'm going to work through each of the things I did with the original app with this one, testing at each step. Hopefully should be able to isolate which step is breaking the compiled app!

(also posted to Apple Dev Forums)


Solution

  • I believe I've tracked this down... It seemed to be happening really intermittently, so it's taken some time (I'd reproduce it, roll back the change, confirm it worked, then re-apply the change, for it to then work again!).

    However, after much cleaning/restart/etc., I believe it's related to the "Build" version in the target settings (there are now two version fields, "Version" and "Build"). It seems that if "Build" is blank, then this error occurs.

    Unfortunately, changing this value doesn't seem to rebuild properly, so sometimes if you change it, then Archive, you still get the previous value. Manually cleaning before Archiving seems to work around this.

    The value gets written into the plist file as CFBundleVersion.