Skip to content
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

AdditionalAppExtensions: .entitlements file location - better lookup or error #19242

Open
Tracked by #19586
tipa opened this issue Oct 18, 2023 · 4 comments
Open
Tracked by #19586
Labels
enhancement The issue or pull request is an enhancement
Milestone

Comments

@tipa
Copy link

tipa commented Oct 18, 2023

Steps to Reproduce

  1. Xcode: File -> New -> Project -> iOS App
  2. Xcode: File -> New -> Target -> (Share) Extensions
  3. Xcode: Select target "Share Extension" & add capability (e.g. App Group, which is very common for extensions)

The last step will create a NAME_OF_EXTENSION.entitlements file in the folder of the extension

When using AdditionalAppExtensions, the documentation links to this example project where the AdditionalAppExtensions Include path points to the project folder, where the .xcodeproj is located.

Expected Behavior

  • App extension is signed correctly & and can use the entitlements granted (e.g. can use the App Group folder).
  • The expected location of the Entitlements file is documented and/or
  • The build process errors out if it expects an Entitlements file but it cannot be found and/or
  • The build process is smarter in finding the Entitlements file, e.g. also looks in the extension-subfolder or searches all subfolders recursively

Actual Behavior

The app extension is not signed correctly and crashes when trying to use features granted by the entitlement.
It appears that this condition fails:

<CodesignEntitlements Condition="Exists('%(AdditionalAppExtensions.Identity)/%(AdditionalAppExtensions.Name).entitlements')">%(AdditionalAppExtensions.Identity)/%(AdditionalAppExtensions.Name).entitlements</CodesignEntitlements>

The build process expects the .entitlements file to be located in the project folder, but it is located in the extension subfolder. In the build process this shows by a missing "--entitlements "path/to/entitlements" part in the _CodesignAppBundle step.

I have encountered this problem yesterday and it took lots of time to find the cause of why the extension didn't work correctly. It appears that most developers trying to use AdditionalAppExtensions face this problem, as can be seen here.

Environment

.NET 8 RC2

@rolfbjarne rolfbjarne added this to the .NET 9 milestone Oct 18, 2023
@rolfbjarne rolfbjarne added the enhancement The issue or pull request is an enhancement label Oct 18, 2023
@github-project-automation github-project-automation bot moved this to Bugs in .NET 9 Aug 27, 2024
@rolfbjarne rolfbjarne modified the milestones: .NET 9, .NET 10 Sep 27, 2024
@rolfbjarne rolfbjarne removed this from .NET 9 Sep 27, 2024
@qasimmajeed
Copy link

@tipa do we have any workaround of it?

@qasimmajeed
Copy link

@tipa i think we must need the feature to have multiple entitlements for different build configuration.

@tipa
Copy link
Author

tipa commented Nov 13, 2024

@qasimmajeed my .csproj looks something like this:

  <ItemGroup>
    <AdditionalAppExtensions Include="../native">
      <Name>ShareExtension</Name>
      <BuildOutput Condition="'$(ComputedPlatform)' == 'iPhone'">build/$(Configuration)-iphoneos</BuildOutput>
      <BuildOutput Condition="'$(ComputedPlatform)' == 'iPhoneSimulator'">build/$(Configuration)-iphonesimulator</BuildOutput>
    </AdditionalAppExtensions>
  </ItemGroup>

The native folder is where I have my xcodeproj. My .entitlements files are placed directly in that folder (not in subfolders of it, where it is placed by default when creating a new project in XCode).

@qasimmajeed
Copy link

@tipa Thanks i have done the same thing from my side and its working as expected. I am just wondering if we have the build configuration different for staging or dev environment how the entitlement will work for the same because they could have different key chain group, so is there any way that we can define the different entitlements here to pick it from the root directory basis on the build configuration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue or pull request is an enhancement
Projects
None yet
Development

No branches or pull requests

3 participants