xcodebuild: exit code 65

Note: This is from a long time ago and I haven’t really touched this stuff since around the time I wrote this. The information may be out of date. That said, if this does or doesn’t work for you, let me know and I’ll update this with the relevant info.

This is something I ran into a while back. If you’re not an iOS developer, but get tasked with building iOS apps, you may run into this. This particular exit code is fun because xcodebuild doesn’t tell you what the problem is.

Aside from building your app using the Xcode IDE, you also have the command line utility xcodebuild available to you. Assuming the code itself compiles just fine, this tool will tell you, for example, if you’re missing a provisioning profile or something.

When getting code 65, the build would fail with no explanation in the log. Rather, at the end it would say something like
<com.apple.tools.product-pkg-utility> "/Users/[me]/Library/MobileDevice/Provisioning Profiles/12345678-ABCD-1234-ABCD-1234567890AB.mobileprovision" -o "/[my_project_build_location]/embedded.mobileprovision"

In my case, it turned out xcodebuild didn’t have access to the certificate I was using.
So… here’s some things to check for:

  • Make sure you’ve installed an up to date certificate in your Keychain
  • Remove expired certificates
  • Grant access to xcode to use your certificate (or allow all programs to use the certificate)
  • Make sure you’ve installed an up to date provisioning profile
  • Remove expired provisioning profiles

4 Replies to “xcodebuild: exit code 65”

  1. Ah, it’s been a while since I wrote this and I don’t have access to a Mac these days. Let’s see if I can remember anything…

    First login with your user that will be building your iOS app. The certificate stuff is done using the Keychain Access tool. I believe to get to it you can go to Applications > Utilities > Keychain Access.

    Oh, I just found what seems to be a good resource while writing this: Using Keychain Access – Macworld.

    If you go over to the left side, there should be “My Certificates” in the left nav. Click on it to see a list of your certificates. Ones that have expired should have some sort of red circle or some other indicator next to it. But if you want to be sure, you can click on each one to view their details and when they expire.

    I think from there you can also right-click or something to remove the expired ones.

    I believe by double clicking the certificate, you should find some sort of “Trust” settings. They may be hidden by a drill-down triangle. I can’t remember, I’m just Googling stuff. But there should be a window that lets you grant access to the certificate for specific programs or all programs.

    If that doesn’t help, I suggest going the the iOS developer site. In the part of the site for provisioning profiles, keychains, and certificates, there should be some help files around there.

    I’m not sure what’s not working for you, but I hope you’ll be able to get it fixed!

    1. Hi Rishi,

      Unfortunately, it’s been a long time since I’ve run into this error and I haven’t worked with the iOS builds in over a year. As I recall, it was fairly consistent when I ran into it. If I were to take a stab in the dark though, is someone logging in with the same account/user that’s building the application? Maybe they or someone else is unlocking the keychain for use by the build user periodically, but permission wasn’t explicitly granted for xcode with that user? That would be my best guess based on my limited memory and not knowing your specific environment/setup. You’ll probably have better luck asking someone else who’s more involved with iOS apps. 🙁

      Best of luck to you!

Leave a Reply

Your email address will not be published. Required fields are marked *