@@ -147,11 +147,22 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
147147 Services . logger ( ) . log ( '[NSDebugAdapter] Running tns command...' , Tags . FrontendMessage ) ;
148148 let cliCommand : DebugResult ;
149149 if ( this . _request . isLaunch ) {
150- let teamId = this . getTeamId ( Services . appRoot , this . _request . args . tnsArgs ) ;
151- if ( ! teamId ) {
152- teamId = ( await Services . extensionClient ( ) . selectTeam ( ) ) . id ;
150+ let tnsArgs = this . _request . args . tnsArgs ;
151+
152+ // For iOS the TeamID is required if there's more than one.
153+ // Therefore if not set, show selection to the user.
154+ if ( args . platform && args . platform . toLowerCase ( ) === 'ios' ) {
155+ let teamId = this . getTeamId ( path . join ( Services . appRoot , 'app' ) , this . _request . args . tnsArgs ) ;
156+ if ( ! teamId ) {
157+ let selectedTeam = ( await Services . extensionClient ( ) . selectTeam ( ) ) ;
158+ if ( selectedTeam ) {
159+ // add the selected by the user Team Id
160+ tnsArgs = ( tnsArgs || [ ] ) . concat ( [ '--teamId' , selectedTeam . id ] ) ;
161+ }
162+ }
153163 }
154- cliCommand = this . _request . project . debug ( { stopOnEntry : this . _request . launchArgs . stopOnEntry , watch : this . _request . launchArgs . watch } , this . _request . args . tnsArgs ) ;
164+
165+ cliCommand = this . _request . project . debug ( { stopOnEntry : this . _request . launchArgs . stopOnEntry , watch : this . _request . launchArgs . watch } , tnsArgs ) ;
155166 }
156167 else if ( this . _request . isAttach ) {
157168 cliCommand = this . _request . project . attach ( this . _request . args . tnsArgs ) ;
@@ -712,8 +723,8 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
712723 }
713724
714725 private readXCConfig ( appRoot : string , flag : string ) : string {
715- let xcconfigFile = path . join ( appRoot , "App_Resources/ios /build.xcconfig" ) ;
716- if ( fs . exists ( xcconfigFile ) ) {
726+ let xcconfigFile = path . join ( appRoot , "App_Resources/iOS /build.xcconfig" ) ;
727+ if ( fs . existsSync ( xcconfigFile ) ) {
717728 let text = fs . readFileSync ( xcconfigFile , { encoding : 'utf8' } ) ;
718729 let teamId : string ;
719730 text . split ( / \r ? \n / ) . forEach ( ( line ) => {
@@ -731,7 +742,7 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
731742 }
732743
733744 let fileName = path . join ( appRoot , "teamid" ) ;
734- if ( fs . exists ( fileName ) ) {
745+ if ( fs . existsSync ( fileName ) ) {
735746 return fs . readFileSync ( fileName , { encoding : 'utf8' } ) ;
736747 }
737748
0 commit comments