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?
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.