Library not loaded - sometimes?

Folks;


Mojave 14.5 Xcode 10.2

I have an macOS app that has an custome OAuth client embedded in it (as a framework)

If I trash the Container, clean and build the project, when I run main.m throws an exit(173) because there is no receipt.

The app will crash after supplying a valid sandbox tester credentials.

Sometimes it throws a crashReporter event (see below), sometimes it just vanishes..


If I immediately re-run the app then everything works fine...


FWIW here's main

int WhoDoApplicationMain(int argc, char *argv[]) {
  @try {
  NSData *m=[NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
  if (!m) {
  [NSException raise:@"MacAppStore Receipt Validation Error" format:@"Failed to fetch the MacAppStore receipt.", nil];
  }
  return NSApplicationMain(argc, (const char **)argv);

  } @catch (NSException *e) {
  exit(173);
  }
}


If I get a crashReporter event this is what I see..

Exception Type:        EXC_CRASH (SIGABRT)
Exception Note:        EXC_CORPSE_NOTIFY
Termination Reason:    DYLD, [0x1] Library missing
Application Specific Information:
dyld: launch, loading dependent libraries
Dyld Error Message:
  Library not loaded: @executable_path/../Frameworks/OAuthClient.framework/Versions/A/OAuthClient
  Referenced from: /Users/USER/Library/Developer/Xcode/DerivedData/XYZmacOS-bshqzazkjlburoduheemqzajgrks/Build/Products/Debug/WhoDo.app/Contents/MacOS/XYZ
  Reason: image not found

My understanding (could be wrong) is that the dylib hasn't loaded when main.m exits.

So when the app relaunches after Sandbox credentials have been supplied the app is in a 'tortured' condition...


How do I rectify or cure this behavior?

Thanks for any help here.

Steve