Apr 30, 2024 2 min read

Xcode: Add Unit Test Target to an existing project

We use a template to add a Unit Test Bundle to an existing Xcode project.

Xcode: Add Unit Test Target to an existing  project
Discovery Tree - Project "<Placeholder>Bridge" > In progress "Add Unit Test Target"

ES

Create a Unit Testing Bundle
Xcode - Menu Bar - "File" > "Target"

File > New > Target...

"iOS " > Search "Unit Test" > Click on "Unit Testing Bundle"

iOS > 🔍 Unit Test > Unit Testing Bundle

Xcode - Choose options for your new target: - Product Name: WeatherBridgeTests

If for example the project is called WeatherBridge, make sure the Product Name: text is project-name+Tests.

  • It is not mandatory that the word Tests is added to the name of the project, but it is a widespread convention.
New look of the project ready to use unit tests

EN

Xcode: Añadir Unit Test Target a un proyecto existente

Árbol de descubrimiento - Proyecto "<Placeholder>Bridge" > En progreso "Add Unit Test Target"
Crear un paquete de Tests Unitarios
Xcode - Barra de menú - "File" > "Target"

File > New > Target...

"iOS " > Buscar "Unit Test" > Hacer clic sobre "Unit Testing Bundle"

iOS > 🔍 Unit Test > Unit Testing Bundle

Xcode - Choose options for your new target: - Product Name: WeatherBridgeTests

Si por ejemplo el proyecto se llama WeatherBridge, fíjate que el texto de Product Name: sea el nombre-del-proyecto+Tests.

  • No es obligado que la palabra Tests se añada al nombre del proyecto, pero es una convención muy extendida.
Nuevo aspecto del proyecto preparado para utilizar tests unitarios
Xcode - Ventana Navigator - Carpeta WeatherBridgeTests - Fichero WeatherBridgeTests.swift
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Swift Legacy Bridge.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.