Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode - failing to validate archive due to weird issues with resolving variables/placeholders in info.plist and entitlements

Something is really broken with my project or Xcode and I'm struggling since two days to figure out what is going on.

My application is running perfectly fine, it is an OS X application and it contains a Today Widget extension. I finalized the project recently and now I'm unable to publish the app due to validation errors.

It started with the validator complaining about my Application Group, which I use to share content between the main application and the Widget extension. The group was defined as $(TeamIdentifierPrefix)com.acme.GreatApp.

The validator was complaining that my Group name was in the wrong format and should rather start with my TEAMID. After 3 hours of running in circles I replaced the placeholder $(TeamIdentifierPrefix) with my team ID (e.g. S3F45A5S35.) – and that worked.

Then the validator complained about every kind of other placeholder in my info.plist and entitlements files, things like $(PRODUCT_NAME), com.acme.GreatApp.$(PRODUCT_NAME:rfc1034identifier) and $(EXECUTABLE_NAME). I replaced all those placeholders with their corresponding values, which then was accepted.

Then, for a while the validator complained about structural issues, which do not make too much sense to me:

iTunes Store operation failed. Bad CFBundleExecutable. Cannot find executable file that matches the value of CFBundleExecutable in the nested bundle GreatAppWidget [com.acme.GreatApp.pkg/Payload/GreatApp.app/Contents] property list file


iTunes Store operation failed. Bad bundle identifier. The bundle identifier 'com.acme.GreatApp.GreatAppWidget' of the application extension GreatApp.app/Contents/Plugins/GreatAppWidget.appex should extend the dotted path of the bundle identifier of its containing application (com.acme.GreatApp.GreatAppWidget)

Are you telling me my extension is contained in my extension?


iTunes Store operation failed. Invalid bundle location. Bundle GreatApp.app/Contents/Plugins/GreatAppWidget.appex must be contained in parent bundle's Contents/Plugins directory.

Well, the error states that I should do what it claims is not correct. Obviously it IS in the parent apps folder Contents/Plugins. So what?


iTunes Store operation failed. The CFBundleExecutable of two bundles may not point to the same file. The following shared bundle path have been found: GreatApp.app/Contents.


The thing is, my app and extension work perfectly fine. If there was anything broken like dependencies, paths or whatever, something most likely wouldn't work, no?

Furthermore, I did not modify any of the build settings or just anything which I do not understand. These are all the default settings. I created a new Cocoa application, added a new Today Widget Extension as target - and that is it. I did not mess around with any paths, locations, dependencies, anything.

Anyway, those errors were only visible for a while and I'm lucky I made a screenshot then. Because now, again it is showing raw placeholders in the error messages, even though I didn't change a thing that could cause that. The only thing I can recall I did was to delete/revoke all provisioning profiles and certificates locally on disk, in the Keychain, and in the Member Center and created everything from scratch through Xcode.

Now the errors look like this:

iTunes Store operation failed. Bad CFBundleExecutable. Cannot find executable file that matches the value of CFBundleExecutable in the nested bundle ${bundleName} [${bundlePath}] property list file


iTunes Store operation failed. Bad bundle identifier. The bundle identifier '${bundleIdentifier}' of the application extension ${bundlePath} should extend the dotted path of the bundle identifier of its containing application (${parentBundleIdentifier})


iTunes Store operation failed. Invalid bundle location. Bundle ${bundlePath} must be contained in parent bundle's ${pluginsSubPath} directory.


iTunes Store operation failed. The CFBundleExecutable of two bundles may not point to the same file. The following shared bundle path have been found: ${sharedBundlePath}.


So I thought maybe Apple just fuped it in the recent update and you just can't validate an app with extension. So I searched the web and found the really nice example Today-Scripts. I added app groups ($(TeamIdentifierPrefix)com.acme.Today-Scripts, the placeholder here perfectly works) to all targets, activated sandboxing, changed certs and provisioning profiles: And it perfectly validates!

So I compared all the build setting etc. And except that I had to replace the placeholders with their actual values, obviously the certs and profiles and the fact that in Today-Scripts there is an additional XPC target which is embedded into the Widget, they are atomically the same. Every single setting is the same.

I cleared all caches, really hard. Cleaned the project, cleared ~/Library/Developer/Xcode/DerivedData as well as ~/Library/Caches/com.apple.dt.Xcode, restarted several times, nothing helps.

I'm really desperate as I have no idea left what I can do. Please someone shed some light on what the heck Xcode is doing here and why.

  1. What causes Xcode to fail to interpret all the placeholders in the info.plist and entitlements files?
  2. How can these bundle errors above happen when I am working with
    • the exact settings XCode created by creating new cocoa app and adding an extension target?
    • the exact same settings/dependencies as the Today-Scripts example?
like image 663
udondan Avatar asked Feb 25 '15 03:02

udondan


3 Answers

I finally found the culprit! The problem was, for some reason I can not explain, the info.plist of the extension was a member (Target Membership) of the main application. I just found that by analyzing the created archive file by file and found an additional info.plist inside the GreatApp.app/Contents/Resources folder. In that file the placeholders were not resolved. The archive validator then used this info.plist for validation.

That little checkbox cost me 3 days.

like image 141
udondan Avatar answered Nov 09 '22 14:11

udondan


I was getting

"iTunes Store operation failed. Bad CFBundleExecutable. Cannot find executable file that matches the value of CFBundleExecutable in the nested bundle ${bundleName} [${bundlePath}] property list file"

error when I try to submit my adobe air app to mac app store.

The executable is located at "/Contents/Frameworks/Adobe AIR.framework/Versions/1.0/Resources/AdobeCP15.plugin/Contents/MacOS/AdobeCP"

In info.plist file located at "/Contents/Frameworks/Adobe AIR.framework/Versions/1.0/Resources/AdobeCP15.plugin/Contents/info.plist"

it is written as

CFBundleExecutable adobecp

These files are generated automatically but it took time to discover the case-sensitivity. Therefore, I changed it into

CFBundleExecutable AdobeCP

and error message disappeared.

like image 30
Umut Demirel Avatar answered Nov 09 '22 14:11

Umut Demirel


I ended up at this post because I had a similar error, but a different cause. My issue was caused by having a WatchKit app and having the 'Embed Watch Content' Build Phase after my 'Run Script' Phase. Once I moved the 'Embed Watch Content' Build Phase in between 'Copy Bundle Resources' and 'Embed Frameworks', the validation of the WatchKit succeeded.

like image 1
Justin Domnitz Avatar answered Nov 09 '22 15:11

Justin Domnitz