Search code examples
ioscloudkit

Anyway to check CloudKit app runs as developer or production mode?


In developer mode I want to skip populating local database from bundle, but I need it when apps run in production mode. Any way to check it?


Solution

  • I think there are a couple of solutions to accomplish this:

    1. Test with #if DEBUG since you probably always your development environment in debug mode and your production environment in release mode

    2. create a settings recordType and add a field named environment. On development it will contain the value development and on production it will contain the value production. Then always first read that record (and cache it in NSUserDefaults)

    3. try to do a modification to the data structure. On development that is possible, on production you will get an error.

    I think option 2 is the cleanest and most robust way. Number 1 is easy and probably good enough. Number 3 is a dirty solution.