Cleaning up the iPhone simulator

前端 未结 15 1315
情话喂你
情话喂你 2020-11-30 17:21

Is there a straightforward way to clean up the directory where xcode deploys an app when building for the iPhone simulator? I have a sqlite database that gets copied into t

相关标签:
15条回答
  • 2020-11-30 18:17

    for Xcode >= 6

    xcrun simctl list | grep -oh '[A-Z0-9]\{8\}-[A-Z0-9]\{4\}-[A-Z0-9]\{4\}-[A-Z0-9]\{4\}-[A-Z0-9]\{12\}' | xargs -n1 xcrun simctl erase
    
    0 讨论(0)
  • 2020-11-30 18:19

    What you are really trying to do is to clear out your database, if you've changed the schema. One way to do this, and it would make you happier in the long run when you start shipping version 2.0, 3.0, etc. of your app, is to check the version of your sqlite table, and if it has changed, then discard the old file and use the one in your bundle.

    Finding a way to clean up the Simulator won't help the real world problem of how to clean up a customer's iPhone when you ship a new version with a new schema.

    For extra points, after determining that you have encountered an old schema, you may want to copy the new database over without destroying the old one, and load any interesting data out of the old database, into the new one. Then blow away the old database. That way you can preserve your user's additions to the database.

    0 讨论(0)
  • 2020-11-30 18:20

    As of Xcode 6, you can do this from the command line with: xcrun simctl erase

    Also, the iOS Simulator app (both the Xcode 6 version and older versions) has a menu item called "Reset Content and Settings" that can be used to erase the currently booted device.

    0 讨论(0)
提交回复
热议问题