Multiple iOS simulators available for single OS + device configurations

ios
xcode
xcodebuild
simulator

#1

EDIT Jan 16 2017: We no longer recommend using UUIDs to start simulators. The OS X image has been updated to resolve the underlying issue, and using UUIDs is no longer necessary. Please check out this post for examples of how to choose the simulators by name.

Hey,

We’ve seen a couple of users complain about failing builds because xcodebuild sees multiple iOS simulators.

Most likely your call to xcodebuild looks something like this: xcodebuild ... -destination 'platform=iOS Simulator,OS=10.0,name=iPhone 6' clean build test

and you’ll see errors like this:

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
		{ platform:iOS Simulator, OS:10.0, name:iPhone 6 }

	The requested device could not be found because multiple devices matched the request.

	Available destinations for the "Amigo" scheme:
		{ platform:iOS Simulator, id:42D87249-99F2-4BC1-9180-317D268C46F7, OS:10.0, name:iPad Air }
		{ platform:iOS Simulator, id:72F9B9E8-DC05-4450-B030-407D4B0968D9, OS:10.0, name:iPad Air }
		{ platform:iOS Simulator, id:A77D8F4F-6D72-4DC1-BC34-BD7780F6B675, OS:10.0, name:iPad Air }
		{ platform:iOS Simulator, id:AD005E41-F7E6-4C5F-B3B1-6C980E834739, OS:10.0, name:iPad Air }
		{ platform:iOS Simulator, id:B9257F59-88B3-421D-B1F2-2BD92F0858D0, OS:10.0, name:iPad Air }
		{ platform:iOS Simulator, id:3F3B8CE6-B349-4397-8A31-4262585B3A7F, OS:10.0, name:iPad Air 2 }
		{ platform:iOS Simulator, id:6E2B1E19-6466-4328-917C-16019130FDE8, OS:10.0, name:iPad Air 2 }
		{ platform:iOS Simulator, id:A141F49D-F20A-49B3-ACBF-A97F9FFB9B89, OS:10.0, name:iPad Air 2 }
		{ platform:iOS Simulator, id:AC291080-8EFE-4095-8C55-B1E952EFFC36, OS:10.0, name:iPad Air 2 }
		{ platform:iOS Simulator, id:F9C94E2A-F080-4AB0-93D6-A41135919D8E, OS:10.0, name:iPad Pro (9.7 inch) }
		{ platform:iOS Simulator, id:BF8D8AD2-6A96-4A62-8059-A836738BB873, OS:10.0, name:iPad Pro (12.9 inch) }
		{ platform:iOS Simulator, id:3184CA90-B2D4-4407-BA93-7EEAD7F88008, OS:10.0, name:iPad Retina }
		{ platform:iOS Simulator, id:399AEF36-5560-4C4A-AE61-03F0A81555D0, OS:10.0, name:iPad Retina }
		{ platform:iOS Simulator, id:A1EC86BA-49AB-414B-9C27-2D0F26A34A81, OS:10.0, name:iPad Retina }
		{ platform:iOS Simulator, id:A70FE3C7-756F-44BF-BE46-68663FAE2EE3, OS:10.0, name:iPad Retina }
		{ platform:iOS Simulator, id:D56EBD40-B853-4D56-B482-D4C40E69A3FC, OS:10.0, name:iPad Retina }
		{ platform:iOS Simulator, id:075FB8BA-F088-4A16-89CF-4EA36BC25E7A, OS:10.0, name:iPhone 5 }
		{ platform:iOS Simulator, id:24F6F5A0-343E-4C64-9F4C-B50D88F5E99E, OS:10.0, name:iPhone 5 }
		{ platform:iOS Simulator, id:85D8FE66-1208-4478-811C-7BD1AA3B33CA, OS:10.0, name:iPhone 5 }
		{ platform:iOS Simulator, id:A11ABCA4-5140-4728-B071-632A834AEC76, OS:10.0, name:iPhone 5 }
		{ platform:iOS Simulator, id:C5C8EA0E-F5A8-4AF8-BBAA-385B61026A5E, OS:10.0, name:iPhone 5 }
		{ platform:iOS Simulator, id:1FB033A8-440D-45F3-B95D-03E4E38B51DF, OS:10.0, name:iPhone 5s }
		{ platform:iOS Simulator, id:3011ED5C-C63A-42E6-9D91-82A39DE4AD06, OS:10.0, name:iPhone 5s }
		{ platform:iOS Simulator, id:45BFA4E8-C0A9-4A04-9CD0-4449FE4CF40B, OS:10.0, name:iPhone 5s }
		{ platform:iOS Simulator, id:49DAC9E5-C129-497D-853E-D93BC4BB8A10, OS:10.0, name:iPhone 5s }
		{ platform:iOS Simulator, id:6C9EA8B9-291B-46EB-B25F-3433372E5AF3, OS:10.0, name:iPhone 5s }
		{ platform:iOS Simulator, id:153C11BB-3CA0-4FFB-8D8C-BE2F11117254, OS:10.0, name:iPhone 6 }
		{ platform:iOS Simulator, id:33D34EBA-703E-4A82-8838-BE75171492E1, OS:10.0, name:iPhone 6 }
		{ platform:iOS Simulator, id:53600017-30F1-428A-A16A-25C6CEDBD849, OS:10.0, name:iPhone 6 }
		{ platform:iOS Simulator, id:547B1B63-3F66-4E5B-8001-F78F2F1CDEA7, OS:10.0, name:iPhone 6 }
		{ platform:iOS Simulator, id:65AAA024-64D5-40B9-A122-8872E3F52EC4, OS:10.0, name:iPhone 6 }
		{ platform:iOS Simulator, id:321D1CF5-2514-4897-8B09-C133602F6DB5, OS:10.0, name:iPhone 6 Plus }
		{ platform:iOS Simulator, id:5525775C-A351-4986-9BF4-144A84E253AA, OS:10.0, name:iPhone 6 Plus }
		{ platform:iOS Simulator, id:8925E024-A809-4391-ACA4-838F2A9D8D8D, OS:10.0, name:iPhone 6 Plus }
		{ platform:iOS Simulator, id:C63728B8-89B5-4FFB-8B6E-174A2F85B47F, OS:10.0, name:iPhone 6 Plus }
		{ platform:iOS Simulator, id:DFB14113-4697-4E2D-AD3F-B4FBA4B62969, OS:10.0, name:iPhone 6 Plus }
		{ platform:iOS Simulator, id:5F273E3F-7B26-436D-A8EB-36460917614D, OS:10.0, name:iPhone 6s }
		{ platform:iOS Simulator, id:763DC427-F2C5-4AA4-989F-2CA944FA8F04, OS:10.0, name:iPhone 6s }
		{ platform:iOS Simulator, id:E8DD285C-51EE-4DB5-B326-7E927686EC36, OS:10.0, name:iPhone 6s }
		{ platform:iOS Simulator, id:F08BA729-6AD2-42DF-A210-34DC8D990011, OS:10.0, name:iPhone 6s }
		{ platform:iOS Simulator, id:011805C3-BB7A-4785-A313-D7AD2AF6DE49, OS:10.0, name:iPhone 6s Plus }
		{ platform:iOS Simulator, id:019CFBB0-0086-44A7-AA41-D39182D9CE01, OS:10.0, name:iPhone 6s Plus }
		{ platform:iOS Simulator, id:34676811-0CF8-4D4F-B460-E61A6627B927, OS:10.0, name:iPhone 6s Plus }
		{ platform:iOS Simulator, id:A310FC97-435A-4026-AF85-F1216F856BA5, OS:10.0, name:iPhone 6s Plus }
		{ platform:iOS Simulator, id:2D96E690-BFB5-44D5-8B22-31D9C57EDADF, OS:10.0, name:iPhone 7 }
		{ platform:iOS Simulator, id:D4155E82-B930-450B-AFC7-F4800669EC65, OS:10.0, name:iPhone 7 Plus }
		{ platform:iOS Simulator, id:84A11478-B7D4-4968-A626-E27CE7372148, OS:10.0, name:iPhone SE }

