Easier App Debugging with Xamarin Studio Run Configurations
When building apps, we often want to run our application under varying conditions. Whether this is something simple like altering environmental variables, or something a bit more complex like changing the startup Activity or service for an Android app, changing your project’s settings to switch between configurations can be tedious, especially if you change between them often.
Xamarin Studio 6.1 makes debugging and testing your apps with multiple configurations even easier with run configurations. Run configurations are created automatically for each executable project and allow you specify a set of options for your app to launch with. Some project types may even generate additional run configuration options, such as selecting which mode to launch your watchOS app in or to turning on background fetch for your iOS app. In this blog post, you’ll learn how to use Xamarin Studio 6.1’s run configurations feature and create your own run configurations for easier app debugging and testing.
Introducing Run Configurations
Run configurations make it as easy as possible to switch between multiple app projects and run them with different options. Rather than having to update project options to run our app in different scenarios, we can simply define a run configuration with a particular set of execution options with a name and easily switch back-and-forth between configurations with the click of a button. Run configurations are defined at the project-level and a default is automatically created for each executable project. To use run configurations, you must have at least Xamarin Studio 6.1 (available in the Stable channel) installed.
To view run configurations, right-click the project name, click Project Options, and navigate to the Run section. In this section, you’ll see a list of run configurations, and a blank run configuration will automatically be created by default if one doesn’t already exist. Depending on the project type, we can set things from arguments to environmental variables to the runtime.
We can click the New button under the Configurations section to create a new runtime configuration.
To debug our application using a different runtime configuration, simply click the configuration you wish to use from the toolbar dropdown in Xamarin Studio. This is awesome, because we can now easily change options for our app back-and-forth with the click of a button.
The scope of these configurations can be user-specific or even applied directly to the project to share the run configurations with your whole team.
Project-Specific Run Configurations
To bring run configurations to the next level, Xamarin Studio supports the idea of special run configurations for each project type. For example, we can create a run configuration that runs our iOS app in background fetch mode, or an Android run configuration to set the entry point of our app to an
Each project type has it’s own run configuration options:
- Entry point (Activity, Service, BroadcastReceiver)
- Intent arguments and data
- Mode (Normal, Background Data Fetch)
- iOS Extensions
- Startup App (Default or Custom)
- Mode (Glance or Notification)
- Notification payload
Imagine we have a scenario where we want to test how our watchOS application responds to notifications. Rather than launching the app in the watchOS Simulator and sending a push notification from the server for testing, we can create a run configuration for this scenario, define the execution mode as Notification, set the path to a .json payload, and debug our watchOS app.
To fire the notification, all we have to do is set the run configuration for testing that scenario and debug our app.
In this blog post, we took at a look at run configurations, introduced in Xamarin Studio 6.1, to help make it even easier to debug and test our apps under different circumstances. Certain project types also have special run configurations available, such as the ability to set the entry point for our Android application or set the WatchKit configuration to Glance or Notification. To learn more about run configurations, visit our guide on Projects, Solutions, and Configurations in the Xamarin Documentation Center.