=====================================================
4. How to setup Xcode for a Flutter app without a MAC
=====================================================

In this tutorial, you will learn how to **configure Xcode** with the help of Appollo to **build your app**.

**This can be achieved without a Mac**. Therefore, you can accomplish this part on  **Windows** or **Linux**.

Requirements
------------

**Before starting the build**, make sure you are in the root folder of your Flutter app.

**If** you do not have a Flutter app for this tutorial, get started on the |flutter_app|.

You also have to make sure that you have already **created at least one App ID**.

You can use ``appollo app ls`` to retrieve a list of all your App IDs.

.. image:: /img/appollo-app-ls.jpg
  :alt: Appollo app ls
  :align: center

|

See previous :ref:`step <previous_step>` of this tutorial if you have skipped it.

Start the configuration build
-----------------------------

When starting an Appollo build, with ``appollo build start``, you are asked to select the **App ID** for which you want
to make a build and also a **build type** among 6 different types.

At this stage, since you want to be able to configure Xcode, you have to use the **configuration** build type.

.. note::
    if you only have a single **App ID** registered on Appollo, it is automatically selected when running ``appollo build start``.

Your build has now been registered and is starting.

.. tip::
    If the build fails you can easily access the logs of your build with the command ``appollo build logs`` and select
    the build for which you want to view the logs.

.. tip::
    If you closed your terminal while your app was building you can execute ``appollo build detail`` and select the last
    build and you will have a detailed view of the build's status. Builds do not stop if the ``appollo build start``
    command is killed.

Connect to your configuration build
-----------------------------------

Once your build is ready, it takes a few minutes, you can use ``appollo build connect`` and select your last build in
the list.

This command will list your connection settings and credentials for a remote connection with Spice.

.. image:: /img/appollo-build-connect.jpg
  :alt: Appollo build connect
  :align: center

|

.. tip::
    If you try to connect a build that was not meant for remote desktop, no problem, Appollo will suggest
    you to create one automatically.

    .. image:: /img/appollo-connect-other.jpg
      :alt: Appollo build connect with other build
      :align: center

|

Use Spice Remote viewer to configure Xcode
------------------------------------------

For this step, you need a remote desktop access application. In this tutorial, the one used is **Spice-Space's** |spice_client|.

Launch your software, it is named RemoteViewer on your computer, indicate the **url** your were given and connect.

.. image:: /img/appollo-remote-connect.jpg
  :alt: Appollo remote connect
  :align: center

|

Second, simply type in the **connection_password** to authenticate.

.. image:: /img/appollo-remote-pw.jpg
  :alt: Appollo remote password
  :align: center

|

That's it ! You are now connected to an Appollo-Remote build machine in remote desktop.

Configure Xcode on the Appollo-Remote
-------------------------------------

At this point, follow these **4-easy steps**:

To configure it with Xcode,

1. Open Xcode

2. Select Open an existing project

.. image:: /img/appollo-xcode.jpg
  :alt: Appollo remote xcode
  :align: center

|

3. Select file Documents/app/ios/Runner.xcworkspace

.. image:: /img/appollo-xcode-file.jpg
  :alt: Appollo remote xcode file
  :align: center

|

4. Enjoy !

.. image:: /img/appollo-xcode-build.jpg
  :alt: Appollo remote xcode build
  :align: center

|

We will configure the Bundle Identifier in XCode for our app to be the same to the one we created with Appollo otherwise
Apple will not accept our submission later on in the tutorial. In the left menu of XCode select **Runner** and in the
General tab under Identity update Bundle Identifier with the bundle ID generated beforehand.

.. image:: /img/appollo-xcode-bundle-id.jpg
   :alt: XCode bundle identifier
   :align: center

|

.. |spice_client| raw:: html

   <a href="https://www.spice-space.org/download.html" target="_blank">client</a>

.. |flutter_app| raw:: html

   <a href="https://docs.flutter.dev/get-started/test-drive?tab=vscode#create-app" target="_blank"> official Flutter tutorial</a>