This is a regression in our OS X image that we will fix as soon as we possibly can, but in the meantime you can use this workaround:

xcodebuild ... -destination 'id=DFB14113-4697-4E2D-AD3F-B4FBA4B62969' clean build test

You should basically pick one of the UUIDs out of the list and simply pass that to the xcodebuild command.

Once the new image version is deployed I will update this post, so you might want to subscribe to it so that you’ll get an E-Mail notification.

Please excuse the inconvenience,
Constantin


Xcodebuild: error: Unable to find a destination matching the provided destination specifier: { platform:iOS Simulator, OS:latest, name:iPhone 6 } The requested device could not be found because multiple devices matched the request
Multiple simulators with the same name in xcode 10.0.0 image
#2

What’s the ETA for this release? It’s a bit time-consuming to go through all projects to add this ID :slight_smile:


#3

We are aiming for next week but we don’t give any ETAs for these things.

Sorry for the inconvenience :frowning:


#4

This broke our builds. Pls rollback or whatever, can you fix it today?


#5

Hi Constantin,

I’m sorry but I don’t think this is really an acceptable answer. For issues linked to Xcode or third-parties breaking builds, I understand that there is a delay in publishing updates.

But in that case, this is a regression and it breaks all our iOS builds. Regressions should be fixed ASAP.

