How to clean the sandbox every time I run the applications? - ios

I am wondering if I could clean up sandbox everytime I run the application. I don't want to clean and rebuild every time since it takes long time.

Delete the app off the device/simulator. That deletes the entire sandbox environment. Deleting off the target device/sim is independent of doing a clean. Clean deletes compiled object files and the app from the Xcode build directory, which is separate from deleting it from the device/sim.

Clean and rebuild doesn't delete the application data stored on the simulator by the previous runs of the app. Clean and rebuild only cleans away and rebuilds the executable before sending it to the device.
To delete the sandbox app data, you can select "Reset contents and settings of simulator" in Simulator menu, or properly delete the app from the simulator.
If you want to clean the simulator stored data more easily, there are a few helpers:
http://simpholders.com iOS app that creates a system tray icon that allows you to wipe simulator data per app (or uninstall apps entirely)
http://swinden.com/ios-simulator-folders-alfred-workflow Alfred workflow which gives you the same kind of options as the above
http://markstruzinski.com/blog/2012/05/02/quick-wipe-of-ios-simulator-using-alfred Another Alfred workflow, simpler than the previous

i don't know if you found the solution but i'll share what I've created:
but be warned this will always wipe your iOS Simulator apps
At first you need to this bash script Gist: Clean iOS Simulator Apps
and then you need to configure a behaviour in the Xcode like I did in this screenshot. When the run finishes I've set the script to be executed.
If you need to clean a specific app you should create a clean script for each app you need to clean, it will look like this:
pkill -9 -fi simulator 2>/dev/null
_WD="$HOME/Library/Application Support/iPhone Simulator"
find "$_WD" -iname "TheApp.app" | while read l; do
f=$(dirname "$l")
rm -rf "$f"
unset f
done
unset _WD
in the find command you will change the parameter "TheApp.app" to the app you need to remove.
(Not tested).

Create a directory called 'dev' and store everything in that (as if it was your documents folder). At launch, delete it if it exists?

Related

Xcode 10.2: Internal error when debugging app

When I tried to run my app it could not launch on simulator or device, while throwing error.
Could not Launch "Carepilot" internal error
So I try Edit
sheme -> run -> info -> Debug executable
to make sure the Debug executable option is not checked, debug mode is disabled there, but this can't be debugged.
Anyone encountered same problem?
I'm not sure exactly why you're seeing that, but here are some basic debugging steps to try.
First, turn debugging back on, you'll want that. Any solution that doesn't let you debug is useless.
Second, quit Xcode and and quit the Simulator. Sometimes things get in a funky state. Relaunch Xcode and try again.
If it still happens, reboot. Try again.
If it still happens, try it with a new project to rule out any issues with yours.
If it still happens, go to Xcode>Preferences…>Locations`, do you have Xcode 10.2 (10E125) command line tools installed and selected? That's what you should see.
If that's not it, go to the Terminal and enter xcode-select -p. Does the path displayed point to the Contents/Developer directory under your Xcode app? If not, set that using sudo xcode-select -s /Applications/Xcode.app/Contents/Developer (substituting your Xcode app's name if necessary).
Unfortunately, "internal errors" in Xcode occur for various reasons and don't provide any useful information. If all else fails, you may need to try reinstalling.
I had this exact same issue after an Xcode crash. Turns out that the executable no longer existed after the crash, but Xcode continued to access it since the reference still existed. Because of this, receiving this exact error is common when trying to debug the build.
If you click on the executable reference in the Products folder you can get the full path for the old build executable from the inspector on the right. Where is the name of your project, this path should be something like this:
/Users/username/Library/Developer/Xcode/DerivedData/<projectname>-<randomhash>/Build/Products/Debug/<projectname>
With the offending path in mind, you can open a terminal, change to the DerivedData folder, and remove the build folder.
$ cd ~/Library/Developer/Xcode/DerivedData
$ rm -r project-randomhash
After removing the build folder, re-build your project and debug once again.

Xcode: invalid symlink error when trying to run app in iOS simulator

At the end of my app's compilation phase, I see an invalid symlink error.
This is just some temp directory that's created every time I run. I tried deleting it to no avail.
The app runs fine on device.
Any help would be much appreciated.
That error usually happens when your app contains a symlink that points outside the app bundle. When building for device or the Simulator, Xcode creates the app bundle, then copies it out for MobileInstallation to do the install or update. MobileInstallation will not install an app that has symlinks to locations outside the app bundle.
Do you have any simulator-specific build scripts or steps? Does your bundle contain any symlinks? Open the Products group in Xcode. Right-click on "<name>.app" and select "Show in Finder". Right-click the app and select "Show Package Contents". Examine the app for the presence of any symlinks. You can also open that directory in Terminal and use ls -al. Any links will have an l character in the first position.
The other possibility is you have a file permission problem or other filesystem corruption. Run Disk Utility to check for errors. Assuming everything is OK, you can reset your Simulators with xcrun simctl erase all.
I had same problem. cleaning the project build directory fixed the issue for me.
I had same problem once, then i deleted the simulator from opened window after followed way "Set the active scheme -> Add additional simulator".After that i added a new simulator. I'm not sure about the solution for you.
Second way to solve the problem (in my opinion), check the simulator path "Finder -> Library -> Developer -> CoreSimulator -> Devices" like this. After that, find your project simulator then delete it :) and run the project on the same simulator again.
I hope it works for you. Good luck.

If I moved my Xcode project folder to another computer running OS X, Can the app still be built and run there?

I have an Xcode project that needs to be copied to another Mac. Because I don't have another Mac, I can't try it to see what happens.
If the user opens the .xcodeproj file and build it. Will the build succeed? And if he/she opens the project and click on the run button on the top-left corner, will the app run on a simulator?
I am asking this because in project settings, I set the Team to myself, I'm afraid that the app won't run because of this. Because I think when you run the app, it finds the certificates from the keychain. If a valid certificate is found, the app will run. But in someone else's Mac, the keychain does not contain the required certificate. So I think the app might not run successfully.
Will the project run on other Macs if they don't have the certificates? Do I need to do additional things to make this work?
Yes, As long as you aren't trying to run it on a physical device and only the simulator it will work.
If you are trying to install and run it on a physical device you will need to be able to link your username/certificate type thing in the build settings in Xcode

Remove iOS app from command line

So we're building this iOS application. We have performance tests that are automatically run by Jenkins. Of course these tests must be run on the device.
Right now we have a lot of trouble with some tests, and I suspect that they don't clean up after themselves, leaving the app's Documents folder in an uncertain state. Obviously I can fix the cleanup, but this will take a huge time.
I'd love to be able to just delete the app from the device before running the tests. Is there any way we can do this via xcodebuild or any other automatable tool. Could be even applescript or a non-official tool. The only rule is that we may not jailbreak the device.
One multi-platform option is libimobiledevice and the ideviceinstaller utility. It runs on Linux, Mac and Windows and even supports iOS 9.
As noted in the library webpage, it does not depend on jailbreak.
To delete an app do:
ideviceinstaller -uninstall com.somecompany.someapp

How to build and run ios app in specified folder on device?

After pressing build and run button in XCode I want to install my app to the specified folder on my device. For example, in directory "/DebugApps". Can I do it?
I'm not sure why you would even want to do that, but no, that is an automated process and the corresponding folders are created by the system.

Resources