3

How do I install the XCUITest runner app and ipa on a real device and get the results?

I have a runner.app that was generated by building it for testing, and a deployed/signed .ipa.

Now what I would like to happen is to have it installed on a real device, execute it, and get the device log.

Carlos Miguel Colanta
  • 2,685
  • 3
  • 31
  • 49

3 Answers3

1

You can use bundleId :

let app = XCUIApplication(bundleIdentifier: "yourapp.bundle.id")
khalil
  • 681
  • 1
  • 6
  • 22
1

You can try to use:

xcodebuild test-without-building -xctestrun somepath/YourAppName_iphoneos14.4-arm64.xctestrun -destination 'platform=iOS, id=some_id' 

I moved YourAppName_iphoneos14.4-arm64.xctestrun, YourAppName.app, YourAppNameUITests-Runner.app to some local folder from a regular Library/Developer/etc.. build folder. Then I opened *.xctestrun file, which is an xml file, and modified paths to my local folder manually.

I couldn't find any official information about it but it seems like the *.xctestrun file is used by xcodebuild in order to find all relevant artefacts i.e both app folders. I would guess that's how they manage to run tests just with app's or ipa's without source code on various clouds...

PS. The question was about IPA, but it's convertible to the app, right? At least there is a thread - How to convert .ipa to .app file?

RiveN
  • 2,595
  • 11
  • 13
  • 26
kozlovb
  • 11
  • 1
0

Edited with answer...

It is possible to achieve this. In order to build an ipa of the UI Testing app bundle you can follow these steps:

  1. Open your project containing in Xcode.
  2. Select the device you'd like to build the ipa for next to the scheme. This can be an actual device or a simulator.
  3. Product > Build For > Testing
  4. Find [your_ui_test_bundle_name].app file in Derived Data.

    • Derived data by default is located at ~/Library/Developer/Xcode/DerivedData/
    • To locate this file, dive into DerivedData for your project, navigating to Build > Products and then the respective directory based on what you chose in step 2. If you chose a simulator, look in -iphonesimulator/ or if you chose a device look in -iphoneos/. The UI test bundle .app file should be in that directory.
  5. Create a directory named Payload case sensitive and it must be named this.

  6. Move the .app file into the Payload directory.
  7. Compress the Payload directory.
  8. Rename the compressed directory to have a file extension of .ipa. You'll be prompted and select Keep .ipa.

Now you have you UI test bundle application saved as an ipa. You can also upload this ipa to a device manually in Xcode via the following process (bonus info, yay!)

  1. Window > Devices and Simulators
  2. Select your connected device.
  3. Tap the + button under Installed Apps.
  4. Navigate to and select your UI test .ipa file that you compressed previously.
  5. It should install onto the device.

Credit where it is due: https://medium.com/ios-os-x-development/how-to-run-your-iphone-test-on-aws-device-farm-98f18086811e

atgrubb
  • 1,145
  • 7
  • 11
  • Thank you for your response, but the reason I'm asking is because I'm wondering if it would be possible to execute a test on a device w/o having the schema or the build. Let's say that I'll give it the files to a person and the person will execute it (runner and ipa). It's just like how external test services does it. – Carlos Miguel Colanta Dec 14 '17 at 04:50
  • 2
    Understood. Thanks for clarifying your question Carlos. I've not heard nor read anything about this but I'm certainly curious now. I'll also play around a bit on my end and see if I can't come up with a solution. In the mean time, good luck! – atgrubb Dec 15 '17 at 02:40
  • Hi @atgrubb, I can't seem to find any information as well. any updates on your side? – Carlos Miguel Colanta Dec 28 '17 at 22:24
  • @CarlosMiguelColanta I've updated my answer and hopefully this works for you. – atgrubb Jan 11 '18 at 16:07
  • 1
    @atgrubb I don't understand how your answer relates to the question at hand. All you provided is how to create the ipa file. – zwebie Feb 04 '18 at 15:10
  • @zwebie did you read the full answer? After explaining how to create the ipa i then provided 5 steps to take to install that ipa on the device... – atgrubb Feb 14 '18 at 23:27
  • 3
    @atgrubb yes, but the OP asked also how to execute the tests and get the logs, to which I don't see any reference. – zwebie Feb 15 '18 at 08:49