How to debug iOS app on Windows

  • Remove From My Forums

  • Question

  • User386626 posted

    Hello,

    I developed an app that should be saved and tested in an iPhone. I used Visual Studio 2019 on a PC.

    At the moment, I have read that I need a Mac computer to compile for iPhone, and in fact, when plugging the iPhone in a USB port, it is not listed in the devices combobox, the same way an Android device is in the Android project.

    Is there a remote possibility to use a PC to build and save the app in the iPhone and then debug it? Or at least, to run it using the same phone.

    If it is not possible, and according your experience, would it work if I try a Mac virtual machine? All of you guys have Mac computers to develop for iOS?

    I wait your comments.

    Thanks

    Jaime

In the world of app development and testing, cross platform testing has become a fixture in QA pipelines. This is done to ensure that the application works flawlessly across all the operating systems and mobile devices.

However, QAs may not always have the requisite devices on hand for testing. For example, they may not have all the necessary iOS devices on which to test an iOS app. For example, they might have to test iOS apps on a Windows PC because that is all they can access at the moment. 

This article will explore how to do exactly that. It will outline two methods – using the XCode simulator and using the real iOS devices on the BrowserStack cloud.

Method 1: Using the XCode Simulator

So let’s have a look at the process of setting up an iOS simulator. This will enable users to test any iOS app on a Windows device.
Apple does not offer a standalone simulator on the App Store. Rather, look for and download XCode which is freely available on the store. Xcode is an integrated development environment (IDE) developed by Apple. It enables the development of applications for all Apple operating systems including iOS, macOS, tvOS, and WatchOS.

Follow the steps below to tests iOS apps on XCode simulator:

Download the Xcode simulator and start by creating a project. You can build and run your app on a simulated or real device without writing code. You can connect a real device to your Mac using a cable, or for iOS or tvOS apps, connect it over Wi-Fi after you pair it with Xcode. For macOS apps, choose a scheme, then click the Run button in the toolbar.

How to debug iOS app on Windows

A scheme is a collection of settings that specify the targets to build, the build configuration, and the executable environment for an app. There’s a scheme for each product (app, library, or framework) in your project. For projects that build an app, choose the scheme that matches your app’s name from the scheme menu in the toolbar. For watchOS apps, choose the WatchKit App target as the scheme.

How to debug iOS app on Windows

Now, select a simulator. For iOS, and watchOS apps, you can choose a simulated device, under [Platform] Simulators, from the run destination menu next to the scheme menu in the toolbar.

How to debug iOS app on Windows

Next step is to select a real device. Before distributing the application, launch it on a real device. Connect the device to your Mac, and choose the device in the run destination menu. If you choose a real device, add your Apple ID in Accounts and assign the project on the Signing & Capabilities window pane of the project editor. For macOS apps, code sign the app by enabling certain capabilities.

Click the Run button to build and run the app on the selected simulated or real device. VIf the build is successful, Xcode runs the app and opens a debugging session in the debug area. Use the controls in the debug area to step through your code, inspect variables, and interact with the debugger.

How to debug iOS app on Windows

If the build is unsuccessful, click the indicators in the activity area to read the error or warning messages in the Issue Navigator. Alternatively, choose View > Navigators > Show Issue Navigator to view the messages.

Now let’s understand how to test an iOS app on a Windows machine using Browserstack’s real device cloud.

Be it manual or automated app testing, QAs can utilize BrowserStack’s infrastructure to get 100% accurate results in real-world circumstances.

Test Apps on Real Mobile Devices

Method 2: Test iOS apps on Windows using BrowserStack

There are two ways to test iOS apps on Windows – Manual App Testing (that is testing an iOS app on your physical Windows PC) and Automated App Testing. We will be discussing the automation approach in detail.

  • Login to Browserstack platform and launch App automate.
  • Sample code is already available, you need to modify and add your code.
  • Once it is configured, the next step is to set up the dependencies and desired capabilities to run the test.
  • In order to test, you need to first upload an iOS app to BrowserStack servers. In this case, I will use the sample iOS app and modify it according to my code.

Before writing the final test case, you need to configure your test case by giving details to the following:

  • Use desired capabilities
  • Set access credentials
  • Specify application under test
  • Select a device for testing (In this case, it is iOS and iPhone 12 Pro Max)
  • Create a remote webdriver
  • Write the test case

Now let’s code the program.

package ios;

