Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En esta guía, se describe cómo preparar una XCTest para realizar pruebas en
Firebase Test Lab.
Paso 1: Configura la ubicación de los datos derivados de tu proyecto
Xcode ubica los artefactos compilados de iOS, incluidas las pruebas que crees, en un directorio de datos derivados. Es posible conservar la ubicación predeterminada de ese directorio, pero resulta útil seleccionar una ubicación que tenga un acceso más sencillo para los archivos, en especial si vas a ejecutar frecuentemente pruebas con Test Lab:
Abre tu proyecto en Xcode.
En la barra de menú macOS, selecciona
File > Project Settings…
Cambia el menú desplegable Derived Data de
Default Location a Custom Location.
En el campo que se encuentra bajo el menú desplegable, selecciona una ubicación donde Xcode pueda guardar
los resultados de las pruebas (esta es tu
FOLDER_WITH_TEST_OUTPUT).
Paso 2: Compila un archivo de prueba genérico
Test Lab ejecuta pruebas de unidades y de IU con el
framework XCTest.
Para ejecutar las XCTests de tus apps en dispositivos de Test Lab, créalas para pruebas en un
dispositivo iOS genérico:
En el menú desplegable del dispositivo que aparece en la ventana superior del lugar de trabajo de Xcode, selecciona
Generic iOS Device.
En la barra de menú de macOS, selecciona
Product > Build For > Testing.
Como alternativa, puedes compilar tu XCTest desde la línea de comandos.
Usa el siguiente comando en una terminal:
Asegúrate de que todos los artefactos de la app y la prueba estén firmados. Por ejemplo, puedes
hacerlo mediante Xcode. Para ello, especifica la configuración de firma, como la identidad y el perfil
de aprovisionamiento. Para obtener más información, consulta
Firma de código de Apple.
Para verificar la firma de la app, ejecuta
codesign --verify --deep --verbose /path/to/MyApp.app, en el que “MyApp” es el
nombre de la app dentro de la carpeta descomprimida. Esto varía según el proyecto.
El resultado esperado es MyApp.app: valid on disk.
Si ejecutas una XCUITest, debes verificar la prueba y el ejecutor
mediante la ejecución de codesign --verify --deep --verbose /path/to/MyTest-Runner.app, en el que
“MyTest” es el nombre del ejecutor dentro de la carpeta descomprimida. Esto varía
según el proyecto. El resultado esperado es MyTest-Runner.app: valid on disk.
Paso 4: Empaqueta tu app y realiza la prueba para subirla
Después de crear la prueba con éxito, puedes comprimirla y subirla a Test Lab:
cd FOLDER_WITH_TEST_OUTPUT/Build/Products : \
zip -r MyTests.zip Debug-iphoneos YOUR_SCHEME_iphoneosDEPLOYMENT_TARGET-arm64.xctestrun
También puedes empaquetar tu prueba comprimiendo los archivos de prueba de forma manual como se indica a continuación:
Abre Finder y navega hasta
FOLDER_WITH_TEST_OUTPUT.
Abre la carpeta que tiene el nombre de tu proyecto como prefijo y, luego, navega a
la carpeta Build/Products.
Selecciona las carpetas Debug-iphoneos y
YOUR_SCHEME_iphoneosDEPLOYMENT_TARGET-arm64.xctestrun
y, luego, comprímelas.
Paso 5: Ejecuta la prueba de forma local (opcional)
Antes de ejecutar tu prueba con Test Lab, puedes ejecutarla de manera local
con un dispositivo conectado por USB para verificar su comportamiento:
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[],[],null,["\u003cbr /\u003e\n\nThis guide describes how to prepare an XCTest for testing in\nFirebase Test Lab.\n\n**Step 1**: Configure your project's Derived Data location\n\nXcode places compiled iOS artifacts, including any tests you build, in a Derived\nData directory. It is possible to keep the default location for that directory,\nif you'd like, but it's often helpful to choose a more easily-accessible place\nfor the files, especially if you're going to be running tests with Test Lab\noften:\n\n1. Open your project in Xcode.\n2. In the macOS menu bar, select **File** \\\u003e **Project Settings...**\n3. Change the **Derived Data** drop-down from **Default Location** to **Custom Location**.\n4. In the field below the drop-down, select a location for Xcode to output your tests to. (This is your \u003cvar class=\"edit\" scope=\"FOLDER_WITH_TEST_OUTPUT\" translate=\"no\"\u003eFOLDER_WITH_TEST_OUTPUT\u003c/var\u003e)\n\n**Step 2**: Build a generic test file\n\nTest Lab runs unit tests and UI tests using the\n[XCTest](https://developer.apple.com/documentation/xctest) framework.\nTo run your app's XCTests on Test Lab devices, build it for testing on a\nGeneric iOS Device:\n\n1. From the device drop-down at the top of your Xcode workspace window, select **Generic iOS Device**.\n2. In the macOS menu bar, select **Product** \\\u003e **Build For** \\\u003e **Testing**.\n\nAs an alternative, you can build your XCTest from the command line.\nUse the following command in a terminal: \n\nproject \n\n```\nxcodebuild -project PATH/TO/YOUR_WORKSPACE/YOUR_PROJECT.xcodeproj \\\n -scheme YOUR_SCHEME \\\n -derivedDataPath FOLDER_WITH_TEST_OUTPUT \\\n -sdk iphoneos build-for-testing\n```\n\nworkspace \n\n```\nxcodebuild -workspace PATH/TO/YOUR_WORKSPACE.xcworkspace \\\n -scheme YOUR_SCHEME \\\n -derivedDataPath FOLDER_WITH_TEST_OUTPUT \\\n -sdk iphoneos build-for-testing\n```\n\n**Step 3**: Sign your test and verify\n\n1. Make sure all artifacts in the app and test are signed. For example, you can\n do this through Xcode by specifying signing settings like provisioning profile\n and identity. For more information, see\n [Apple Code Signing](https://developer.apple.com/support/code-signing/).\n\n | **Note** : Test Lab re-signs your app with its own provisioning profile and certificate.\n2. Verify app signature by running\n `codesign --verify --deep --verbose /path/to/MyApp.app` where \"MyApp\" is the\n name of the app inside the unzipped folder. This varies for each project.\n Expected output is `MyApp.app: valid on disk`.\n\n3. If you are running an XCUITest, then you need to verify the test and runner\n by running `codesign --verify --deep --verbose /path/to/MyTest-Runner.app` where\n \"MyTest\" is the name of the runner inside the unzipped folder. This varies for\n each project. Expected output is `MyTest-Runner.app: valid on disk`.\n\n**Step 4**: Package your app and test for uploading\n\n1. After your test successfully builds, zip it for upload to Test Lab:\n\n ```\n cd FOLDER_WITH_TEST_OUTPUT/Build/Products : \\\n zip -r MyTests.zip Debug-iphoneos YOUR_SCHEME_iphoneosDEPLOYMENT_TARGET-arm64.xctestrun\n ```\n\nYou can also package up your test by compressing the test files manually:\n\n1. Open Finder and navigate to\n \u003cvar class=\"edit\" scope=\"FOLDER_WITH_TEST_OUTPUT\" translate=\"no\"\u003eFOLDER_WITH_TEST_OUTPUT\u003c/var\u003e.\n\n2. Open the folder that has your project name as a prefix, then navigate to\n `Build/Products` folder inside.\n\n3. Select the folders `Debug-iphoneos` and\n \u003cvar class=\"edit\" scope=\"YOUR_SCHEME\" translate=\"no\"\u003eYOUR_SCHEME\u003c/var\u003e`_iphoneos`\u003cvar class=\"edit\" scope=\"DEPLOYMENT_TARGET\" translate=\"no\"\u003eDEPLOYMENT_TARGET\u003c/var\u003e`-arm64.xctestrun`\n and then compress them.\n\n**Step 5**: (Optional) Run your test locally\n\nBefore running your test with Test Lab, you can run it locally with\na USB-connected device to quality check its behavior: \n\n```\nxcodebuild test-without-building \\\n -xctestrun \"Derived Data/Build/Products/YOUR_SCHEME.xctestrun\" \\\n -destination id=your-phone-id\n```\n\nNext steps\n\nUpload and run your test in the [Firebase console](/docs/test-lab/ios/firebase-console)\nor the [gcloud CLI](/docs/test-lab/ios/command-line)."]]