Skip to content

Commit

Permalink
chore: make the SDK not depend on MAUI
Browse files Browse the repository at this point in the history
  • Loading branch information
lassana committed Dec 13, 2023
1 parent c621fdd commit b9d2311
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 71 deletions.
22 changes: 8 additions & 14 deletions DotNet/CobrowseIO/CobrowseIO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

<PropertyGroup>
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios;</TargetFrameworks>
<UseMaui>true</UseMaui>
<SkipValidateMauiImplicitPackageReferences>true</SkipValidateMauiImplicitPackageReferences>
<UseMaui>false</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>false</ImplicitUsings>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>

<Title>Xamarin.CobrowseIO</Title>
Expand All @@ -27,19 +26,14 @@
<CreatePackage>false</CreatePackage>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<ItemGroup Condition="$(TargetFramework.StartsWith('net8.0-android')) != true">
<Compile Remove="Platforms\Android\*.cs" />
<None Include="Platforms\Android\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.10.1.2" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.6.1.3" />
<PackageReference Include="Xamarin.AndroidX.ConstraintLayout" Version="2.1.4.6" />
<PackageReference Include="Square.OkHttp3" Version="4.11.0.3" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Process" Version="2.6.1.3" />
<PackageReference Include="Xamarin.AndroidX.WebKit" Version="1.7.0.1" />
<ItemGroup Condition="$(TargetFramework.StartsWith('net8.0-ios')) != true">
<Compile Remove="Platforms\iOS\*.cs" />
<None Include="Platforms\iOS\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>

<Target Name="FixMauiBug10150" AfterTargets="Build" Condition="'$(TargetFramework)'=='net8.0-android'">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0-ios</TargetFrameworks>
<OutputType>Library</OutputType>
<ApplicationId>io.cobrowse.mauisample.broadcastuploadextension</ApplicationId>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion>12.0</SupportedOSPlatformVersion>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net8.0-ios</TargetFrameworks>
<OutputType>Library</OutputType>
<ApplicationId>io.cobrowse.mauisample.broadcastuploadextension</ApplicationId>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion>12.0</SupportedOSPlatformVersion>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<CreatePackage>false</CreatePackage>
</PropertyGroup>

<PropertyGroup>
<IsAppExtension>true</IsAppExtension>
<IsWatchExtension>false</IsWatchExtension>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<CreatePackage>false</CreatePackage>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\iOS\CobrowseIO.AppExtension.iOS\CobrowseIO.AppExtension.iOS.csproj" />
</ItemGroup>
<PropertyGroup>
<IsAppExtension>true</IsAppExtension>
<IsWatchExtension>false</IsWatchExtension>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\iOS\CobrowseIO.AppExtension.iOS\CobrowseIO.AppExtension.iOS.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Sample/MauiSample/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public App()
{
InitializeComponent();

MainPage = new AppShell();
MainPage = new NavigationPage(new MainPage());

CobrowseIO.Instance.License = "e-73R7b1nIeoFQ";
CobrowseIO.Instance.Api = "https://staging.cobrowse.io";
Expand Down
15 changes: 0 additions & 15 deletions Sample/MauiSample/AppShell.xaml

This file was deleted.

10 changes: 0 additions & 10 deletions Sample/MauiSample/AppShell.xaml.cs

This file was deleted.

5 changes: 2 additions & 3 deletions Sample/MauiSample/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
HorizontalOptions="Center" />

<Label
Text="Hello, World!"
Text="Cobrowse.io SDK"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center" />

<Label
Text="Welcome to .NET Multi-platform App UI"
Text="This label is redacted"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
HorizontalOptions="Center" />

Expand Down
2 changes: 2 additions & 0 deletions Sample/MauiSample/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public partial class MainPage : ContentPage
public MainPage()
{
InitializeComponent();

Title = "Home";
}

private void OnCounterClicked(object sender, EventArgs e)
Expand Down
23 changes: 18 additions & 5 deletions Sample/MauiSample/MauiSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,24 @@

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
<AndroidManifest>Platforms\Android\AndroidManifest.xml</AndroidManifest>
<CodesignEntitlements>Platforms\iOS\Entitlements.plist</CodesignEntitlements>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0-ios'">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<!--
CodesignEntitlements property appears to be ignored in Debug builds.
The following message is printed in the MSBuild output:
> The "CodesignEntitlements" property is a global property, and cannot be modified.
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
The bug is not reproducible in Release builds.
-->
<CodesignEntitlements>Platforms\iOS\Entitlements.plist</CodesignEntitlements>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
Expand All @@ -60,6 +66,13 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
<!--
An Android MAUI app cannot simply rely on the same dependency versions the Cobrowse.io SDK uses.
Instead, the client app _must_ specify the exact versions that MAUI relies on. Otherwise
it leads to duplicate Java classes build errors.
https://github.com/xamarin/AndroidX/issues/764
https://github.com/xamarin/GooglePlayServicesComponents/issues/648
-->
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.10.1.2" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.6.1.3" />
<PackageReference Include="Xamarin.AndroidX.ConstraintLayout" Version="2.1.4.6" />
Expand Down

0 comments on commit b9d2311

Please sign in to comment.