Is there a way to automatically sign into a Apple ID Account for iCloud use inside of simulator?

Viewed 172

I know that you can sign in manually in the settings app on each simulator, wanted to know if there's some way to do this automatically. I've been using Fastlane to take screenshots. Now that I have an app that requires iCloud I'd have to go and manually sign in to an Apple ID account for each simulator, and language.

I've tried:

  • Looking through simulator settings and Xcode settings, there appears to be no such option for any sort of "default" account.

  • Searched Google/Stack overflow. I can't find anything relating to this subject aside from an apparent sign-on issue with Xcode 11 beta.

  • From Caleb, Tried copying simulator preference files over from one simulator to the other, it appears to just overwrite these when loading up the new one.

Update

I was not able to find a solution. I tried both of the below answers and was not able to get either working. I'll update this post if I figure out a way :)

2 Answers

I'm not sure what versions you are using but as of MacOS 10.13 and Xcode 9.1 there is no way to set an Apple ID a default and I can't find anything suggesting that this has been added in later versions. Sorry!

According to You don’t need GUI — how to control iOS Simulator from command line, there's a preferences file for each simulator located at:

$HOME/Library/Developer/CoreSimulator/Devices/$SIMULATOR_ID/data/Library/Preferences/.GlobalPreferences

You could set up a simulator manually with whatever settings you need, then go grab that file and copy it to the corresponding location for each of your other simulators. I haven't checked that the iCloud account settings are in there, but you can look and see. Note that it's a binary file, so you'll need to use plutil to convert it to a human-readable property list if you want to look inside. The linked article gives some examples.

Related