Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@


<Target Name="ProcessAppClips" DependsOnTargets="$(ProcessAppClipsDependsOn)" Condition="'@(AppClips)' != ''">
<PropertyGroup>
<!-- We want the actual string $(AppIdentifierPrefix) in this property. -->
<!-- But MSBuild will evaluate if no matter what, even if I escape it. -->
<!-- The best way I found was to do this "hacky" Replace operation. -->
<AppIdentifierPrefix>$([System.String]::Copy('$***(AppIdentifierPrefix)').Replace('***', ''))$(AppClipsIdentifiers)</AppIdentifierPrefix>
</PropertyGroup>

<ItemGroup>
<!-- Transferthe AppClips items back from XcodeProjects -->
<AppClips Remove="@(AppClips)" />
Expand All @@ -64,29 +57,25 @@

<ItemGroup>
<_AppClipsFiles Include="%(AppClips.ArchivePath)/**/*.app/AppClips/**" />

<_AppClipsFiles>
<TargetPath>$([System.Text.RegularExpressions.Regex]::Replace('%(_AppClipsFiles.FullPath)', '^.*[\\/]AppClips[\\/]', ''))</TargetPath>
</_AppClipsFiles>
<_AppClipsInfoPList Include="%(_AppClipsFiles.FullPath)" Condition="'%(_AppClipsFiles.Filename)%(_AppClipsFiles.Extension)' == 'Info.plist'" />
</ItemGroup>

<Error Condition="'@(_AppClipsFiles)' == ''" Code="404" Text="No AppClips found in Xcode project: '%(AppClips.Identity)'" />

<!-- Extract the bundle identifier from the AppClips found -->
<Exec
Condition="'%(_AppClipsFiles.Filename)%(_AppClipsFiles.Extension)' == 'Info.plist'"
Command="xcrun plutil -extract CFBundleIdentifier raw '%(_AppClipsFiles.FullPath)'"
ConsoleToMsBuild="true"
StandardOutputImportance="Low">
<Output TaskParameter="ConsoleOutput" ItemName="_AppClipsIdentifiers" />
</Exec>
<ReadAppManifest AppManifest="@(_AppClipsInfoPList)" TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)">
<Output TaskParameter="CFBundleIdentifier" ItemName="_AppClipsIdentifiers" />
</ReadAppManifest>

<ItemGroup>
<!-- Add the bundle identifiers to the entitlements of the app -->
<CustomEntitlements
Include="com.apple.developer.associated-appclip-app-identifiers"
Type="StringArray"
Value="@(_AppClipsIdentifiers -> '$(AppIdentifierPrefix)%(Identity)', ';')" />
Value="@(_AppClipsIdentifiers -> '$(_AppIdentifierPrefix)%(Identity)', ';')" />

<!-- Include the found AppClips in the MAUI app -->
<MauiAsset Include="@(_AppClipsFiles)" LogicalName="AppClips/%(_AppClipsFiles.TargetPath)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<!-- Use the build system default output root, if it is available -->
<XcodeOutputPathRoot Condition="'$(XcodeOutputPathRoot)' == ''">$(_XcodeProjectDefaultOutputPathRoot)</XcodeOutputPathRoot>
<XcodeOutputPathRoot Condition="'$(XcodeOutputPathRoot)' == ''">$(MSBuildProjectDirectory)/$(IntermediateOutputPath)xcode/</XcodeOutputPathRoot>
<XCodeCommonParams Condition="'$(XCodeCommonParams)' == ''">-derivedDataPath '$(XcodeOutputPathRoot)DerivedData' -packageCachePath '$(XcodeOutputPathRoot)Cache'</XCodeCommonParams>
<_XcodeCachePath Condition="'$(_XcodeCachePath)' == ''">$(XcodeOutputPathRoot)Cache</_XcodeCachePath>
<_XcodeDerivedDataPath Condition="'$(_XcodeDerivedDataPath)' == ''">$(XcodeOutputPathRoot)DerivedData</_XcodeDerivedDataPath>
</PropertyGroup>
</Target>

