3

I'm finding that the UUID I get is different depending on whether the app is directly installed by xcode (which I do during development) or through testflight.

let uuidstring = UIDevice.current.identifierForVendor!.uuidString

Is it possible to get a UUID that is the same in both cases?

Ideally a UUID that is truly a unique device identifier, and doesn't change if the app is removed and added, which seems to change the UUID currently.

Ian
  • 1,427
  • 1
  • 15
  • 27
  • 2
    You can create your own UUID and store it in the keychain. `identifierForVendor` can and will change. It is not intended to provide a lifetime-unique device identifier – Paulw11 Nov 22 '16 at 23:36
  • Apple intentionally does not provide a unique device identifier. Each one that people have tried to sneak in, Apple has intentionally broken (try fetching the MAC address on an iPhone). You are not allowed to track devices. – Rob Napier Nov 23 '16 at 03:54

1 Answers1

3

As the documentation says

The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them.

This is the reason why reinstalls will change the UUID for an App.

Ivan Nesterenko
  • 939
  • 1
  • 12
  • 23
  • 2
    That's a fair point, but does that explain why the TestFlight version produces a different UUID to the directly installed version? That's my main question. I can flip flop between two stable uuids by changing the install method – Ian Nov 22 '16 at 23:59
  • 2
    You will also see a change in `identifierForVendor` between Xcode installs and App store installs. A testflight build is basically an app store install, so it is a different identifier. – Paulw11 Nov 23 '16 at 00:00
  • 1
    UUID and UDID are different things: https://stackoverflow.com/questions/21872233/differences-between-udid-and-uuid – HotFudgeSunday Oct 05 '17 at 15:24