I'm using NSUserDefaults to save some data in my application. Where can I find the file where my data is stored during development? It's a normal cocoa app (so no ios/iphone!)
Once it's deployed, it should be available in Library/Preferences/appname.plist, right? But where can I find it while I'm still working on the application?
There is no difference between "development" and "deployment". NSUserDefaults doesn't know whether you did a debug or release build. The location should be ~/Library/Preferences/yourAppIdentifier.plist no matter what.
If you are seeing a difference between development and deployment builds, maybe check the bundle identifier (CFBundleIdentifier) in your app's Info.plist.
Also: if your app is sandboxed, your prefs will end up in the sandbox: ~/Library/Containers/yourAppIdentifier/Data/Library/Preferences/yourAppIdentifier.plist. The documentation claims that the system automatically moves your old preferences file into the sandbox, if necessary, on the first launch of the sandboxed version of the app.
Related
I am testing my macOS app, and I need to uninstall it to check some special features. For iOS apps this is very simple, I simple remove the app from the simulator and then I reinstall it. How can I do the same thing for macOS?
I've already tried to delete the app from /Users/myuser/Library/Developer/Xcode/DerivedData/Build/Products/Debug/myapp.app
But that doesn't work. If I run my project again, all previous settings and saves are kept.
How can I completely remove an app made in Xcode for macOS development?
The topic: Delete app from OSX simulator in Xcode didn't help me.
This command will delete whatever's in the UserDefaults database for your app:
defaults delete com.mywebsite.myapp
Replace com.mywebsite.myapp with the bundle ID of your application.
If you have items other than just UserDefaults settings, they'll appear in the home/Library/Containers folder in a folder named after your app bundle (assuming your app is sandboxed; otherwise check home/Library/Application Support). You'll find the plist file for your UserDefaults in here as well, although deleting that using the Finder isn't reliable, since the system sometimes caches the plists in memory, so the defaults command is still the best way to clear that.
There are many apps that allow you to thoroughly uninstall apps, for example AppCleaner. However I'd try to use the clean build folder option within Xcode first.
I created a simple Finder Sync (FinderSync) extension (appex) and it comes by default with App Sandbox ON (in .entitlements com.apple.security.app-sandbox true).
Everything works fine but I need to access a specific folder on the macOS via this extension and I cannot do that with the Sandbox on.
I disabled the sandbox but the extension is not loaded anymore in Finder.
Any thoughts on this? Any workarounds?
Finder Sync extensions must be sandboxed. I couldn't find this requirement explicitly documented anywhere, but the following error appears in your system log if it's not sandboxed:
pkd[255]: ignoring mis-configured plug-in at /Applications/Liferay\ Sync.app/Contents/PlugIns/LiferayFinderSync.appex: plug-ins must be sandboxed
If you need to access a folder outside your application's container, you can use temporary exception entitlements like "com.apple.security.temporary-exception.files.home-relative-path.read-only". Note that apps submitted to the Mac App Store using these entitlements will likely be rejected.
I'm not understanding if a containing app is needed alongside a Today Extension for OSX. I have a very simple and straightforward widget, it does not need nor rely on a main or containing app. With that said, how can I create an Today Extension without a containing app.
What I have so far is that I have a blank app with a today extension.
You cannot create a today extension without having an app. They don't work that way. All iOS app extensions are just that-- extensions to an app. There must be an app, and it must do something to be accepted into the app store (Apple rejects apps for "minimal functionality"). Extensions cannot exist on iOS outside of an app bundle, until or unless Apple decides to change things in the future.
A container app is not needed. Read up the Apple documentation on it. It says:
To deliver an OS X app extension, it’s recommended that you submit your containing app to the App Store, but it’s not required.
I have an OS X app all correctly setup for using iCloud. If I archive the app and save it as an app in the applications folder and run it, it works with iCloud, but if I run it from Xcode, NSFileManager's ubiquityIdentityToken will always return nil. Anyone know what could cause this?
I've resolved this by enabling all apps in iCloud preferences->documents and data. I don't know why this helps as the app I am developing has always been iCloud enabled, but it is working now.
I'm curious about how a sandboxed app, handle uninstalling. and how NSUserDefaults get affected by it.
Depends how you delete it. If you just remove /Applications/TheApp.app then no, as the sandboxed app's files (including NSUserDefaults related files) are in ~/Library/Containers/com.domain.theapp.
However if you use tools like AppZapper or AppCleaner etc., then they will doubtless remove the container as well. However that is up to them.