Expand Down Expand Up @@ -47,7 +48,7 @@
<!-- so we have to do it separately once we have -->
<!-- all the metadata like Scheme, Configuration etc. -->
<XcodeProjects>
<ArchivePath>$(XcodeOutputPathRoot)/%(XcodeProjects.Scheme)-%(XcodeProjects.Configuration)-%(XcodeProjects.UniqueId).xcarchive</ArchivePath>
<ArchivePath>$(XcodeOutputPathRoot)%(XcodeProjects.Scheme)-%(XcodeProjects.Configuration)-%(XcodeProjects.UniqueId).xcarchive</ArchivePath>
</XcodeProjects>
</ItemGroup>
</Target>
Expand All @@ -57,11 +58,19 @@
<PropertyGroup>
<_XcodeDestination Condition="$(TargetPlatformIdentifier) == 'ios'">iOS</_XcodeDestination>
<_XcodeDestination Condition="$(RuntimeIdentifier.Contains('iossimulator')) == true">iOS Simulator</_XcodeDestination>
<XCodeCommonParams>-destination 'generic/platform=$(_XcodeDestination)' $(XCodeCommonParams)</XCodeCommonParams>
<XCodeCommonParams>$(XCodeCommonParams) -destination 'generic/platform=$(_XcodeDestination)'</XCodeCommonParams>
</PropertyGroup>

<ItemGroup>
<XcodeProjects>
<DerivedData>$(_XcodeDerivedDataPath)/%(XcodeProjects.UniqueId)</DerivedData>
<PackageCache>$(_XcodeCachePath)/%(XcodeProjects.UniqueId)</PackageCache>
</XcodeProjects>
</ItemGroup>

<Exec
Command="xcrun xcodebuild archive -project '%(XcodeProjects.FullPath)' -scheme '%(XcodeProjects.Scheme)' -configuration '%(XcodeProjects.Configuration)' -archivePath '%(XcodeProjects.ArchivePath)' $(XCodeCommonParams) %(XcodeProjects.XcodeParams)"
Condition="'$(SkipXcodeProjects)' != 'true'"
Command="xcrun xcodebuild archive -project '%(XcodeProjects.FullPath)' -scheme '%(XcodeProjects.Scheme)' -configuration '%(XcodeProjects.Configuration)' -archivePath '%(XcodeProjects.ArchivePath)' -derivedDataPath '%(XcodeProjects.DerivedData)' -packageCachePath '%(XcodeProjects.PackageCache)' $(XCodeCommonParams) %(XcodeProjects.XcodeParams)"
Outputs="%(XcodeProjects.ArchivePath)" />
<!--
This built in task adds parameters to the xcodebuild that cannot be controlled,
Expand All @@ -71,8 +80,8 @@
SchemeName="%(XcodeProjects.Scheme)"
Configuration="%(XcodeProjects.Configuration)"
ArchivePlatform="generic/platform=$(_XcodeDestination)"
DerivedDataPath="$(XcodeOutputPathRoot)DerivedData"
PackageCachePath="$(XcodeOutputPathRoot)Cache"
DerivedDataPath="$(_XcodeDerivedDataPath)/%(XcodeProjects.UniqueId)"
PackageCachePath="$(_XcodeCachePath)/%(XcodeProjects.UniqueId)"
OutputPath="%(XcodeProjects.ArchivePath)"
WorkingDirectory="%(XcodeProjects.RootDir)%(XcodeProjects.Directory)" />
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,47 +38,68 @@

<ItemGroup>
<Widgets>
<!-- Mark this as a Widgets project so we can -->
<!-- identify it from XcodeProjects later on. -->
<!-- Mark this as a Widgets project so we can -->
<!-- identify it from XcodeProjects later on. -->
<IsWidgets>true</IsWidgets>
</Widgets>

<!-- Consolidate all included Xcode projects -->
<!-- Consolidate all included Xcode projects -->
<XcodeProjects Include="@(Widgets)" />
</ItemGroup>
</Target>


<Target Name="ProcessWidgets" DependsOnTargets="$(ProcessWidgetsDependsOn)" Condition="'@(Widgets)' != ''">
<ItemGroup>
<!-- Transfer Widgets items back from XcodeProjects -->
<Widgets Remove="@(Widgets)" />
<Widgets Include="@(XcodeProjects)" Condition="'%(XcodeProjects.IsWidgets)' == 'true'" />
</ItemGroup>

