If you are getting the "failed to get the task for pid" error, that means that your app does now allow itself to be debugged. On iOS, by default, the debugger is NOT allowed to attach to an iOS app. When you build the debug configuration of your app, Xcode automatically adds the correct entitlement, and the debugger is allowed to attach. The release configuration typically does not add this entitlement, so you generally can't attach to release builds.
For more info on this entitlement, see for instance:
What does get-task-allow do in Xcode?
Without looking at your project it's hard to know what has gone wrong, but this might give you a place to start looking.