Cannot test debug/development version of Mac app from Xcode

I have an app that I have been distributing on the Mac App Store for the past year. When testing this build, I have always been able to run a debug configuration of the app from Xcode, sign in with a sandbox Apple ID account, and test the features of the app locally. The app would initially attempt to launch from Xcode, immediately close, then prompt me to login with an Apple ID. I would then enter a sandbox environment Apple ID, and the app would re-launch. I could then close the app, run from Xcode, and debug the app normally and be able to attach the debugger to view output.

Today when preparing to release a new version to the Mac App Store, I went through the normal routine of trying to test the app locally using the sandbox environment to validate features. I found that I now get an error message stating:

“[My App]” is damaged and can’t be opened. Delete “[My App]” and download it again from the App Store.

Noting that I had previously submitted using Xcode 12.5, and was now using Xcode 13, I loaded up Xcode 12.5 and went back to the last commit on my branch that was successfully tested locally and submitted to the Mac App Store to rule out any new changes causing the issue. Reverting back has yielded the same result, so I can rule out both code changes causing this, and a change in Xcode versions.

I am currently running macOS Big Sur 11.5.2 on a Mac Pro 2019. I have also checked the Security & Privacy pane of the Preferences app to see if I need to allow access to my app, but the button that usually appears to allow an app bypass validation checks never appears.

How can I fix this issue and test my macOS app locally before submitting to the Mac App Store as I have previously?

Answered by GravityBytes in 715527022

This issue has been a head-scratcher. I have however found a workaround which I'm not sure is the appropriate thing to do, but at least lets me develop my app without issue.

In my main.swift file I had code that would check for the existence of the Bundle.main.appStoreReceiptURL file, validate that the data was not empty, and if it was, exits the app with code 173 as described in the documentation here: https://developer.apple.com/documentation/appstorereceipts/validating_receipts_on_the_device?language=objc

This has worked in the past when using debug configurations, and lately only intermittently. Eventually I would get hard-stuck with the "your app is damaged" message and be unable to continue running my debug configuration.

Today I've modified my main.swift file to not perform this file check for debug configurations, and the app will load up just fine so I can continue working on it. I'm assuming this is safe to do since the receipt validation is still there for my release builds, but is confusing since this had worked in the past. Maybe Apple no longer supports this configuration and only validates release builds?

It'd be great to hear from someone with an actual answer to this question, and verify if I had just setup my debug configuration incorrectly or if there's something wrong with Apple's validation service. Either way, I thought I'd log my experiences here in case this helps any other frustrated developer out there.

I found additional information in the Console app, which shows there is a failure getting the receipt for the sandboxed app:

Log message 1:

Fetching missing receipt for sandbox app /PathToBuiltProductsDir/Debug/MyApp.app

Log message 2:

<ReceiptRefreshRequest: 0x7fb683c079d0>: Error fetching receipt for [app bundle id] - Error Domain=com.apple.commerce.client Code=500 "(null)"

Log message 3:

StoreLegacy: Failed to perform in-line receipt renewal for application at path /PathToBuiltProductsDir/Debug/MyApp.app : 'Error Domain=com.apple.commerce.client Code=500 "(null)"'

Additionally, running this app DOES work fine on my macbook, but not my desktop. What would cause this request to fail and how do I fix it?

Everybody has this same problem. It's also known as the exit(173) bug. Apple broke something and you can't get a receipt by logging on with your sandbox test user ID. Search the forums for 173.

This is still an issue on Xcode 13.4 using macOS 12.3.1

Accepted Answer

This issue has been a head-scratcher. I have however found a workaround which I'm not sure is the appropriate thing to do, but at least lets me develop my app without issue.

In my main.swift file I had code that would check for the existence of the Bundle.main.appStoreReceiptURL file, validate that the data was not empty, and if it was, exits the app with code 173 as described in the documentation here: https://developer.apple.com/documentation/appstorereceipts/validating_receipts_on_the_device?language=objc

This has worked in the past when using debug configurations, and lately only intermittently. Eventually I would get hard-stuck with the "your app is damaged" message and be unable to continue running my debug configuration.

Today I've modified my main.swift file to not perform this file check for debug configurations, and the app will load up just fine so I can continue working on it. I'm assuming this is safe to do since the receipt validation is still there for my release builds, but is confusing since this had worked in the past. Maybe Apple no longer supports this configuration and only validates release builds?

It'd be great to hear from someone with an actual answer to this question, and verify if I had just setup my debug configuration incorrectly or if there's something wrong with Apple's validation service. Either way, I thought I'd log my experiences here in case this helps any other frustrated developer out there.

see my response to this same question in the post "In-app purchase fail to get receipts and macos says application damaged"

rich kubota developer technical support CoreOS/Hardware/MFI

Cannot test debug/development version of Mac app from Xcode
 
 
Q