2017-09-01 4 views
0

Est-il possible d'avoir Xcode en arrière-plan, mais compiler et exécuter le projet en cours via un script?Xcode exécuté à partir d'une autre application/ligne de commande/script Apple

J'utilise principalement AppCode pour le développement, mais je voudrais lancer à partir de Xcode via un raccourci clavier. AppCode n'affiche pas correctement une barre de compilation-progression (Xcode sur le second écran), les capacités de débogage d'AppCode ne sont pas aussi avancées que celles de Xcode. Sinon, AppCode est plus rapide et mieux.

Répondre

1

Il est possible d'un AppleScript, voici un exemple de script (testé sur Sierra et Xcode Version 8.3.3):

tell application "Xcode" 
    tell active workspace document to if exists then 
     repeat until (loaded) -- Whether the workspace document has finished loading after being opened 
      delay 1 
     end repeat 
     run -- Invoke the "run" scheme action 
    end if 
end tell 

Pour exécuter sur un périphérique spécifique: I ne pas avoir de périphériques à tester, mais j'utilise le simulateur, essayez ce script:

tell application "Xcode" 
    tell active workspace document to if exists then 
     repeat until (loaded) -- Whether the workspace document has finished loading after being opened 
      delay 1 
     end repeat 
     --**** run on a specific device **** 
     set active run destination to run destination "iPad Pro (12.9 inch)" -- *** change it to the name of your device *** 

     set schAction to run -- Invoke the "run" scheme action 
     repeat while (get status of schAction) is in {not yet started, running} -- exit the loop when the status is (‌cancelled, failed, ‌error occurred or ‌succeeded), so I press the stop button in Xcode, or I delete the application in the simulator or I quit the simulator. 
      delay 3 
     end repeat 

     --**** run on another specific device **** 
     set active run destination to run destination "iPhone 7" -- *** change it to the name of your device *** 
     run 
    end if 
end tell 
+0

W C'est rapide et c'est génial! Je vous remercie! Par hasard, savez-vous aussi courir sur un appareil spécifique? Je fais un jeu multijoueur en temps réel et j'ai souvent besoin de deux appareils. Ce serait cool de fonctionner sur un appareil, d'attendre que cela soit fait, puis de courir sur l'autre. – keyboard