We pay CircleCI for automating our CI and not having to deal with maintaining a Jenkins server all the time etc., but lately Circle has been more worry and consuming us a lot of time, than a helpful resource.

That being said, I appreciate your time and help dealing with all these issues.

Thanks.


#6

We understand why this is an issue and apologize for any disruption in your workflow. We’re working as quickly as possible to provide a fix, and will update you here as soon as we have one. Thank you so much for your patience.


#7

I can just fully agree with @bvrlt. :expressionless:

At least we already having that issue since 4 days now… we paying you for not configurating our own CI and now we get as answer we should configure our build progress for a short time and then put our old configure back after everything runs well again…


#8

UPDATE: we have been able to start tests using the above workaround by specifying simulator id:
-destination ‘id=2D96E690-BFB5-44D5-8B22-31D9C57EDADF’

This issue blocks our usage of CircleCI. None of our tests are able to start. Builds are marked as Failed when they should have “Unable to run” or some other status.

Thank you for looking into this!


#9

So, am I the only one that cannot make this work again, even with the partial solution they are giving us? This issue is causing me some troubles with my client… is there any update?


#10

Pls. How long are you going to leave your system broken?


#11

So, this is a little bit involved, but I do have a general purpose solution that will fix this for everyone. We already had this code in place before this incident and it prevented us from having the issues that you guys are currently experiencing as a result. Our builds use rake and thus the following code is written in Ruby, however, most of it just wraps shell commands, so it should be very easy to extract and use in a shell script or whatever else you are using to do your builds.

# Returns a list of all known devices on the host machine.
def get_known_devices
  known_devices, stderr, status = Open3.capture3("xcrun instruments -s devices \
    | sed '1 d' \
    | grep -i 'Simulator' \
    | sed -e 's/Simulator//g' -e 's/\\((\\)\\(.*inch\\)\\()\\)/\\2/g' \
    | grep -v '+' \
    | tr -d '])' \
    | sort -b -t '(' -k 1,1 -k2,2n \
    | column -ts '[('")

  return known_devices
end

# Returns a UUID for the specified device model, which can
# be used to launch the simulator.
def get_uuid_for_device_model(device_model, device_list)
  devices = device_list || get_known_devices()

  line_number, stderr, status = Open3.capture3("echo '#{devices}' \
    | awk -F ' {2,}' '{print $1}' \
    | grep -Fnx '#{device_model}' \
    | tail -n 1 \
    | awk -F ':' '{print $1}'")

  device_uuid, stderr, status = Open3.capture3("echo '#{devices}' \
    | awk -F ' {2,}' 'NR==#{line_number.to_i} {print $3}'")

  device_uuid = device_uuid.gsub(/\s+/, ' ').strip

  if device_uuid.to_s.empty?
    error "Unable to find a UUID for device model '#{device_model}'\n\n#{devices}"
  end

  return device_uuid
end

Then, to use those two helper methods to retrieve the device UUID for the model of your choice:

# This gets the UUID for the specified model targeting the instance with the newest iOS version.
device_uuid = get_uuid_for_device_model('iPhone 6', get_known_devices())

Lastly, in the call to xcodebuild, include the following for the destination:

-destination 'platform=iOS Simulator,id=#{device_uuid}'

The device list is nicely formatted, as we also output it before the build to see what devices are available. I hope that this helps you guys until things are worked out on CircleCI’s end.


#12

Any update on this? Every build is failing for me.


#13

Hey everyone,

For now you can add this to your dependencies step in your circle.yml:

