Skip to content

Commit 00b973b

Browse files
committed
[mobile]Move to net8 MAUI and add MacCatalyst support
1 parent 0de2e66 commit 00b973b

File tree

6 files changed

+104
-16
lines changed

6 files changed

+104
-16
lines changed

mobile/examples/Maui/MauiVisionSample/MauiVisionSample/MauiProgram.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using Microsoft.Extensions.Logging;
5+
46
namespace MauiVisionSample;
57

68
public static class MauiProgram
@@ -15,7 +17,9 @@ public static MauiApp CreateMauiApp()
1517
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
1618
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
1719
});
18-
19-
return builder.Build();
20+
#if DEBUG
21+
builder.Logging.AddDebug();
22+
#endif
23+
return builder.Build();
2024
}
2125
}

mobile/examples/Maui/MauiVisionSample/MauiVisionSample/MauiVisionSample.csproj

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

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>
5-
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
6+
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
7+
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
8+
9+
<!-- Note for MacCatalyst:
10+
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
11+
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
12+
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
13+
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
14+
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->
15+
616
<OutputType>Exe</OutputType>
717
<RootNamespace>MauiVisionSample</RootNamespace>
818
<UseMaui>true</UseMaui>
@@ -21,22 +31,14 @@
2131
<ApplicationVersion>1</ApplicationVersion>
2232

2333
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
34+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
2435
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
2536
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
2637
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
38+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
2739
<DefaultLanguage>en</DefaultLanguage>
2840
</PropertyGroup>
2941

30-
<!--
31-
Short term workaround for issue with publishing the iOS IPA by manually adding CoreML to the frameworks we link against.
32-
https://github.com/microsoft/onnxruntime/issues/12420
33-
-->
34-
<Target Name="AddCoreML" Condition="'$(TargetFramework)' == 'net6.0-ios'" AfterTargets="_LoadLinkerOutput" BeforeTargets="_ComputeLinkNativeExecutableInputs">
35-
<ItemGroup>
36-
<_LinkerFrameworks Include="CoreML" />
37-
</ItemGroup>
38-
</Target>
39-
4042
<ItemGroup>
4143
<!-- App Icon -->
4244
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
@@ -55,8 +57,12 @@
5557
</ItemGroup>
5658

5759
<ItemGroup>
58-
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.12.1" />
59-
<PackageReference Include="SkiaSharp" Version="2.88.6" />
60+
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.18.0-dev-20240323-1233-2c11c10789" />
61+
<PackageReference Include="SkiaSharp" Version="2.88.7" />
62+
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.14" />
63+
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.14" />
64+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
65+
<PackageReference Include="Microsoft.ML.OnnxRuntime.Extensions.Dummy" Version="0.10.0" />
6066
</ItemGroup>
6167

6268
<!--<ItemGroup>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Foundation;
2+
3+
namespace MauiVisionSample;
4+
5+
[Register("AppDelegate")]
6+
public class AppDelegate : MauiUIApplicationDelegate
7+
{
8+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9+
}
10+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<!-- See https://aka.ms/maui-publish-app-store#add-entitlements for more information about adding entitlements.-->
5+
<dict>
6+
<!-- App Sandbox must be enabled to distribute a MacCatalyst app through the Mac App Store. -->
7+
<key>com.apple.security.app-sandbox</key>
8+
<true/>
9+
<!-- When App Sandbox is enabled, this value is required to open outgoing network connections. -->
10+
<key>com.apple.security.network.client</key>
11+
<true/>
12+
</dict>
13+
</plist>
14+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<!-- The Mac App Store requires you specify if the app uses encryption. -->
6+
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/itsappusesnonexemptencryption -->
7+
<!-- <key>ITSAppUsesNonExemptEncryption</key> -->
8+
<!-- Please indicate <true/> or <false/> here. -->
9+
10+
<!-- Specify the category for your app here. -->
11+
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/lsapplicationcategorytype -->
12+
<!-- <key>LSApplicationCategoryType</key> -->
13+
<!-- <string>public.app-category.YOUR-CATEGORY-HERE</string> -->
14+
<key>UIDeviceFamily</key>
15+
<array>
16+
<integer>2</integer>
17+
</array>
18+
<key>UIRequiredDeviceCapabilities</key>
19+
<array>
20+
<string>arm64</string>
21+
</array>
22+
<key>UISupportedInterfaceOrientations</key>
23+
<array>
24+
<string>UIInterfaceOrientationPortrait</string>
25+
<string>UIInterfaceOrientationLandscapeLeft</string>
26+
<string>UIInterfaceOrientationLandscapeRight</string>
27+
</array>
28+
<key>UISupportedInterfaceOrientations~ipad</key>
29+
<array>
30+
<string>UIInterfaceOrientationPortrait</string>
31+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
32+
<string>UIInterfaceOrientationLandscapeLeft</string>
33+
<string>UIInterfaceOrientationLandscapeRight</string>
34+
</array>
35+
<key>XSAppIconAssets</key>
36+
<string>Assets.xcassets/appicon.appiconset</string>
37+
</dict>
38+
</plist>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using ObjCRuntime;
2+
using UIKit;
3+
4+
namespace MauiVisionSample;
5+
6+
public class Program
7+
{
8+
// This is the main entry point of the application.
9+
static void Main(string[] args)
10+
{
11+
// if you want to use a different Application Delegate class from "AppDelegate"
12+
// you can specify it here.
13+
UIApplication.Main(args, null, typeof(AppDelegate));
14+
}
15+
}
16+

0 commit comments

Comments
 (0)