Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

Win one of the five The Mobile System Design book copiesJoin for free

Share Extension UI Tests written in Swift

UI Tests are a great tool to validate your application. It is easy to create them for your main application, but it might be harder to create a UI test for your share extension. This can be just as easy as your main application with some simple steps.

UI Test steps

A UI test for testing the extension needs a few extra steps.

  1. Launch an external app, for example, Safari
  2. Navigate to some sharable content
  3. Open the share sheet
  4. Enable the extension for your application
  5. Open the extension for your application

After that, you should be able to interact with your extension.

Share extension UI Test example

To make this really easy, I’ve written an extension which can be found here:

This results in just a few lines of code before you can start interacting with your share extension:

// start main app to make sure the Share Extension exists.
let mainApp = XCUIApplication()

let safariApp = openSafari(with: URL(string: "")!)
openShareExtension(name: "Example Share Extension", in: safariApp)

This video will show you how a certain UI Test run would look:

This video is directly recorded from the simulator using simctl. Read more about it here.


Do you know everything about Swift?

You don't need to master everything, but staying informed is crucial. Join our community of 17,905 developers and stay ahead of the curve:

Featured SwiftLee Jobs

Find your next Swift career step at world-class companies with impressive apps by joining the SwiftLee Talent Collective. I'll match engineers in my collective with exciting app development companies. SwiftLee Jobs