First things first, you should see if this problem is specific to your app. Try putting the relevant bits of code into a small test project to see if the problem reproduces there.
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"