Cleaning up the iPhone simulator

前端 未结 15 1316
情话喂你
情话喂你 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:05

    Clear Xcode Cache;

    Command+Option+Shift+K

    Command+Shift+K

    (Use both of them because they have different functionality)

    Clear Derived Data content ;

    Menu Bar -> Window -> Organizer -> Projects -> Select Your Project

    Right Pane shows the name of folder and also delete button at the right side allows you to delete all derived data contents.

    Clear Simulator Cache;

    Menu Bar -> iOS Simulator -> Reset Contents And Settings

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

    As I was explaining in a comment under the validated answer:

    I was testing adding and removing calendar subscriptions. On a real device, you can remove a calendar subscription in Settings, Accounts but this menu does not exist in iOS Simulator and I did not want to reset the whole simulator.

    So I ended up locally versioning my Device folder with git and perform the following commands to remove a calendar subscription after I added it:

    $ git reset HEAD --hard
    $ git clean -f
    

    So the steps are:

    1. Install your application on the iOS Simulator and do what you have to do
    2. Identify your device in ~/Library/Developer/CoreSimulator/Devices/ and do a cd to it, then git init to create a git repository
    3. Once you want to save the state, perform git commit -a "Message"
    4. Do whatever changes the settings (ex: adding a calendar subscription) and perform your tests
    5. Shutdown the simulator
    6. Do git reset --hard HEAD
    7. Start the simulator, all changes done after git commit are gone.
    0 讨论(0)
  • 2020-11-30 18:12

    If you are using Xcode 9 -> Menubar -> Hardware -> Erase All Content and Settings

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

    This works with 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 -I{} xcrun simctl erase {}
    

    For .bash_profile

    alias cleansim="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 -I{} xcrun simctl erase {}"
    
    0 讨论(0)
  • 2020-11-30 18:15

    The way I do this is to simply click and hold on the icon for my app in the simulator--then when it starts to wiggle click the black and white (x). A message will pop up asking whether you really want to delete and you just click yes. The next time you build and deploy your app it will use the new sqlite db without a hitch and you don't have to go muck around in the filesystem.

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

    After iOS 5 on Mac OS X Lion, you can try:

    1. Create a script called RemoveSimulatorApps.command that contains:
      rm -rf "$HOME/Library/Application Support/iPhone Simulator/5.0/Applications/*"
      
    2. Save this script to a directory in your PATH.
    3. Make the file executable, such as:
      chmod +x RemoveSimulatorApps.command

    Assumptions

    • You may want to invoke this from a keyboard favorites buttons, such as on a Logitech or Microsoft keyboard with programmable keys (hence, saving it as a .command file instead of say, .sh)
    • You are okay with blowing away everything in the iOS simulator (ideal if you're just actively working on one app)
    • All the notes from others apply about being a good upgradable app etc. (I personally found this useful nonetheless b/c I have development mode switches that reload a database in a specific state I was trying to do some consistent robustness/error handling on)
    0 讨论(0)
提交回复
热议问题