3

In Xcode 12, how can it be known at build time which .xctestplan will be used?

I have a build script that needs to take a certain action depending on which xctestplan is currently selected in Xcode when the user presses command-U (to start testing).

If Plan A is active then the script should perform Action A. If Plan B is selected then the script should perform action B. This needs to take place before the testrunner launches.

CommaToast
  • 11,370
  • 7
  • 54
  • 69
  • Idea: Inject environment variables via each test plan. Now your script can test for those (I think). – matt Mar 30 '21 at 00:15
  • @matt That was the first thing I tried. But test-plan-specific environment variables are not visible to build-phase scripts or pre-test action scripts. They are visible during runtime of tests via ProcessInfo.processInfo.environment, but by that point, it's too late to change the app data. Even if you overwrite the prior app data programatically before UIApplicationMain even gets initialized, simulator will only use whatever app data existed at build time (not at runtime). – CommaToast Mar 30 '21 at 00:34
  • Note that I'm trying to workaround a bug in Xcode versions 6–12 where the .xcappdata associated with a given XCScheme or XCTestPlan does not get installed to the simulator, only to the device. Apple has been incredibly neglectful not to fix this and it's completely ridiculous that I'm even having to ask this question. – CommaToast Mar 30 '21 at 00:36
  • Sounds like filing a bug is all you can do. :( – matt Mar 30 '21 at 02:51
  • Still seems like there ought to be some way to tell which testplan is active before the simulator loads the app... – scaly Mar 31 '21 at 20:33

0 Answers0