Skip to content

Commit

Permalink
Updates for net9.0 (#55)
Browse files Browse the repository at this point in the history
Context: dotnet/android@dbdc5fa
Context: xamarin/xamarin-macios@4489999

Updates samples and template to target net9.0, using the new 
`@(AndroidGradleProject)` and `@(XcodeProject)` build
actions added to the .NET MAUI SDKs.

The  `CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks` project
has been removed as it is no longer relevant for net9.0.
  • Loading branch information
pjcollins authored Dec 18, 2024
1 parent ac7ec25 commit e91dadd
Show file tree
Hide file tree
Showing 40 changed files with 119 additions and 998 deletions.
36 changes: 11 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,30 @@ on:
jobs:
build:
name: build
runs-on: macos-14
runs-on: macos-15
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use .NET 8.x
- name: Use .NET 9.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
dotnet-version: 9.0.x

- name: Install JDK 17
uses: actions/setup-java@v4
with:
distribution: microsoft
java-version: 17

- name: Use Xcode 15.4
run: sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: 11076708
packages: 'build-tools;35.0.0'

- name: Use Xcode 16.0
run: sudo xcode-select -s /Applications/Xcode_16.app/Contents/Developer

- name: Install MAUI
run: dotnet workload install maui
Expand All @@ -44,26 +50,6 @@ jobs:
- name: Create logs dir
run: mkdir -p ${{ runner.temp }}/logs/

- name: Create local nupkg dir
run: mkdir -p ./src/CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks/bin/Release

- name: Build and test build tasks
working-directory: ./src
run: >-
dotnet test CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks.sln
--logger trx --results-directory ${{ runner.temp }}/logs/TestResults-build-tasks
-bl:${{ runner.temp }}/logs/build-tasks.binlog
- name: Pack build tasks
working-directory: ./src/CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks
run: dotnet pack CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks.csproj -bl:${{ runner.temp }}/logs/build-tasks-pack.binlog

- name: Upload nupkg
uses: actions/upload-artifact@v4
with:
name: nupkg
path: ./src/CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks/bin/Release/*.nupkg

- name: Build template
working-directory: ./template
run: dotnet build -bl:${{ runner.temp }}/logs/template.binlog
Expand Down
10 changes: 0 additions & 10 deletions Directory.Build.props

This file was deleted.

4 changes: 2 additions & 2 deletions facebook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ This folder contains a slim binding for the Facebook SDK which demonstrates simp

### Build and Run
```shell
dotnet build sample -t:Run -f net8.0-android
dotnet build sample -t:Run -f net8.0-ios
dotnet build sample -t:Run -f net9.0-android
dotnet build sample -t:Run -f net9.0-ios
```

### Configure
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-android</TargetFramework>
<TargetFramework>net9.0-android</TargetFramework>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<!--
Enable trim analyzers for Android class libraries.
To learn more, see: https://learn.microsoft.com/dotnet/core/deploying/trimming/prepare-libraries-for-trimming
-->
<IsTrimmable>true</IsTrimmable>
<RootNamespace>Facebook</RootNamespace>
<AndroidGenerateResourceDesigner>false</AndroidGenerateResourceDesigner>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks" Version="$(NLIPackageVersion)" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<NLIGradleProjectReference Include="../native" >
<AndroidGradleProject Include="../native/build.gradle.kts" >
<ModuleName>mauifacebook</ModuleName>
<!-- Metadata applicable to @(AndroidLibrary) will be used if set, otherwise the following defaults will be used:
<Bind>true</Bind>
<Pack>true</Pack>
-->
</NLIGradleProjectReference>
</AndroidGradleProject>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion facebook/android/native/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.library") version "8.2.2" apply false
id("com.android.library") version "8.6.1" apply false
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Feb 02 10:15:22 GMT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
14 changes: 1 addition & 13 deletions facebook/android/native/mauifacebook/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,9 @@ android {
}
}

configurations {
create("copyDependencies")
}

dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.11.0")
implementation("com.facebook.android:facebook-android-sdk:latest.release")
"copyDependencies"("com.facebook.android:facebook-android-sdk:latest.release")
implementation("com.facebook.android:facebook-android-sdk:17.0.2")
}

project.afterEvaluate {
tasks.register<Copy>("copyDeps") {
from(configurations["copyDependencies"])
into("${buildDir}/outputs/deps")
}
tasks.named("preBuild") { finalizedBy("copyDeps") }
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-ios</TargetFramework>
<TargetFramework>net9.0-ios</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<IsBindingProject>true</IsBindingProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks" Version="$(NLIPackageVersion)" PrivateAssets="all" />
</ItemGroup>
<!--
Enable trim analyzers for class libraries.
To learn more, see: https://learn.microsoft.com/dotnet/core/deploying/trimming/prepare-libraries-for-trimming
-->
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinitions.cs"/>
<NLIXcodeProjectReference Include="../native/MauiFacebook.xcodeproj">
<XcodeProject Include="../native/MauiFacebook.xcodeproj">
<SchemeName>MauiFacebook</SchemeName>
<SharpieNamespace>Facebook</SharpieNamespace>
<SharpieBind>true</SharpieBind>
<!-- Metadata applicable to @(NativeReference) will be used if set, otherwise the following defaults will be used:
<Kind>Framework</Kind>
<SmartLink>true</SmartLink>
-->
</NLIXcodeProjectReference>
</XcodeProject>
</ItemGroup>

</Project>
5 changes: 4 additions & 1 deletion facebook/sample/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ public partial class App : Application
public App()
{
InitializeComponent();
}

MainPage = new AppShell();
protected override Window CreateWindow(IActivationState? activationState)
{
return new Window(new AppShell());
}
}
47 changes: 20 additions & 27 deletions facebook/sample/Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-ios;net8.0-android</TargetFrameworks>
<TargetFrameworks>net9.0-android;net9.0-ios</TargetFrameworks>
<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
Expand All @@ -26,35 +26,32 @@
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4"/>
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128"/>
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*"/>
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185"/>
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*"/>
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)"/>
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)"/>
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)"/>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('ios')) Or $(TargetFramework.Contains('maccatalyst'))">
Expand All @@ -63,19 +60,15 @@

<ItemGroup Condition="$(TargetFramework.Contains('android'))">
<ProjectReference Include="..\android\Facebook.Android.Binding\Facebook.Android.Binding.csproj" />
<!-- Include core facebook dependencies. Starting in .NET 9 these can potentially be replaced with @(AndroidMavenPackage) -->
<AndroidLibrary Include="..\android\native\mauifacebook\bin\Release\$(TargetFramework)\outputs\deps\facebook-android-sdk-17.0.0.aar">
<Bind>false</Bind>
<Visible>false</Visible>
</AndroidLibrary>
<AndroidLibrary Include="..\android\native\mauifacebook\bin\Release\$(TargetFramework)\outputs\deps\facebook-common-17.0.0.aar">
<Bind>false</Bind>
<Visible>false</Visible>
</AndroidLibrary>
<AndroidLibrary Include="..\android\native\mauifacebook\bin\Release\$(TargetFramework)\outputs\deps\facebook-core-17.0.0.aar">
<Bind>false</Bind>
<Visible>false</Visible>
</AndroidLibrary>
<!-- Add maven dependencies used in Facebook.Android.Binding.csproj to be resolved at runtime.
See https://learn.microsoft.com/en-us/dotnet/android/binding-libs/advanced-concepts/android-maven-library -->
<AndroidMavenLibrary Include="com.facebook.android:facebook-core" Version="17.0.2" Bind="false" />
<AndroidMavenLibrary Include="com.facebook.android:facebook-bolts" Version="17.0.2" Bind="false" />
<PackageReference Include="Xamarin.AndroidX.Annotation" Version="1.8.2.1" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.Core.Utils" Version="1.0.0.29" />
<PackageReference Include="Xamarin.Google.Android.InstallReferrer" Version="1.1.2.6" />
<PackageReference Include="Xamarin.AndroidX.Core.Core.Ktx" Version="1.13.1.5" />
<PackageReference Include="Xamarin.Kotlin.StdLib" Version="2.0.21" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion firebase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This folder contains a slim binding for the Firebase SDK which demonstrates simp

### Build and Run
```shell
dotnet build sample -t:Run -f net8.0-ios
dotnet build sample -t:Run -f net9.0-ios
```

### Configure
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<IsBindingProject>true</IsBindingProject>
<NoBindingEmbedding>true</NoBindingEmbedding>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks" Version="$(NLIPackageVersion)" PrivateAssets="all" />
</ItemGroup>
<!--
Enable trim analyzers for class libraries.
To learn more, see: https://learn.microsoft.com/dotnet/core/deploying/trimming/prepare-libraries-for-trimming
-->
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinitions.cs" />
<NLIXcodeProjectReference Include="../native/MauiFirebase.xcodeproj">
<XcodeProject Include="../native/MauiFirebase.xcodeproj">
<SchemeName>MauiFirebase</SchemeName>
<SharpieNamespace>Firebase</SharpieNamespace>
<SharpieBind>true</SharpieBind>
<!-- Metadata applicable to @(NativeReference) will be used if set, otherwise the following defaults will be used:
<Kind>Framework</Kind>
<SmartLink>true</SmartLink>
-->
</NLIXcodeProjectReference>
</XcodeProject>
</ItemGroup>

</Project>
5 changes: 4 additions & 1 deletion firebase/sample/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ public partial class App : Application
public App()
{
InitializeComponent();
}

MainPage = new AppTabbedPage();
protected override Window CreateWindow(IActivationState? activationState)
{
return new Window(new AppTabbedPage());
}
}
17 changes: 8 additions & 9 deletions firebase/sample/Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net9.0-ios;net9.0-maccatalyst</TargetFrameworks>

<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
Expand All @@ -25,10 +26,8 @@
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<MtouchLink>None</MtouchLink>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">13.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -51,17 +50,17 @@

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<BundleResource Include="Platforms\iOS\GoogleService-Info.plist">
<Link>GoogleService-Info.plist</Link>
</BundleResource>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\macios\Firebase.MaciOS.Binding\Firebase.MaciOS.Binding.csproj" />
</ItemGroup>

<ItemGroup>
<BundleResource Include="Platforms\iOS\GoogleService-Info.plist">
<Link>GoogleService-Info.plist</Link>
</BundleResource>
<!-- Exclude when running a generic build in CI where provisioning profiles aren't configured -->
<CustomEntitlements Include="aps-environment" Type="string" Value="development" Condition="'$(Configuration)' == 'Debug' and '$(CI)' != 'true'" />
<CustomEntitlements Include="aps-environment" Type="string" Value="production" Condition="'$(Configuration)' == 'Release' and '$(CI)' != 'true'" />
Expand Down
Loading

0 comments on commit e91dadd

Please sign in to comment.