<ItemGroup>
<_AppexFiles Include="%(Widgets.ArchivePath)/**/*.app/PlugIns/**/*.appex/**" />
<_AppexBundles Include="$([System.Text.RegularExpressions.Regex]::Replace('%(_AppexFiles.FullPath)', '(^.*\.appex)[\\/].*', '$1'))" />
<_AppexFiles Include="%(Widgets.ArchivePath)/**/*.app/PlugIns/**/*.appex/**" UniqueId="%(Widgets.UniqueId)" DerivedData="%(Widgets.DerivedData)" />
<_AppexBundles Include="$([System.Text.RegularExpressions.Regex]::Replace('%(_AppexFiles.FullPath)', '(^.*\.appex)[\\/].*', '$1'))" DerivedData="%(_AppexFiles.DerivedData)" UniqueId="%(_AppexFiles.UniqueId)" />
</ItemGroup>

<!-- Make sure each .appex is actually a widget -->
<Delete Condition="Exists('%(_AppexBundles.FullPath).widget')" Files="%(_AppexBundles.FullPath).widget" />
<!-- Make sure each .appex is actually a widget -->
<Exec
Command="[ &quot;`xcrun plutil -extract NSExtension.NSExtensionPointIdentifier raw -o - '%(_AppexBundles.FullPath)/Info.plist'`&quot; = &quot;com.apple.widgetkit-extension&quot; ] &amp;&amp; echo &quot;%(_AppexBundles.FullPath)&quot;"
IgnoreExitCode="true"
ConsoleToMsBuild="true"
StandardOutputImportance="Low">
<Output TaskParameter="ConsoleOutput" ItemName="_ValidAppexBundles" />
</Exec>

<Exec Command="plutil -extract NSExtension xml1 -o - '%(_AppexBundles.FullPath)/Info.plist' | grep -q 'com.apple.widgetkit-extension' &amp;&amp; echo 'true' > '%(_AppexBundles.FullPath).widget'" IgnoreExitCode="true" />
<PropertyGroup>
<!-- Convert item list to proeperty so we can filter using "Contains()" -->
<_ValidAppexBundlesList>@(_ValidAppexBundles)</_ValidAppexBundlesList>
</PropertyGroup>

<ItemGroup>
<_WidgetsAppexBundles Include="@(_AppexBundles)" Condition="$(_ValidAppexBundlesList.Contains('%(_AppexBundles.FullPath)')) == true" />
<_WidgetsAppexMobileProvision Include="%(_WidgetsAppexBundles.FullPath)/**/embedded.mobileprovision" EntitlementPath="%(_WidgetsAppexBundles.FullPath).entitlements" />
</ItemGroup>

<!-- Extract mobileprovision to get entitlements we need for codesigning -->
<Exec
Condition="Exists('%(_WidgetsAppexMobileProvision.FullPath)')"
Command="security cms -D -i '%(_WidgetsAppexMobileProvision.FullPath)' | plutil -extract Entitlements xml1 -o - - &gt; '%(_WidgetsAppexMobileProvision.EntitlementPath)'" />

<ItemGroup>
<AdditionalAppExtensions Include="%(_AppexBundles.FullPath)/.." Condition="Exists('%(_AppexBundles.FullPath).widget')">
<Name>%(_AppexBundles.Filename)</Name>
<AdditionalAppExtensions Include="%(_WidgetsAppexBundles.FullPath)/..">
<Name>%(_WidgetsAppexBundles.Filename)</Name>
<CodesignEntitlements Condition="Exists('%(_WidgetsAppexBundles.FullPath).entitlements')">%(_WidgetsAppexBundles.FullPath).entitlements</CodesignEntitlements>
</AdditionalAppExtensions>
</ItemGroup>
</Target>


<Target Name="VerifyWidgets" Condition="'@(Widgets)' != ''">
<!-- TODO: Find a way to verify that Widgets was correctly included -->
<!-- TODO: Find a way to verify that Widgets was correctly included -->
</Target>


<!-- This target is for debug purposes. See README.md for information -->
<!-- This target is for debug purposes. See README.md for information -->
<Target Name="BuildWidgets">
<PropertyGroup>
<BuildNativeEmbedded>Widgets</BuildNativeEmbedded>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
<!-- We need to set this here, despite it should be a part of the build -->
<!-- system. See https://github.com/dotnet/macios/issues/22238 -->
<TargetPlatformIdentifier Condition="'$(TargetPlatformIdentifier)' == ''">$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>

<!-- We want the actual string $(AppIdentifierPrefix) in this property. -->
<!-- But MSBuild will evaluate it no matter what, even if I escape it. -->
<!-- The best way I found was to do this "hacky" Concat operation. -->
<_AppIdentifierPrefix>$([System.String]::Concat('$', '(AppIdentifierPrefix)'))</_AppIdentifierPrefix>
</PropertyGroup>

</Project>
Loading