If you’re building a standard App Store app then the only supported way to get the IMEI is to ask the user to enter it.
If you’re deploying to managed environments you have other options (specifically, MDM allows you to get the device’s IMEI, and you could integrate your app with the MDM server).
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"