Community Forums

Xcode Cloud Build Failed with Exit Code 65

JD
johndoe Original Poster
2 days ago

Hey everyone,

I'm encountering an issue with my latest Xcode Cloud build. It consistently fails with an exit code of 65. I've checked the build logs and it seems to be related to a code signing or provisioning profile issue, but I'm not entirely sure how to pinpoint it.

Here's a snippet from the logs:


[10:35:15]: $ set -o pipefail
[10:35:15]: $ xcodebuild -workspace MyProject.xcworkspace -scheme MyScheme -sdk iphoneos -configuration Release archive -archivePath $PWD/build/MyProject.xcarchive
[10:37:45]: ▸ ** ARCHIVE FAILED **
[10:37:45]: ▸ Command line invocation:
[10:37:45]: ▸     /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace MyProject.xcworkspace -scheme MyScheme -sdk iphoneos -configuration Release archive -archivePath /Volumes/workspace/build/MyProject.xcarchive
[10:37:45]: ▸
[10:37:45]: ▸ User defaults:
[10:37:45]: ▸     IDEPackageSupportUseBuiltinSCM = YES
[10:37:45]: ▸
[10:37:45]: ▸ It is recommended that you use Xcode 14.2 or later.
[10:37:45]: ▸ ** ARCHIVE FAILED **
[10:37:45]: ▸ xcrun: error: unable to find utility "PackageApplication", not a developer tool or in PATH
[10:37:45]: ▸ 
[10:37:45]: [10:37:45]: Exit code: 65
[10:37:45]: 
[10:37:45]: Lane: ios_build
[10:37:45]: 
[10:37:45]: ERROR [2023-10-27 10:37:45]: Fastlane error:
[10:37:45]: [!] Xcode did not generate a recognizable build.
[10:37:45]: Ensure that you are using a version of Xcode that is supported by the SDK you are using.
[10:37:45]: If you are using a beta version of Xcode, please ensure that you are using a beta version of fastlane.
[10:37:45]: For more information on how to resolve this, check out the troubleshooting guide: https://docs.fastlane.tools/examples/ios/codesigning/
                    

I've already tried regenerating the provisioning profile and certificates on the Apple Developer portal, but that didn't resolve the issue. Has anyone else faced this with Xcode Cloud and Exit Code 65? Any advice on what to check next would be greatly appreciated!

Thanks!

AS
annasmith Moderator
1 day ago

Hi John,

Exit code 65 in Xcode Cloud often points to a code signing or provisioning profile mismatch. The log snippet `xcrun: error: unable to find utility "PackageApplication", not a developer tool or in PATH` is a bit unusual and might be a symptom of a larger issue with how the build environment is set up or how Xcode is finding its tools.

Here are a few things to check:

  • Xcode Version Mismatch: The log suggests "It is recommended that you use Xcode 14.2 or later." Make sure the Xcode version specified in your Xcode Cloud workflow matches the version you're using locally and that it's fully installed and functional.
  • Build Settings: Double-check your project's build settings for "Signing & Capabilities" in Xcode. Ensure "Automatically manage signing" is checked if you want Xcode Cloud to handle it, or that your manual signing configurations are correct.
  • Provisioning Profile and Certificates: Even though you've regenerated them, verify that the correct provisioning profile (e.g., App Store, Ad Hoc) is selected for your Release build configuration and that the corresponding certificates are installed correctly on the machine that performed the signing (or are correctly managed by Xcode Cloud).
  • Xcode Cloud Environment: Sometimes, cleaning the Xcode Cloud build environment can help. In your workflow settings, try deleting the previous build cache or performing a clean build.
  • Fastlane Configuration (if used): If you're using Fastlane, ensure your `Appfile` and `Fastfile` are correctly configured for Xcode Cloud, especially regarding bundle identifiers and signing credentials. The error about `PackageApplication` might indicate a Fastlane issue if you're not using a very recent version of Xcode that might have deprecated it or changed its location.

Could you share more details about your Fastlane setup, if any, or how your code signing is configured in Xcode Cloud? That might help narrow down the problem.

JD
johndoe
1 day ago

Thanks for the quick reply, Anna!

I'm using Xcode 14.3.1 locally, and my Xcode Cloud workflow is set to use the latest stable version, which I believe is 14.3.1 as well. I've set "Automatically manage signing" in my project's "Signing & Capabilities" for the Release configuration.

I'm not using Fastlane directly in my Xcode Cloud workflow; I'm relying on the built-in Archive action. I did try cleaning the build cache in Xcode Cloud, but the issue persisted.

One thing I noticed is that when I download the build artifacts from a *failed* build, the `.xcarchive` file seems incomplete. It's much smaller than a successful archive from my local machine.

AS
annasmith Moderator
1 day ago

That's a very good clue, John! An incomplete archive suggests the archiving process itself is failing before it can fully package everything, which aligns with the exit code 65 and the `PackageApplication` error.

Since you're not using Fastlane and are relying on Xcode Cloud's built-in archiving, let's focus on the Xcode Cloud configuration itself:

  • Workflow Configuration: Go into your Xcode Cloud workflow settings. Under the "Build" section, review the "Arguments" or "Configuration" settings. Ensure there are no custom build flags or arguments that might interfere with the archiving process.
  • Branch and Tags: Sometimes, issues can arise with specific branches or if your Git tags are not set up as expected for archiving. Ensure your target branch is clean and that the Git tag (if you're using tags for builds) is correctly pointing to a commit that's ready for archiving.
  • Dependencies: Although less common for exit code 65, ensure all your project dependencies (CocoaPods, SPM, Carthage) are correctly resolved and installed during the build. You might consider adding a "Resolve Dependencies" step before the archive step if you're not already doing so.
  • Xcode Cloud Settings for Code Signing: Even with "Automatically manage signing" checked in your project, ensure that the correct signing certificate and provisioning profile are selected within your Xcode Cloud workflow settings for the specific branch you are building. Sometimes, a mismatch here can cause issues even if the project settings are correct.
  • Test Builds: Try creating a very basic test build on Xcode Cloud using a different branch or a simple test project to see if that succeeds. This can help isolate whether the problem is with your specific project or the Xcode Cloud environment.

The fact that the archive is incomplete is key. It suggests something is fundamentally breaking the `xcodebuild archive` command itself before it can finish. Let's check those workflow settings.