dependencies:
  pre:
    - snapshot reset_simulators

I will update this thread once a fixed image version has been shipped to production.

Sorry for the inconvenience.

Best,
Constantin


#14

When adding this command, I get the following output:

snapshot reset_simulators
Are you sure? All your simulators will be DELETED and new ones will be created!
(y/n)

command snapshot reset_simulators took more than 10 minutes since last output

Is there an argument I can pass to snapshot in order to automatically respond with a yes?


#15

You could use the yes command @weissazool . . . but yeah… this bug bothers me right now way to long and then we got even commands that just pause the whole build and burns the build time… good that I read your answer xD normally I just had wait till my smartphone send me a push notification that it works, so I saved some of the build minutes…

here is the command that works as workaround for the workaround:

 dependencies:
  pre:
    - yes | snapshot reset_simulators

edit: it also takes ~12 Seconds per Build extra.


#16

You can set the SNAPSHOT_FORCE_DELETE environment variable to force a reset without any prompt:

dependencies:
  pre:
    - SNAPSHOT_FORCE_DELETE=1 snapshot reset_simulators

#17

Perfect, thanks. The additional build time is unfortunate, but I’m sure we will all get refunded for it, right @KunalJain? :slight_smile:


#18

Not work for me.

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
		{ platform:iOS Simulator, OS:latest, name:iPhone 6 }

	The requested device could not be found because no available devices matched the request.

	Available destinations for the "Project" scheme:
		{ platform:iOS Simulator, id:15B76184-3FD2-4189-8010-A04F94960C61, OS:10.0, name:iPad Air }
		{ platform:iOS Simulator, id:4840FDAC-9004-4A2C-9A19-C0C4087D2A51, OS:10.0, name:iPad Air 2 }
		{ platform:iOS Simulator, id:598636A3-7454-4C8B-910C-C47B054E39A0, OS:10.0, name:iPad Pro (9.7-inch) }
		{ platform:iOS Simulator, id:06EC7C40-D977-4B6A-A49E-B4F86916024C, OS:10.0, name:iPad Pro (12.9-inch) }
		{ platform:iOS Simulator, id:AE3AE2A5-03AE-4853-827D-073E661F8FA6, OS:10.0, name:iPad Retina }
		{ platform:iOS Simulator, id:C1C9B550-1EE2-4403-95D9-6532552E9A38, OS:10.0, name:iPhone 5 }
		{ platform:iOS Simulator, id:B2001920-E6F7-4536-9DCF-40081F3A2AC8, OS:10.0, name:iPhone 5s }
		{ platform:iOS Simulator, id:1D314116-8C32-47FB-AC1D-D4A34F80A64D, OS:10.0, name:iPhone 6 }
		{ platform:iOS Simulator, id:D1C4B515-BDE1-40A6-91F0-C180735D424E, OS:10.0, name:iPhone 6 Plus }
		{ platform:iOS Simulator, id:F5C9B910-C68A-466D-85D9-F29A5B72A549, OS:10.0, name:iPhone 6s }
		{ platform:iOS Simulator, id:677CCC17-F3B1-4D14-8C26-4D426BC88AC3, OS:10.0, name:iPhone 6s Plus }
		{ platform:iOS Simulator, id:3E98033C-EC9E-4E38-9D04-04E721CA189A, OS:10.0, name:iPhone 7 }
		{ platform:iOS Simulator, id:FD49928E-34F2-4E77-8008-07D87669C4CF, OS:10.0, name:iPhone 7 Plus }
		{ platform:iOS Simulator, id:CD7619A0-CFC8-4452-8222-64508BF35D83, OS:10.0, name:iPhone SE }

	Ineligible destinations for the "Project" scheme:
		{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Generic iOS Device }
		{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Generic iOS Simulator Device }

export LC_CTYPE="en_US.UTF-8"
set -o pipefail && xcodebuild -project './Project.xcodeproj' -scheme 'Project' clean build test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= PROVISIONING_PROFILE= | tee $CIRCLE_ARTIFACTS/xcode_raw.log | xcpretty --color --report junit --output $CIRCLE_TEST_REPORTS/xcode/results.xml
 returned exit code 70

#19

Hey Jan,

Please open a support ticket with a link to your post in this thread and I will take care of it!!

Best,
Constantin


#20

Hey @anon47539524, any update on the original issue? :slight_smile: