How can I configure the iOS Simulator application directory? - xcode

Is there a way to configure the iOS Simulator application directory?
I'm using Xcode 4.3 and it's currently under
/Users/<Username>/Library/Application Support/iPhone Simulator/5.1/Applications/
When I run an app in Xcode it gets copied to a sub-directory:
/Users/<Username>/Library/Application Support/iPhone Simulator/5.1/Applications/<APP-UUID>/<AppName>.app
"Documents", "Library" and "tmp" dirs are next to the the app itself. Any file access that I'm doing within my app is using this directory as root.
The reason for asking this is that I want to keep the files on an SSD that is not my startup volume. So any hard links won't work either.
I haven't looked at Xcode 4.4 or 4.5 yet, but I could use those as well.
UPDATE:
Actually soft links work:
First delete
rm -R /Users/<Username>/Library/Application Support/iPhone Simulator/5.1/Applications/
Then create the soft link
ln -s /Volumes/<YourSSDVolume>/Applications/ /Users/<Username>/Library/Application Support/iPhone Simulator/5.1/Applications/
Thanks to John.K.Doe for forcing me to try it again;)

you can use soft-links to link onto other volumes, so long as those volumes always end up in the same place, and you could also use a soft-link to link to someplace that you then configure whenever your SSD is attached.

I think you can use a parameter to launch Simulator. See this SO answer: https://stackoverflow.com/a/4894178/801466.

Related

Remove local app M1 Mac that was created in Xcode

I'm working on an iOS Xcode project on an M1 Mac. I set the run destination as (This Mac) and ran the app on the Mac. Now I need to delete the app to clear its data because I need to make sure a file copy operation happens on first run. A search in Finder shows me the app in /Users/my Name/Library/Developer/Xcode/DerivedData/myXcodeProject-cpkgxnpaxvacnldboddpfgojwukv/Build/Products/Debug-iphoneos
I can delete the app from there but when I run it again all of its data is still there.
I don't see any other supporting files in that directory.
The data I want to delete are the files that are automatically copied to the Apps Documents Directory. Any suggestions how to scrub that app off the Mac?
First, open the terminal and do the following:
cd ~/Library/Containers
find . -iname "*bloons*"
This will return an output which is showing a match in an obscured directory name. You need to delete the app and its directory with:
rm -Rf 2EC6B4BC-DD8D-4D49-89A1-4376990BF693
The original answer could be found here:
https://forums.macrumors.com/threads/how-to-uninstall-ios-ipados-apps-on-m1-macs-and-where-do-they-store-their-files.2275923/?post=29453766#post-29453766

XCode - How to reset/"delete" a mac os app run from Xcode (analog to deleting the app in the ios simulator)?

When using the iOS Simulator, I can simply delete the app and re-run the app to start fresh. How is this done for mac os apps? I can't find it out. There is a folder for the project inside "DerivedData", but deleting this also messes with the entire project and I have to re-fetch all dependencies and stuff.
Thanks!
Had the same question, found the answer in another question on Stack Overflow: Nicolas Miari and superfell's answer did the trick for me and my Mac Catalyst app:
You can use the defaults command line tool to remove all the settings,
you just need the bundle id of your app (which you can find in your
Info.plist file), e.g. if your bundle id is "com.foo.barApp" then you
can run this from a terminal shell:
defaults delete com.foo.barApp
For anyone who comes here later for solution:
install fd from homebrew: brew install fd
search for your data folder: fd com.thisIsYour.bundleId
You should see something likes this:
Library/Containers/B155E847-3026-484D-8CC1-165E3CA1E9CD/Data/Library/...
Library/Containers/B155E847-3026-484D-8CC1-165E3CA1E9CD/Data/Library/...
Library/Containers/B155E847-3026-484D-8CC1-165E3CA1E9CD/Data/Library/...
remove the folder: rm -rf Library/Containers/B155E847-3026-484D-8CC1-165E3CA1E9CD
If the app is storing something at say ~/Library/Caches/yourapp or ~/Library/Application Support/yourapp, it's trivial to set up an Automator Service, or bash alias to clean them up.
~/Library/Developer/Xcode/DerivedData is meant for the Xcode project and the things Xcode creates, not the things that your app creates such as user preferences.
Alternatively, you can create a listener for a flag in the app itself like --run-fresh that can be set in scheme settings as launch argument. This flag will (if you code it) stop the app from looking into user data folder.

My Xcode installation is taking up loads of space; how to reduce space used by simulators?

So my computer is the base model MacBook Pro so hard drive space is a premium.
I've been looking through folders to find what's taking up all the space and my UserName/Library/Developer folder was 30GB. This folder contains Xcode & CoreSimulator.
I've gone and deleted most of my archived projects and that's reduced the size down to 20GB in total with 18GB in the Xcode folder, but this still seems large.
I haven't got any of the simulators installed, except for the current 8.4 simulator, yet I seem to have a folder for each simulator in the iOS DeviceSupport subfolder of Xcode.
Can someone tell me if their Xcode folder is a similar size and if I should expect all of the simulators to be included in this folder, even if they aren't visibly available in Xcode? Is it safe for me to delete all of these unused simulators?
Yes, it is safe to remove all the simulators.
Your best option is probably just to install again Xcode, this way you could just sudo rm -rf /Library/Developer and rm -rf ~/Library/Developer then install again everything (a simple download that is.)
Just found out you can run the following command in terminal to delete unused simulators and free up some space:
xcrun simctl delete unavailable

How can I tell Spotlight to index my .dSYM bundles?

Today was the first time that I tried - and failed - to symbolicate a crash log on a newly bought MacBook (let's call this machine MB1). MB1 came with Mac OS X 10.9 pre-installed. I tracked the problem of the failing symbolication down to Spotlight not indexing any of my .dSYM bundles (without the Spotlight index, Apple's symbolicatecrash script fails to locate the .dSYM bundle that matches the crash log). I came to my conclusion because
mdfind "com_apple_xcode_dsym_uuids == *"
does not print anything, although I have several .xcarchive bundles in my ~/Library/Developer/Xcode/Archives folder, and they definitely contain .dSYM sub-bundles whose UUID I can print with dwarfdump --uuid. I also have a couple of .dSYM bundles inside my project's build folder (DerivedData), but none of them are indexed either.
The short and easy question therefore is: How can I tell Spotlight to index my .dSYM bundles?
In case there is no easy answer for this easy question, here is what I have already tried on MB1:
Check permissions of files and folders in ~/Library/Developer/Xcode/Archives (they are all OK, 755 for folders, 644 for files)
Run mdimport ~/Library/Developer/Xcode/Archives (has no effect)
In "System Preferences > Spotlight > Privacy" first add and then remove the ~/Library/Developer/Xcode/Archives folder (has no effect either)
Check with mdutil -s / that indexing is enabled for the volume (it is)
Erase and rebuild the entire index mdutil -E / (takes maybe 10-15 minutes, but still has no effect)
To go into more detail: I have an older MacBook (let's call this machine MB2) that was my dev machine before I switched to MB1. On MB2 I never had any trouble with symbolicating. MB2 had Mac OS X 10.8 installed while I was still actively developing on it, but I recently upgraded MB2 to Mac OS X 10.9.
Today, running mdfind on MB2 still gives me a lot of .dSYM bundles, both from the Archives folder and from the project's DerivedData build folder. These are all old files from the Mac OS X 10.8 days, but apparently Spotlight keeps its index across OS upgrades. I thought it would be interesting to see how Spotlight behaves when new files are created, so I did the following:
Fire up Xcode on MB2, create a new archive, and run mdfind. This finds the intermediate .dSYM bundle inside the DerivedData build folder.
Delete the intermediate .dSYM bundle and run mdfind again. No results this time, i.e. the .dSYM bundle inside the Archives folder is NOT found!
Make a copy of the .xcarchive bundle created in step 1 and place the copy in the root of the user home directory. Run mdfind. This finds the .dSYM sub-bundle within the copied .xcarchive bundle!
At this point, I jumped to the conclusion that because ~/Library is a hidden folder this is what prevents Spotlight from indexing stuff within it. This can be easily confirmed by creating a regular file inside ~/Library and searching for it (no hits), then moving the file outside of ~/Library and searching again (1 hit). Unfortunately, this theory falls flat on its nose because of two reasons:
~/Library was already hidden in Mac OS X versions prior to 10.9, but this never prevented Spotlight from indexing .dSYM files
The "hidden" flag is not all that keeps Spotlight from indexing stuff in ~/Library: If I unhide the folder with chflags nohidden ~/Library, that does not make the regular file visible to Spotlight.
Back to MB1: I tried to repeat step 3 from above, i.e. make a copy of the .xcarchive bundle in the root of the user's home directory, then run mdfind. Surprisingly, on MB1, the result is different from MB2: mdfind still finds no .dSYM bundles whatsoever!
At this point I give up and hope for your help. My conclusion is that Mac OS X 10.9 is somehow responsible for my problems, but for the life of me I can't figure out why this is so. In case it helps, here are a few additional configuration details:
MB1: Xcode 5.0.2 and Xcode 4.6 are installed, 5.0.2 is the default (set with xcode-select). Also installed is Homebrew. The system is a clean install of Mac OS X 10.9.
MB2: Xcode 4.5, 4.6 and 5.0 are installed, 4.6 is the default. Also installed is MacPorts. The system is an upgrade install of Mac OS X 10.9 (previously installed .
Peeking into an Xcode application bundle reveals the following Spotlight importers:
caradhras:~ --> find /Applications/Xcode-5.0.2.app -name \*.mdimporter
/Applications/Xcode-5.0.2.app/Contents/Applications/Application Loader.app/Contents/Library/Spotlight/MZSpotlight.mdimporter
/Applications/Xcode-5.0.2.app/Contents/Library/Spotlight/uuid.mdimporter
Running this command
mdimport -g /Applications/Xcode-5.0.2.app/Contents/Library/Spotlight/uuid.mdimporter ~
finally indexes the .xcarchive bundle that is in the root of the user's home directory. It does NOT index the bundles in ~/Library/Developer/Xcode/Archives, though, even when I explicitly point mdimport to this folder.
The question remains: Why is uuid.mdimporter not run automatically?
EDIT
The solution was to reboot the machine (logout/login might have been sufficient), archive bundles outside of ~/Library are now properly indexed. The reason why I needed to reboot probably is this:
I am using a privileged admin user (A) for installing software, but I am using a different, non-privileged user (U) for normal work, such as developing with Xcode.
I was logged in with user U at the time I installed Xcode with user A
Since that time I have never rebooted, nor made any logins (I prefer sending my machine to sleep over night instead of shutting it down). Presumably, the list of active Spotlight importers is updated (probably by launch services) only when logging out/logging in, or after a reboot.
Anyway, during troubleshooting I found that you can check the list of active Spotlight importers by running mdimport -L (note that different users can have different Spotlight importers active at the same time). Unsurprisingly, after the reboot uuid.mdimporter is now listed, while before the reboot it was not.
Here is a useful Apple document that I found after some googling: Troubleshooting Spotlight Importers.
FINAL SOLUTION
Configure Xcode so that the archive folder is located outside of ~/Library. In Xcode 6 you can do this in the Preferences dialog, under the "Locations" tab.

How to fully remove Xcode 4

I want to remove all existing SDK versions as well as Xcode 4.
Xcode 4 Guide says to do this:
sudo /Xcode4/Library/uninstall-devtools --mode=all
But I don't have Xcode4 at this location and the only place I see it is under /Developer/Applications
I've already run the uninstall-devtools that was previously found in /Developer/Applications and then did a reinstall.
What else can I do to completely remove everything and start from scratch?
I use this command:
sudo /Developer/Library/uninstall-devtools --mode=all
Edit (1 year later):
If you've downloaded Xcode from the App Store, it's self-contained, as #mediaslave suggests. You can just drag it to the trash or use AppZapper (or a similar utility) to remove the developer tools.
If you're looking to update it, you can also do that straight through the App Store.
sudo /[xcode-path]/Library/uninstall-devtools --mode=all
Normally, [xcode-path] means /Developer, but if you have multiple versions, for example 3 is the first installed, 4 is second, /Developer will be xcode 3's root derectory and /Xcode4 for xcode 4.
Ensure Xcode, iOS Simulator, and the Mac App Store apps aren't running, then trying running the uninstall script at this (different!) location:
/Library/Developer/Shared/uninstall-devtools
This is where I found it.
Also delete Install Xcode.app from Applications folder, and Empty Trash.
Then run App Store again, and find/install Xcode.
su (or sudo su, whatever)
find / -name uninstall-devtools
This will reveal where the utility is...
If you have XCode 4.3.1, just Move To Trash the XCode.app file in the Applications folder.
If you have installed xcode from Mac App store, then you need to delete it from Launch pad. You can do this by locating xcode icon in launch pad, long click on the icon till it starts dancing. Then delete it and wait for a while till the xcode.app is deleted from /Application. If you manually delete xcode.app from /Application, App store will continue to think its installed and will not allow you to reinstall in future.
I tried to uninstall this by deleting it, but the AppStore still thought that it was installed. I deleted some preferences files in my /private directory, which made the AppStore "forget" that I had installed Xcode. I used the following command:
sudo find / -iname '*xcode*' 2> /dev/null | egrep '^/private.*' | xargs -I file sudo rm -rfv file
Which deleted the following files from my computer:
/private/var/db/receipts/com.apple.pkg.XcodeMAS_iOSSDK_6_1.bom
/private/var/db/receipts/com.apple.pkg.XcodeMAS_iOSSDK_6_1.plist
/private/var/folders/7d/n34963zx62s7znxyzn3dn6bh0000gq/C/com.apple.Xcode.503/CachedSpecifications-Xcode
/private/var/folders/7d/n34963zx62s7znxyzn3dn6bh0000gq/C/com.apple.Xcode.503/CachedSpecifications-xcodebuild
/private/var/folders/7d/n34963zx62s7znxyzn3dn6bh0000gq/C/com.apple.Xcode.503
I do not know what these files are used for, but it made the AppStore forget that it was installed, which is what I needed to happen. In my case, the AppStore was not allowing me to update to the new version of Xcode.

Resources