Skip to content

Commit e91dadd

Browse files
authored
Updates for net9.0 (#55)
Context: dotnet/android@dbdc5fa Context: dotnet/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.
1 parent ac7ec25 commit e91dadd

40 files changed

+119
-998
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,30 @@ on:
1010
jobs:
1111
build:
1212
name: build
13-
runs-on: macos-14
13+
runs-on: macos-15
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v3
1717

18-
- name: Use .NET 8.x
18+
- name: Use .NET 9.0.x
1919
uses: actions/setup-dotnet@v4
2020
with:
21-
dotnet-version: '8.x'
21+
dotnet-version: 9.0.x
2222

2323
- name: Install JDK 17
2424
uses: actions/setup-java@v4
2525
with:
2626
distribution: microsoft
2727
java-version: 17
2828

29-
- name: Use Xcode 15.4
30-
run: sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer
29+
- name: Setup Android SDK
30+
uses: android-actions/setup-android@v3
31+
with:
32+
cmdline-tools-version: 11076708
33+
packages: 'build-tools;35.0.0'
34+
35+
- name: Use Xcode 16.0
36+
run: sudo xcode-select -s /Applications/Xcode_16.app/Contents/Developer
3137

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

47-
- name: Create local nupkg dir
48-
run: mkdir -p ./src/CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks/bin/Release
49-
50-
- name: Build and test build tasks
51-
working-directory: ./src
52-
run: >-
53-
dotnet test CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks.sln
54-
--logger trx --results-directory ${{ runner.temp }}/logs/TestResults-build-tasks
55-
-bl:${{ runner.temp }}/logs/build-tasks.binlog
56-
57-
- name: Pack build tasks
58-
working-directory: ./src/CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks
59-
run: dotnet pack CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks.csproj -bl:${{ runner.temp }}/logs/build-tasks-pack.binlog
60-
61-
- name: Upload nupkg
62-
uses: actions/upload-artifact@v4
63-
with:
64-
name: nupkg
65-
path: ./src/CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks/bin/Release/*.nupkg
66-
6753
- name: Build template
6854
working-directory: ./template
6955
run: dotnet build -bl:${{ runner.temp }}/logs/template.binlog

Directory.Build.props

Lines changed: 0 additions & 10 deletions
This file was deleted.

facebook/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ This folder contains a slim binding for the Facebook SDK which demonstrates simp
33

44
### Build and Run
55
```shell
6-
dotnet build sample -t:Run -f net8.0-android
7-
dotnet build sample -t:Run -f net8.0-ios
6+
dotnet build sample -t:Run -f net9.0-android
7+
dotnet build sample -t:Run -f net9.0-ios
88
```
99

1010
### Configure
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0-android</TargetFramework>
3+
<TargetFramework>net9.0-android</TargetFramework>
44
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
7+
<!--
8+
Enable trim analyzers for Android class libraries.
9+
To learn more, see: https://learn.microsoft.com/dotnet/core/deploying/trimming/prepare-libraries-for-trimming
10+
-->
11+
<IsTrimmable>true</IsTrimmable>
712
<RootNamespace>Facebook</RootNamespace>
8-
<AndroidGenerateResourceDesigner>false</AndroidGenerateResourceDesigner>
913
</PropertyGroup>
1014

1115
<ItemGroup>
12-
<PackageReference Include="CommunityToolkit.Maui.NativeLibraryInterop.BuildTasks" Version="$(NLIPackageVersion)" PrivateAssets="all" />
13-
</ItemGroup>
14-
15-
<ItemGroup>
16-
<NLIGradleProjectReference Include="../native" >
16+
<AndroidGradleProject Include="../native/build.gradle.kts" >
1717
<ModuleName>mauifacebook</ModuleName>
1818
<!-- Metadata applicable to @(AndroidLibrary) will be used if set, otherwise the following defaults will be used:
1919
<Bind>true</Bind>
2020
<Pack>true</Pack>
2121
-->
22-
</NLIGradleProjectReference>
22+
</AndroidGradleProject>
2323
</ItemGroup>
2424

2525
</Project>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
plugins {
3-
id("com.android.library") version "8.2.2" apply false
3+
id("com.android.library") version "8.6.1" apply false
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Fri Feb 02 10:15:22 GMT 2024
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

facebook/android/native/mauifacebook/build.gradle.kts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,9 @@ android {
2525
}
2626
}
2727

28-
configurations {
29-
create("copyDependencies")
30-
}
31-
3228
dependencies {
3329
implementation("androidx.appcompat:appcompat:1.6.1")
3430
implementation("com.google.android.material:material:1.11.0")
35-
implementation("com.facebook.android:facebook-android-sdk:latest.release")
36-
"copyDependencies"("com.facebook.android:facebook-android-sdk:latest.release")
31+
implementation("com.facebook.android:facebook-android-sdk:17.0.2")
3732
}
3833

39-
project.afterEvaluate {
40-
tasks.register<Copy>("copyDeps") {
41-
from(configurations["copyDependencies"])
42-
into("${buildDir}/outputs/deps")
43-
}
44-
tasks.named("preBuild") { finalizedBy("copyDeps") }
45-
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0-ios</TargetFramework>
3+
<TargetFramework>net9.0-ios</TargetFramework>
44
<Nullable>enable</Nullable>
55
<ImplicitUsings>true</ImplicitUsings>
66
<IsBindingProject>true</IsBindingProject>
7-
</PropertyGroup>
87

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

1315
<ItemGroup>
1416
<ObjcBindingApiDefinition Include="ApiDefinitions.cs"/>
15-
<NLIXcodeProjectReference Include="../native/MauiFacebook.xcodeproj">
17+
<XcodeProject Include="../native/MauiFacebook.xcodeproj">
1618
<SchemeName>MauiFacebook</SchemeName>
17-
<SharpieNamespace>Facebook</SharpieNamespace>
18-
<SharpieBind>true</SharpieBind>
1919
<!-- Metadata applicable to @(NativeReference) will be used if set, otherwise the following defaults will be used:
2020
<Kind>Framework</Kind>
2121
<SmartLink>true</SmartLink>
2222
-->
23-
</NLIXcodeProjectReference>
23+
</XcodeProject>
2424
</ItemGroup>
2525

2626
</Project>

facebook/sample/App.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ public partial class App : Application
55
public App()
66
{
77
InitializeComponent();
8+
}
89

9-
MainPage = new AppShell();
10+
protected override Window CreateWindow(IActivationState? activationState)
11+
{
12+
return new Window(new AppShell());
1013
}
1114
}

facebook/sample/Sample.csproj

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

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

29-
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
30-
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
29+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
30+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
3131
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
32-
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
33-
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
34-
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
3532
</PropertyGroup>
3633

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

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

4441
<!-- Images -->
45-
<MauiImage Include="Resources\Images\*"/>
46-
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185"/>
42+
<MauiImage Include="Resources\Images\*" />
43+
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
4744

4845
<!-- Custom Fonts -->
49-
<MauiFont Include="Resources\Fonts\*"/>
46+
<MauiFont Include="Resources\Fonts\*" />
5047

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

5552
<ItemGroup>
56-
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)"/>
57-
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)"/>
53+
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
54+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
5855
</ItemGroup>
5956

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

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

8174
</Project>

0 commit comments

Comments
 (0)