Search code examples
iosios-simulatorappium-iosappium-desktop

IOS Simulator UUID, chosen by Appium does not exist on my desktop


I am trying to use Appium to do some testing on my IOS app. (This is my first time using it). I am using Appium Desktop to start Appium. Here is my capability list:

{
  "platformName": "iOS",
  "platformVersion": "11.2",
  "deviceName": "iPhone 7 Plus",
  "automationName": "XCUITest",
  "app": "/Users/me/Library/Developer/Xcode/DerivedData/MyApp/Build/Products/Debug-iphoneos/MyApp.app",
  "noReset": true,
  "showIOSLog": true
}

When I start a session, In the logs, I see that Appium is starting a IOS simulator with UUID B068A9B1-62CF-4E28-A9DA-E7C7C8EEF8DC. Here is the relevant log lines:

[debug] [iOSSim] The count of running Simulator UI client instances is 0

[iOSSim] Booting Simulator with UDID B068A9B1-62CF-4E28-A9DA-E7C7C8EEF8DC...

[iOSSim] Starting Simulator UI with command: open -Fn /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID B068A9B1-62CF-4E28-A9DA-E7C7C8EEF8DC -ConnectHardwareKeyboard 1

[iOSSim] Simulator with UDID B068A9B1-62CF-4E28-A9DA-E7C7C8EEF8DC booted in 67 seconds

According to this log, UUID is given as B068A9B1-62CF-4E28-A9DA-E7C7C8EEF8DC . However when I type in a terminal window:

xcrun simctl list

The list I got is as follows:

== Devices ==
-- iOS 11.2 --
    iPhone 5s (46A12989-6F7E-459D-A566-347883681981) (Shutdown)
    iPhone 6 (429F8EB3-E8C6-4EE6-8313-17E6FBE98BB2) (Shutdown)
    iPhone 6 Plus (2EB7ADC5-47F7-46DD-92A2-043D8CD36764) (Shutdown)
    iPhone 6s (FDE95542-48A8-4C7E-A983-84D0747AF5B6) (Shutdown)
    iPhone 6s Plus (25008979-F6E4-42F6-B5A0-28ED4D872E85) (Shutdown)
    iPhone 7 (DBD96A0C-B1D7-4FA6-8DE4-CBE741859341) (Shutdown)
    iPhone 7 Plus (2D65A1C5-CA42-4808-B60A-C7805DFE0D02) (Shutdown)
    iPhone 8 (781339FA-7397-455C-8EB1-5D116381ACD6) (Shutdown)
    iPhone 8 Plus (22C4CA50-57CD-4D03-A9DB-5A7E8CED337C) (Shutdown)
    iPhone SE (EA7C6EE8-D177-4FA0-AD6C-2AC3FA1ABB74) (Shutdown)
    iPhone X (359B77C6-0559-4FF6-83E3-E815A5EBA1C5) (Booted)
    iPad Air (3DFF4AE2-3867-4E18-92D6-6086B5909FCC) (Shutdown)
    iPad Air 2 (AED4735B-8771-494E-9F80-A2A8F8EE09E8) (Shutdown)
    iPad (5th generation) (9094F6EE-4190-4028-9596-EAC994CEC44E) (Shutdown)
    iPad Pro (9.7-inch) (59A04DFC-48BC-4302-A824-0F6F2C818650) (Shutdown)
    iPad Pro (12.9-inch) (42446801-ED81-4A7E-992B-FC1DB96CCEFA) (Shutdown)
    iPad Pro (12.9-inch) (2nd generation) (1C95389C-3508-4998-A770-AC02DE6C6797) (Shutdown)
    iPad Pro (10.5-inch) (7FD67BA5-C826-4CB5-BA7B-BB1F1B7B0B0F) (Shutdown)
