banditoth / maui-archiver-vscode

Visual Studio Code extension for archiving/publishing .NET MAUI applications
MIT License
40 stars 6 forks source link

Enhancement - IOS: Entitlement.plist #19

Closed EntityBox closed 3 weeks ago

EntityBox commented 4 months ago

New Command Example: "NET MAUI - Archive : IOS - Add Entitlement.plist"

I have recently moved over to VSCode from VS for MAC and searched for some support in adding the keychain access for the MAUI SecureStorage. in VS For MAC you can easily select Entitlement under the IOS Bundle Signing section. Had to do some research to get this done manually in VSCode. Because it falls together with Publishing, I thought I'd log this enhancement as it will fit nicely with the existing commands.

Action 1:

Create a new Entitlement.plist XML file with Secure Storage example:

  1. Location & Filename: Create Entitlement.plist in /Platforms/iOS folder.
  2. File Example to create
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <!-- Allow Debug Secure Storage access, replace {csprojfile.ApplicationId} from your project file and uncomment this section -->
        <!-- <key>keychain-access-groups</key>
        <array>
            <string>$(AppIdentifierPrefix){csprojfile.ApplicationId}</string>
         </array> -->
    </dict>
</plist>
  1. Warnings: If the file exist do not take action.

Action 2:

Add the Entitlement section to the project file if it does not exist

  1. Location & Filename: Open the .csproj file and add a before the close tag.
  2. Tag Example
    <PropertyGroup Condition="$(TargetFramework.Contains('-ios'))">    
    <CodesignEntitlements>Platforms\iOS\Entitlements.plist</CodesignEntitlements>
    </PropertyGroup>
  3. Warnings: Tag already exist

Thanks for the great plugin, using it extensively with all my projects - Hope this can enhance it and does not take too much effort with the samples provided.

banditoth commented 3 weeks ago

Hey @EntityBox Thanks for your idea. Unfortunately I'm not planning to implement this functionality in this extension. However, I've got a good practice for you to use custom entitlements in your .NET MAUI app. Check out the end of this blogpost: https://www.banditoth.net/2024/10/04/using-different-entitlements-for-debug-and-release-modes-in-net-maui-ios/