How to Archive for iOS simulator?

Usually you won't archive iOS app for simulator use, unless... your client suddenly tell you that his iPhone is broken and undergoing repair, but hey he has a Mac that can run Xcode and also iOS simulator and he still want to test your app! Of course you wouldn't want to send the full source code over before client paid you in full. So how do you send him the build to test without sending the source code over?

As per Apple documentation,

Applications built for the simulator cannot be archived

Fortunately, there's a way to send the compiled build so your client can run the compiled build without him having to build from the source code.

1. Locate your iOS Simulator folder in Finder

Open terminal, and run instruments -s devices , you will see a list of simulator device and their UDID inside square brackets.

Simulator list

I will be using iPhone SE (iOS 11.2) as the selected simulator device for this tutorial, the corresponding UDID for it is "18BF1A2D-15C2-40E2-80A6-0CB87D2B56D4".

The folder containing the simulator data will be located at
~/Library/Developer/CoreSimulator/Devices/[Simulator UDID] .
In Finder, press Command + Shift + G, and enter the path.

Simulator data path

2. Build your app and locate its data folder

Before building your app, I recommend deleting all other existing app you have built previously on the simulator so that you can find your app data folder easier in the next step.

Proceed to build your app as usual in Xcode, my app name is "exampleApp" for this tutorial.

After building, open Finder and proceed to the simulator folder path
~/Library/Developer/CoreSimulator/Devices/[Simulator UDID]

In your simulator folder, locate to data/Containers/Bundle/Application , here you will see the folder for the apps you have built in the simulator.

App data folder

To find the folder containing your app, you have to open one by one until you found your app name inside, like this :

Correct app folder

Compress the app and send the zip file to your client.

Compress selected app

For easier instruction, ask your client to unzip the compressed file at Desktop folder.

3. Instruction for clients

Below are the instruction for clients:
Open Xcode, then start iOS Simulator by choosing Xcode > Open Developer Tool > Simulator.

Open Simulator from Xcode

In Simulator, select the device you want.

Select simulator device

Open "Terminal" (In spotlight, type 'Terminal' and press enter)

Open Terminal

type cd ~/Desktop and press Enter

type instruments -s devices and press Enter, then choose the simulator device you selected earlier and select the UDID string between the square brackets, right click and copy.

Copy simulator path picture

type xcrun simctl install [UDID] [App name] , replace the [UDID] with the string you copied just now, replace App name with the file name of the app (with '.app' at behind). It should look similar to this : xcrun simctl install 18BF1A2D-15C2-40E2-80A6-0CB87D2B56D4 .

The app should install on the simulator successfully, rejoice!

Send this link to your client for reference if needed :