Skip to content

Commit

Permalink
Frontend.Maui: switch to .NET8 for Android
Browse files Browse the repository at this point in the history
Switch to .NET8 to fix bug in Android when using back button
in navigation bar crashes the app. Continue using .NET6 for
GTK.
  • Loading branch information
webwarrior-ws committed Jul 2, 2024
1 parent 7096103 commit 0b14ef9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
35 changes: 21 additions & 14 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,37 @@ on:
# (msbuild bug?)

jobs:
macOS--dotnet6-and-mono:
macOS--dotnet8-and-mono:
runs-on: macOS-12
steps:
- uses: actions/checkout@v1
with:
submodules: false
- name: Setup .NET SDK 6.0.x
- name: Setup .NET SDK 8.0.x
uses: actions/setup-dotnet@v1.7.2
with:
dotnet-version: '6.0.113'
dotnet-version: '8.0.300'
- name: Replace global.json in root dir
run: |
# Use global.json from src/GWallet.Frontend.Maui as it specifies .NET8
cp ./src/GWallet.Frontend.Maui/global.json ./
- name: install maui workload
run: dotnet workload install maui
- name: configure
run: ./configure.sh
- name: build in DEBUG mode
run: make
- name: Build Maui Android frontend
run: |
# first run will give some errors related to Resource, so run build command twice
dotnet build src/GWallet.Frontend.Maui/GWallet.Frontend.Maui.fsproj --framework=net6.0-android || \
dotnet build src/GWallet.Frontend.Maui/GWallet.Frontend.Maui.fsproj --framework=net6.0-android
run: dotnet build src/GWallet.Frontend.Maui/GWallet.Frontend.Maui.fsproj --framework=net8.0-android
- name: Build Android APK
run: |
# first run will give some errors related to Resource, so run build command twice
dotnet publish src/GWallet.Frontend.Maui/GWallet.Frontend.Maui.fsproj --framework net6.0-android --configuration Release || \
dotnet publish src/GWallet.Frontend.Maui/GWallet.Frontend.Maui.fsproj --framework net6.0-android --configuration Release
run: dotnet publish src/GWallet.Frontend.Maui/GWallet.Frontend.Maui.fsproj --framework net8.0-android --configuration Release
# Upload artifact fails with "permission denied" error without this
- name: Fix permissions
run: sudo chmod -R 755 src/GWallet.Frontend.Maui/bin/Release/net6.0-android/publish
run: sudo chmod -R 755 src/GWallet.Frontend.Maui/bin/Release/net8.0-android/publish
- name: Find the APK file's path and name
id: find_apk_file
run: |
FILEPATH=$(ls src/GWallet.Frontend.Maui/bin/Release/net6.0-android/publish/*.apk)
FILEPATH=$(ls src/GWallet.Frontend.Maui/bin/Release/net8.0-android/publish/*.apk)
FILENAME=$(basename $FILEPATH)
echo "file_path=$FILEPATH" >> $GITHUB_OUTPUT
echo "file_name=$FILENAME" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -228,6 +226,10 @@ jobs:
uses: actions/setup-dotnet@v1.7.2
with:
dotnet-version: ${{ env.DotnetVersion }}
- name: Replace global.json in src/GWallet.Frontend.Maui
run: |
# Use global.json from root as it specifies .NET6
cp ./global.json ./src/GWallet.Frontend.Maui/
- name: Install gtk workload
run: |
wget -O gtksharp.net.sdk.gtk.manifest-${{ env.DotnetVersion }}.nupkg https://globalcdn.nuget.org/packages/gtksharp.net.sdk.gtk.manifest-${{ env.DotnetVersion }}.$GtkSharpVersion.nupkg
Expand Down Expand Up @@ -521,7 +523,7 @@ jobs:
- windows--dotnet6-and-legacyFramework
- windows--legacyFramework-only
- windows--dotnet6-only
- macOS--dotnet6-and-mono
- macOS--dotnet8-and-mono
- macOS--mono-only
- macOS--dotnet6-only

Expand Down Expand Up @@ -665,6 +667,11 @@ jobs:
run: |
git submodule foreach git fetch --all && git submodule sync --recursive && git submodule update --init --recursive
dotnet fsi ./scripts/snap_bump.fsx
- name: Replace global.json in src/GWallet.Frontend.Maui
run: |
# Use global.json from root as it specifies .NET6
cp ./global.json ./src/GWallet.Frontend.Maui/
- name: Generate snap package
run: ./scripts/snap_build_maui.sh || (cat /home/runner/.local/state/snapcraft/log/*.log && exit 1)
Expand Down
4 changes: 2 additions & 2 deletions scripts/make.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ let DotNetBuild
// https://github.com/fabulous-dev/FSharp.Mobile.Templates/tree/55a1f3a0fd5cc397e48677ef4ff9241b360b0e84
let BuildMauiProject binaryConfig =
let mauiProjectFilePath = FrontendProject.Maui.GetProjectFile().FullName
DotNetBuild mauiProjectFilePath binaryConfig "--framework net6.0-android" true
DotNetBuild mauiProjectFilePath binaryConfig "--framework net6.0-android" false
DotNetBuild mauiProjectFilePath binaryConfig "--framework net8.0-android" true
DotNetBuild mauiProjectFilePath binaryConfig "--framework net8.0-android" false

let JustBuild binaryConfig maybeConstant: FrontendApp*FileInfo =
let maybeBuildTool = Map.tryFind "BuildTool" buildConfigContents
Expand Down
12 changes: 3 additions & 9 deletions src/GWallet.Frontend.Maui/GWallet.Frontend.Maui.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<!-- NOTE: when making changes to the lines below, maybe remove CheckEolWorkloads tag too -->
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('linux'))">net6.0-gtk</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
Expand Down Expand Up @@ -40,11 +40,6 @@
<CheckEolWorkloads>false</CheckEolWorkloads>
</PropertyGroup>

<!-- workaround for https://github.com/xamarin/xamarin-android/issues/6101 -->
<PropertyGroup>
<GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles>
</PropertyGroup>

<!-- workaround for https://github.com/dotnet/maui/discussions/15540 (VS4Mac build, not happening in CI) -->
<PropertyGroup>
<MtouchLink>SdkOnly</MtouchLink>
Expand Down Expand Up @@ -219,6 +214,7 @@

<ItemGroup>
<PackageReference Include="FSharp.Core" Version="6.0.3" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.21" />
</ItemGroup>

<ItemGroup Condition="$(TargetPlatformIdentifier) != 'gtk'">
Expand All @@ -244,8 +240,6 @@
<AndroidManifest Include="$(AndroidProjectFolder)AndroidManifest.xml" />
<Compile Include="$(AndroidProjectFolder)MainActivity.fs" />
<Compile Include="$(AndroidProjectFolder)MainApplication.fs" />

<PackageReference Include="FSharp.Android.Resource" Version="1.0.4" />
</ItemGroup>

<ItemGroup Condition="$(TargetPlatformIdentifier) == 'ios'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ open Microsoft.Maui
type MainApplication(handle, ownership) =
inherit MauiApplication(handle, ownership)

do GWallet.Frontend.Maui.Resource.UpdateIdValues()

override _.CreateMauiApp() = MauiProgram.CreateMauiApp()
4 changes: 2 additions & 2 deletions src/GWallet.Frontend.Maui/global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.113",
"version": "8.0.0",
"rollForward": "latestMinor"
}
}
}

0 comments on commit 0b14ef9

Please sign in to comment.