Unable to run the XPC service from a sandboxed app in "Release" mode build"

I have a main application which is sandboxed. Created an XPC service for downloads the content and launch Tasks. I am able to create the connection in debug mode. But unable to do it in release mode.

Note: XPC service is not sandboxed, which is needed.

   upgradeConnection = [[NSXPCConnection alloc] initWithServiceName:@"com.test.client.TestXPC"];
  upgradeConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(PGUpdateinstallerProtocol)];
  [upgradeConnection resume];
   
  id<PGUpdateinstallerProtocol> service = [upgradeConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) {
    NSString *log = [NSString stringWithFormat:@"XPC Service creation failed Reason : %@ and user info is %@",error.debugDescription,error.userInfo];
    NSLog(@"Updates Connection failed %@",log);
  }];
   
  [service checkYouAreAbleToInstallUpdates:NSHomeDirectory() withOutput:^(NSString *bundleOp) {
    NSString *XPCLog = @"Successfully communicated with XPC Service.";
    NSLog(@"Updates failed %@",XPCLog);
  }];

During release mode I am getting error domain=nscocoaerrordomain code=4099 the connection to service is invalidated

Please let me know how to make this work in release mode.

Unable to run the XPC service from a sandboxed app in "Release" mode build"
 
 
Q