-- tvOS 11.2 --
    Apple TV (AC8B4DA3-286E-4507-8FBB-D358EAC8E607) (Shutdown)
    Apple TV 4K (4E8B99D7-D07B-4ECF-8E07-EAD5D799929C) (Shutdown)
    Apple TV 4K (at 1080p) (9510E577-B71D-4D24-BA10-0B5E079F4DAB) (Shutdown)
-- watchOS 4.2 --
    Apple Watch - 38mm (36E860BC-4DF3-413C-90C4-71FB2813B13D) (Shutdown)
    Apple Watch - 42mm (A8408CA5-99C3-4F0E-B571-7509703B2FE0) (Shutdown)
    Apple Watch Series 2 - 38mm (19BAAC48-A69C-4D5B-A921-7008C76CA3C5) (Shutdown)
    Apple Watch Series 2 - 42mm (0CA6DA87-4BBE-44AF-8B82-C652CA3D80CC) (Shutdown)
    Apple Watch Series 3 - 38mm (5515A207-88C3-4752-82A2-E99F5B7C8532) (Shutdown)
    Apple Watch Series 3 - 42mm (9532F5BC-DAA0-4CC0-A544-D26A6EC9F9AD) (Shutdown)
== Device Pairs ==
AE5E48FE-EFBD-4FF9-851E-861ED3FF2002 (active, disconnected)
    Watch: Apple Watch Series 2 - 38mm (19BAAC48-A69C-4D5B-A921-7008C76CA3C5) (Shutdown)
    Phone: iPhone 7 (DBD96A0C-B1D7-4FA6-8DE4-CBE741859341) (Shutdown)
64C97089-7FB9-4CC3-986C-7B3F56D982CC (active, disconnected)
    Watch: Apple Watch Series 2 - 42mm (0CA6DA87-4BBE-44AF-8B82-C652CA3D80CC) (Shutdown)
    Phone: iPhone 7 Plus (2D65A1C5-CA42-4808-B60A-C7805DFE0D02) (Shutdown)
10141E88-D1D8-4BF7-A665-59A6EB10F8A9 (active, disconnected)
    Watch: Apple Watch Series 3 - 38mm (5515A207-88C3-4752-82A2-E99F5B7C8532) (Shutdown)
    Phone: iPhone 8 (781339FA-7397-455C-8EB1-5D116381ACD6) (Shutdown)
9ED5EC88-726E-46CE-A7C9-5849613ABAFA (active, disconnected)
    Watch: Apple Watch Series 3 - 42mm (9532F5BC-DAA0-4CC0-A544-D26A6EC9F9AD) (Shutdown)
    Phone: iPhone 8 Plus (22C4CA50-57CD-4D03-A9DB-5A7E8CED337C) (Shutdown)

As you can see, there is no such device with matching UUID.

More interestingly, Appium thinks that my app is already installed onto this device, in the logs:

[debug] [XCUITest] App 'com.****.**********' is already installed. No need to reinstall.

However, when I look at the opened simulator screen, I can not see my app at all.

My questions are:

  1. How does Appium decide which device to use? (I tried to give different phone models but Appium insists on picking up iPhone X for some reason and does not respect my choices.)
  2. If device with matching UUID does NOT exist, how come Appium thinks that my app is already installed?
  3. If device with matching UUID does not exits, how does this simulator gets started ?

Any insight would be appreciated. Thank you.


Solution

  • This turned out to be simpler than I initially thought. I want to share what I have found here so that others, who may get bitten by the same mistake, would not waste their time.

    While I was trying to get Appium working, as a solution to one of the hurdles I had faced with, someone suggested to start Appium with sudo. So I had been using:

    sudo ./Appium 
    

    to start it.

    This is obviously wrong.! Do Not start Appium with sudo!

    If you don't, it works like magic.

    Lessons learnt from this experience:

    1. Looks like xcode had different UUID for simulator devices for different users. When you think about it, it makes sense.
    2. This also explains why Appium does not select the device I give as a capability.
    3. There is no magic in computer world. There are just misunderstandings.