"Could not find the main bundle or the Info.plist is missing a CFBundleIdentifier"

I'm trying to upload my MacOS app to Appstore via command line, and after solving some signing and certificates issues, I'm a bit stuck on package validation.

After exporting the archive to a .pkg file, I run the following command:

xcrun altool --validate-app -f ${filename}.pkg -t macOS -u $username -p $password --output-format json

And then I get a message with this feedback:

Could not find the main bundle or the Info.plist is missing a CFBundleIdentifier in ‘MyApp.pkg’.

The problem is my Info.plist looks valid, and it does have a CFBundleIdentifier key. Besides that, uploading to Appstore through Xcode organizer works fine, so I don't really know what I'm missing here.

So, I have the following doubts:

  • Am I in the right direction to upload the app to the store via command line?
  • Do I really needs this --validate-app step?
  • Is it correct to try to validate a pkg file?

Please let me know if there is more information I could give.

Any help would be appreciated.

Accepted Reply

After reaching to this answer on StackOverflow I could figure out what was happening. The problem was in xcodebuild -exportArchive command, where an exportPath is required. I was passing the whole package name to this argument, like this:

xcodebuild -exportArchive [...] -exportPath mypackage.pkg

That would create a folder named mypackage.pkg and then export the actual .pkg inside of it. So in the next command where I validate the app, I was actually validating the folder that contains the package, not the package itself.

Finally, to solve the problem I replaced the command above by the following:

xcodebuild -exportArchive [...] -exportPath .

  • Oh, wow, that's wacky. Thanks for closing the loop.

Add a Comment

Replies

Am I in the right direction to upload the app to the store via command line?

Yes.

Do I really needs this --validate-app step?

Not absolutely, but it’s a good idea. You can go straight to the upload step (--upload-package) but the result may be an upload that’s not usable. The validate step allows you to debug these issue locally.

Is it correct to try to validate a pkg file?

Yes.

I’m not sure why you’re installer package is having problems. Let’s start with a simple question: If you validate the package from the Xcode organiser, does that work?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Yes, through the Xcode organiser it works fine. But I actually found the problem. Gonna post the solution here.

Add a Comment

After reaching to this answer on StackOverflow I could figure out what was happening. The problem was in xcodebuild -exportArchive command, where an exportPath is required. I was passing the whole package name to this argument, like this:

xcodebuild -exportArchive [...] -exportPath mypackage.pkg

That would create a folder named mypackage.pkg and then export the actual .pkg inside of it. So in the next command where I validate the app, I was actually validating the folder that contains the package, not the package itself.

Finally, to solve the problem I replaced the command above by the following:

xcodebuild -exportArchive [...] -exportPath .

  • Oh, wow, that's wacky. Thanks for closing the loop.

Add a Comment