No receipt -> exit 173; Mac App crashes on relaunch

In the AppDelegate -init

if (![[NSFileManager defaultManager] fileExistsAtPath:[[[NSBundle mainBundle] appStoreReceiptURL] path]]) {
  exit(173);
  }


When I remove the Container directory and then launch the app - the receipt does not exist and the exit is called.

A prompt for my sandbox credentials is shown.

When I supply the password the app immediately crashes:

...

Termination Reason: DYLD, [0x1] Library missing


Application Specific Information:

dyld: launch, loading dependent libraries


Dyld Error Message:

Library not loaded: @executable_path/../Frameworks/OAuth2Client.framework/Versions/A/OAuth2Client

Referenced from: /Users/USER/Library/Developer/Xcode/DerivedData/XYZ_macOS-bshqzazkjlburoduheemqzajgrks/Build/Products/Debug/XYZ.app/Contents/MacOS/XYZ

Reason: image not found


If I simply relaunch after this error everything proceeds normally.


What am I doing wrong?

Steve