My solution for similar problems is use of Fastlane Tools https://fastlane.tools
First You can use GYM tool for build/archive your project, and then Pilot for send it to iTunesConnect Testflight.
This tool fixes all of my problems with Code signing, submitting, etc. so I can recommend it.