I\'ve setup some XCTest unit tests for my application and would like every time I run tests for it to run in a brand new install of the application. Currently when
In addition to @rintaro's answer, if you set "Provide build settings from" to your app, you can add a generic command, which will keep working when your bundle id changes:
xcrun simctl uninstall booted ${PRODUCT_BUNDLE_IDENTIFIER}
Maybe this works, but only for Simulator.
In Product > Scheme > Edit Scheme...

xcrun simctl is command line utility to control the iOS Simulator.
This uninstalls com.yourcompany.AppName application from booted simulator before running tests.
I don't know how to do like this for real device :(