Register
and Export
attributes used to wire up your C# classes to Objective-C objects and UI elements.MacSandbox
for the project name and click the Create button:webView
:using WebKit;
ViewDidLoad
method look like the following:com.appracatappra.MacSandbox
):com.appracatappra.MacSandbox
):~/Library/Containers/
folder - If the app is sandboxed, there will be a folder named like your app's Bundle Identifier (example: com.appracatappra.MacSandbox
):/Applications/Utilities
).Yes
for your application:bin
directory.codesign -dvvv --entitlements :- executable_path
(where executable_path
is the path to your application):CompileEntitlements
target for msbuild
to automatically add that permission to the entitlements for any app that is sandboxed for debug builds only. Release builds should use the entitlements specified in the entitlements file, unmodified./Applications/Utilties/
).sandbox
in the search:network-outbound
traffic because of the App Sandbox, since we have not requested that right..txt
file and a .pdf
.~Library/Containers
) and can be accessed with the NSHomeDirectory
function (see below) within your application. Because it is in the Home directory, each user will get their own container for the app.NSLibraryDirectory
), Application Support and Preferences subdirectories.NSHomeDirectory
API has not been mapped in the current version of Xamarin.Mac.com.apple.security.application-groups
entitlement to access a shared container that is common to all the applications in the group. You can use this shared container for non-user facing content such as database or other types of support files (such as caches).~/Library/Group Containers/<application-group-id>
. The Group ID must begin with your Development Team ID and a period, for example:/bin
or /usr/lib
).NSOpenPanel
or NSSavePanel
. Powerbox access is enabled via the Entitlements that you set for your Xamarin.Mac application./bin
/sbin
/usr/bin
/usr/lib
/usr/sbin
/usr/share
/System
NSTemporaryDirectory
.Info.plst
file, b) code to tell the sandbox what the app will be doing with these files..txt
file to a .pdf
file. To handle this situation, you must use a NSFileCoordinator
to access the file. You'll call the WillMove(fromURL, toURL)
method first, move the file to the new extension and then call ItemMoved(fromURL, toURL)
.NSFilePresenter
to gain access to the secondary file. Provide the main file to the PrimaryPresentedItemURL
property and the secondary file to the PresentedItemURL
property. When the main file is opened, call the AddFilePresenter
method of the NSFileCoordinator
class to register the secondary file.NSIsRelatedItemType
(with a value of YES
) to its entry in the CFBundleDocumentTypes
array.NSOpenPanel
and NSSavePanel
when calling them from a sandboxed Xamarin.Mac app:NSOpenSavePanelDelegate
.NSOpenPanel
NSSavePanel``NSPanel``NSWindow``NSResponder``NSObject``NSOpenPanel``NSSavePanel``NSObject``NSOpenPanel``NSSavePanel
NSOpenPanel
), the app can create an App-Scoped Bookmark so that it can access the same file again in the future.NSOpenPanel
), the app creates a Document-Scoped Bookmark for the item that is stored in the project, so that the file is always accessible to the app./private
or /Library
).com.apple.security.files.bookmarks.app-scope
Entitlement key to true
. For Document-Scoped Bookmarks, set the com.apple.security.files.bookmarks.document-scope
Entitlement key to true
.NSOpenPanel
for example), that the app will need persistent access to. Use the public virtual NSData CreateBookmarkData (NSUrlBookmarkCreationOptions options, string[] resourceValues, NSUrl relativeUrl, out NSError error)
method of the NSUrl
class to create the bookmark.public static NSUrl FromBookmarkData (NSData data, NSUrlBookmarkResolutionOptions options, NSUrl relativeToUrl, out bool isStale, out NSError error)
method of the NSUrl
class to resolve the bookmark.StartAccessingSecurityScopedResource ()
method of the NSUrl
class to start accessing a Security-Scoped URL.StopAccessingSecurityScopedResource ()
method of the NSUrl
class to stop accessing a Security-Scoped URL./Applications/Utilities
).asctl container acl add -file
in the Terminal window./Applications/Utilities
).asctl container acl list -bundle <container-name>
.<container-name>
is usually the Bundle Identifier for the Xamarin.Mac application.[Your-App-Bundle]
is the name and path to the application's bundle.userInfo
dictionary when posting to an NSDistributedNotificationCenter
object for messaging other tasks.NSRunningApplication
to terminate other apps.NSDocument
, you should switch to it because of the built in support for the App Sandbox. NSDocument
automatically works with PowerBox and provides support for keeping documents within your sandbox if the user moves them in Finder.LSSharedFileList
nor can you manipulate the state of launch services using LSRegisterURL
. Use the SMLoginItemSetEnabled
function as described in Apples Adding Login Items Using the Service Management Framework documentation.getpwuid
to obtain the user's home directory from directory services, consider using Cocoa or Core Foundation symbols such as NSHomeDirectory
./Applications/Utilities
) and look for sandboxd
violations in the All Messages log.sandboxd
violation, resolve the issue either by using the app container instead of other file system locations or apply App Sandbox Entitlements to enable access to restricted OS features.sandboxd
violations have been resolved.