import java.net.URL;

import java.util.List;

import java.net.MalformedURLException;;

import org.openqa.selenium.support.ui.WebDriverWait;

import org.openqa.selenium.remote.DesiredCapabilities;

import org.openqa.selenium.support.ui.ExpectedConditions;
 
import io.appium.java_client.MobileBy;

import io.appium.java_client.ios.IOSDriver;

import io.appium.java_client.ios.IOSElement;

public class BrowserStackSample {

  public static void main(String[] args) throws MalformedURLException, InterruptedException {

      DesiredCapabilities caps = new DesiredCapabilities();

   // Set your access credentials

      caps.setCapability("browserstack.user", "Username");

      caps.setCapability("browserstack.key", "Password");

   // Set URL of the application under test

      caps.setCapability("app", "bs://444bd0308813ae0dc236f8cd461c02d3afa7901d");

   // Specify device and os_version for testing

      caps.setCapability("device", "iPhone 12 Pro Max");

      caps.setCapability("os_version", "14");

   // Set other BrowserStack capabilities

      caps.setCapability("project", "First Project");

      caps.setCapability("build", "Java iOS");

      caps.setCapability("name", "first_test");

   // Initialise the remote Webdriver using BrowserStack remote URL

   // and desired capabilities defined above

        IOSDriver driver = new IOSDriver(

         new URL("http://hub-cloud.browserstack.com/wd/hub"), caps);

     // Test case for the BrowserStack sample iOS app.      

  IOSElement textButton = (IOSElement) new WebDriverWait(driver, 30).until(

            ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Input")));

         textInput.sendKeys("mail.gogle.com");

     IOSElement textInput = (IOSElement) new WebDriverWait(driver, 30).until(

            ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Input")));

        textInput.sendKeys("");

        Thread.sleep(5000);

     IOSElement textOutput = (IOSElement) new WebDriverWait(driver, 30).until(

             ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Output")));

        if(textOutput != null && textOutput.getText().equals(""))

            assert(true);

     else

            assert(false); 

     // Invoke driver.quit() after the test is done to indicate that the test is completed.

        driver.quit();

  }
 

}

You can also download the file and save it in order to upload it to App Live for real-time testing on iOS.

Now, execute the program using the below command on the command line.

mvn test -P 

Also, you can go to App live and upload this file to run the test on the device that you prefer.

Now that you have an iOS app ready, you can deploy this into the windows platform to test the application and check for its compatibility.

Now, let’s launch the Live Browserstack tool to test the application on windows. Upload the application developed and set the windows environment you want to test the application in. This example uses Windows 10 and Chrome 94.

Output goes like this:

How to debug iOS app on Windows


That’s how you can test the application.

However, to take full advantage of its features, tests must be run on real mobile devices (iOS, Android, Windows, etc.) There is no way to accurately identify all possible bugs without testing apps in real user conditions, and that is where BrowserStack App Automate comes in.BrowserStack’s real device cloud offers thousands of real mobile devices from major vendors and manufacturers for app testing (manual and automated). Each device is loaded with real operating systems – multiple versions of popular operating systems in use.

Essentially, QAs can access thousands of popular mobile device-OS combinations to test their app. They don’t have to worry about buying and updating devices and installing software. They just need to sign up for free, choose the required device-OS combination and start testing their app.

Can I debug iOS app on Windows?

Also, you can go to App live and upload this file to run the test on the device that you prefer. Now that you have an iOS app ready, you can deploy this into the windows platform to test the application and check for its compatibility. Now, let's launch the Live Browserstack tool to test the application on windows.

How do I debug an installed iOS app?

Steps to connect when the application is installed but not in running mode.
Application is installed either on a simulator or on the device..
Select Debug option from XCode Menu..
Select Attach to Process by PID or Name..
You'll get a popup, where by entering PID or name you can attach to the debugger..

Is there USB debugging on iOS?

Using Safari Remote Debugging Apple's iOS 6 update introduced Safari Remote Debugging, which allows you debug web pages in the Safari app on iOS devices. To get started, follow the steps below: Connect your iOS device to your machine via USB cable. On your device, open the Settings app.

Can I use Xcode on Windows?

Given that Xcode works only on macOS, a solution to get Xcode on Windows would be to install macOS on a Windows PC by means of a virtualization app such as VMware or VirtualBox. Using a virtualization platform provides users with the full functionality of Xcode on your Windows machine.