Book Image

Learning Xamarin studio

By : William Smith
Book Image

Learning Xamarin studio

By: William Smith

Overview of this book

Table of Contents (16 chapters)
Learning Xamarin Studio
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Setting up test devices


Simulators and AVDs are acceptable for development testing, but it is unwise to rely solely on these virtual environments. Therefore, it is important to test on at least one physical device that matches your target environment.

Setting up iOS devices

Although setting up the iOS simulator is a joy, setting up devices for testing is anything but a joy. To test using your iOS device, you must have several items in place. If you have been following along up until now, you already have your Apple iOS Developer Program account. Now, you need a development certificate and a provisioning profile for your device.

Note

If you do not intend to develop iOS applications, you may skip this walkthrough for now and come back to it whenever you're ready.

Obtaining a development certificate

There are two ways to generate your development certificate, and the method you choose is largely based on whether you are developing on a Mac or on a Windows machine. First, for those who are developing on a Mac, we'll look at how to generate your development certificate and associate it with your application within Xamarin Studio. Here are the steps you need to follow:

  1. Open your solution inside Xamarin Studio.

  2. Go to Xamarin Studio | Preferences.

  3. Under the Environment group, select the Developer Accounts panel.

  4. Click the plus (+) button.

  5. Enter your Apple ID and password in the dialog that appears.

  6. Your credentials will be verified and Xamarin will automatically generate the developer certificate for that account.

  7. Close the Preferences dialog.

  8. Double-click on the start-up project, which will open the Project Options dialog.

  9. In the Build group, choose the iOS Application item.

  10. Open the Team drop-down list and choose your developer account.

  11. Click OK.

For those developing iOS applications on a Windows machine, the process is only slightly more involved and requires manual generation of the developer certificate. The steps are follows:

  1. On your Mac, open Finder.

  2. Open Keychain Access by navigating to Applications | Utilities.

  3. Open Keychain Access | Certificate Assistant | Request a Certificate From a Certificate Authority.

  4. Enter your e-mail address and name.

  5. Under the Request group, choose Saved to disk.

  6. Click the Continue button.

  7. When prompted, save the file on your desktop.

  8. Open a browser and log in to the Certificates, Identifiers, and Profiles section of the Developer Portal at https://developer.apple.com/account/overview.action.

  9. In the Certificates section, choose the iOS Apps column.

  10. Click the plus (+) button to create a new certificate.

  11. For the type of certificate, choose iOS App Development.

  12. Click Continue.

  13. On the Generate your certificate screen, upload the certificate file you saved previously.

  14. Click Generate.

  15. Download your new certificate.

  16. Open the file. This will add the certificate to Keychain.

Provisioning your devices

Now that you have a developer certificate for your applications to link to, you still need to add your devices to your developer account by a process called provisioning. To provision a device, we must first create a provisioning profile containing that device's information. You must repeat the following process for every device you want to provision. Here are the steps you need to follow:

  1. Plug your device into your Mac and launch iTunes.

  2. From the sidebar select your device.

  3. Click on the Serial Number value.

  4. The serial number will change to Identifier (UDID).

  5. Copy the serial number value.

  6. Open a browser and log in to the Certificates, Identifiers, and Profiles section of the Developer Portal at https://developer.apple.com/account/overview.action.

  7. Open the Devices section and click the plus (+) button.

  8. Enter a name for your device and the UDID you copied from iTunes.

  9. Click Continue.

  10. Verify that your new information is included in the list of devices and that it is correct.

  11. Click Submit.

  12. Once the profile is generated, click Download.

  13. Open iTunes again and select your device.

  14. Drag the provisioning profile file to the Library in iTunes.

  15. Click the Sync button, and the profile will be installed to your device.

Setting up Android devices

In order to test on an Android device, three steps must be performed:

  1. First, you must enable debugging on the device.

  2. Next, you may need to install additional USB drivers.

  3. Finally, you need to connect your device to your computer using a USB or alternately via Wi-Fi.

Note

If you do not intend to develop Android applications, you may skip this walkthrough for now and come back to it whenever you're ready.

Enabling debugging on your device

To enable debugging on Android 3.2 and older devices, perform the following steps:

  1. On your device, open the Application menu.

  2. Go to Settings.

  3. Select Applications.

  4. Select the Development item.

  5. Check USB Debugging.

To enable debugging on Android 4.0 to 4.1, perform the following steps:

  1. On your device, go to the Settings screen.

  2. Select Developer Options.

  3. Uncheck the USB Debugging option.

To enable debugging on Android 4.2 and higher, perform the following steps:

  1. On your device, go to the Settings screen.

  2. Open the About Phone group.

  3. Tap the Build Number item seven times (yes, I'm serious).

  4. Go back to the Settings screen.

  5. Select Applications.

  6. Select the Development item.

  7. Check USB Debugging.

Installing USB drivers and connecting your device

Using a USB cable is the easiest method of connecting your device and development machine. If you are developing on a Mac, you just need to plug it in. If you are developing on a Windows machine, you may also need to install additional USB drivers for your specific device. Since each manufacturer tends to release their own unique USB drivers, you will need to search over the Internet for the specific instructions for your device.

Under certain circumstances, however, you may want to use Wi-Fi to connect to your device. Connecting via Wi-Fi is completely optional so you may skip this section if it doesn't apply to you. Perform the following steps:

  1. Ensure that your device is connected to the same Wi-Fi network as your development machine.

  2. On your device, go to Settings | Wi-Fi.

  3. Tap the Wi-Fi network you are currently connected to.

  4. Scroll down until you see your device's IP address.

  5. Connect your device to your development machine with a USB cable.

  6. Open Terminal (command prompt on Windows) and enter the following command:

    adb tcpip 5555
    
  7. Disconnect your device from the development machine.

  8. Again in Terminal (command prompt on Windows), enter the following command replacing the listed IP address with that of your device:

    adb connect 192.168.254.12:5555
    
  9. Your device can now be tested across a Wi-Fi network. When you are done testing via Wi-Fi, open Terminal (command prompt on Windows) and enter the following command:

    abd disconnect 192.168.254.12:5555