-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MacCatalyst] Added Default Entitlements for MacCatalyst projects #18669
Changes from 4 commits
ede766e
f43ae76
483d2ea
4892823
bcae3c0
a7ffe68
f84522c
2a79af0
2be6ea2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,20 @@ | |
<None Include="@(ObjcBindingCoreSource)" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup Condition="'$(_PlatformName)' == 'MacCatalyst'"> | ||
<EnableDefaultMacCatalystReleaseEntitlements Condition="'$(EnableDefaultMacCatalystReleaseEntitlements)' == ''">True</EnableDefaultMacCatalystReleaseEntitlements> | ||
<EnableDefaultMacCatalystDebugEntitlements Condition="'$(EnableDefaultMacCatalystDebugEntitlements)' == ''">True</EnableDefaultMacCatalystDebugEntitlements> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="'$(EnableDefaultMacCatalystDebugEntitlements)' == 'True' and '$(Configuration)' == 'Debug'"> | ||
<CustomEntitlements Include="com.apple.security.get-task-allow" Type="boolean" Value="true" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(EnableDefaultMacCatalystReleaseEntitlements)' == 'True' and '$(Configuration)' == 'Release'"> | ||
<CustomEntitlements Include="com.apple.security.app-sandbox" Type="boolean" Value="true" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 since it allows sandboxing on catalyst apps: https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_app-sandbox There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was under the impression that Xcode also automatically adds this entitlement for apps that run on MacOS: https://developer.apple.com/documentation/uikit/mac_catalyst/creating_a_mac_version_of_your_ipad_app @rolfbjarne Should app-sandbox get the same treatment as network.client? MAUI wanted this in our sdk.. can you publish Mac Catalyst apps in the Mac App Store without this entitlement? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No: "To distribute a macOS app through the Mac App Store, you must enable the App Sandbox capability." |
||
<CustomEntitlements Include="com.apple.security.network.client" Type="boolean" Value="true" /> | ||
dustin-wojciechowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</ItemGroup> | ||
|
||
<!-- Architecture --> | ||
<!-- If the old-style variables are set, use those --> | ||
<PropertyGroup Condition=" '$(TargetArchitectures)' == '' "> | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1270,6 +1270,33 @@ public void AutoAllowJitEntitlements (ApplePlatform platform, string runtimeIden | |||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", "Release")] | ||||||||||||||||||||||||||||||||||||||||
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", "Debug")] | ||||||||||||||||||||||||||||||||||||||||
public void CheckForMacCatalystDefaultEntitlements (ApplePlatform platform, string runtimeIdentifiers, string configuration) | ||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||
var project = "Entitlements"; | ||||||||||||||||||||||||||||||||||||||||
Configuration.IgnoreIfIgnoredPlatform (platform); | ||||||||||||||||||||||||||||||||||||||||
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath, configuration: configuration); | ||||||||||||||||||||||||||||||||||||||||
Clean (project_path); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
var properties = GetDefaultProperties (runtimeIdentifiers); | ||||||||||||||||||||||||||||||||||||||||
properties ["Configuration"] = configuration; | ||||||||||||||||||||||||||||||||||||||||
DotNet.AssertBuild (project_path, properties); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
var executable = GetNativeExecutable (platform, appPath); | ||||||||||||||||||||||||||||||||||||||||
var foundEntitlements = TryGetEntitlements (executable, out var entitlements); | ||||||||||||||||||||||||||||||||||||||||
if (configuration == "Release") { | ||||||||||||||||||||||||||||||||||||||||
Assert.IsTrue (foundEntitlements, "Found in Release"); | ||||||||||||||||||||||||||||||||||||||||
dustin-wojciechowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||
Assert.IsTrue (entitlements!.Get<PBoolean> ("com.apple.security.app-sandbox")?.Value, "com.apple.security.app-sandbox enlistment was not found."); | ||||||||||||||||||||||||||||||||||||||||
Assert.IsTrue (entitlements!.Get<PBoolean> ("com.apple.security.network.client")?.Value, "com.apple.security.network.client enlistment was not found."); | ||||||||||||||||||||||||||||||||||||||||
dustin-wojciechowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||
} else if (configuration == "Debug") { | ||||||||||||||||||||||||||||||||||||||||
Assert.IsTrue (foundEntitlements, "Found in Debug"); | ||||||||||||||||||||||||||||||||||||||||
Assert.IsTrue (entitlements!.Get<PBoolean> ("com.apple.security.get-task-allow")?.Value, "com.apple.security.get-task-allow enlistment was not found."); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i understand this format is consistent with the other tests.. but i wonder if it may be better to have a separate test per config? it might be a bit more verbose but in the future if there are more entitlements added it might be easier to keep track of and the test failure will speak for itself otherwise lgtm
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
// [TestCase (ApplePlatform.MacCatalyst, null, "Release")] | ||||||||||||||||||||||||||||||||||||||||
[TestCase (ApplePlatform.MacOSX, null, "Release")] | ||||||||||||||||||||||||||||||||||||||||
public void NoWarnCodesign (ApplePlatform platform, string runtimeIdentifiers, string configuration) | ||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 On debugging: https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues#3087731
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being that this isn't part of the Release configuration and only Debug, and that this is something that Xcode adds in itself to enable web debugging, wouldn't this be fine? I'll add an assert in the unit test to make sure it's not being passed into the release configuration.