Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
feat: Add MAUI Support and update iOS/Android SDKs to latest (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonStalnaker authored Aug 14, 2024
1 parent 0a10c8c commit ff98269
Show file tree
Hide file tree
Showing 343 changed files with 60,088 additions and 1,285 deletions.
38 changes: 16 additions & 22 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,22 @@ on:

jobs:
Build:
runs-on: macos-10.15
runs-on: macOS-14
steps:
- uses: actions/checkout@v1
- name: Build artifacts
run: ./build.sh

Android:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v1
- name: Android
- uses: actions/checkout@v4
- name: Install Mono Framework
run: |
nuget restore
cd Samples/mParticle.Xamarin.Android.Sample
msbuild
iOS:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v1
- name: iOS
curl https://download.mono-project.com/archive/6.12.0/macos-10-universal/MonoFramework-MDK-6.12.0.206.macos10.xamarin.universal.pkg -o /tmp/MonoFramework-MDK-6.12.0.206.macos10.xamarin.universal.pkg
sudo installer -pkg /tmp/MonoFramework-MDK-6.12.0.206.macos10.xamarin.universal.pkg -target /
- name: Install Xamarin Android Framework
run: |
nuget restore
cd Samples/mParticle.Xamarin.iOS.Sample
msbuild
curl https://download.visualstudio.microsoft.com/download/pr/8cbf56b1-ef0d-466f-8cfe-fae4ba8c5080/e9e853fee3169b1c5128098942f19120/xamarin.android-13.2.2.0.pkg -o /tmp/xamarin.android-13.2.2.0.pkg
sudo installer -pkg /tmp/xamarin.android-13.2.2.0.pkg -target /
- name: Install Xamarin iOS Framework
run: |
curl https://download.visualstudio.microsoft.com/download/pr/ceb0ea3f-4db8-46b4-8dc3-8049d27c0107/3960868aa9b1946a6c77668c3f3334ee/xamarin.ios-16.4.0.23.pkg -o /tmp/xamarin.ios-16.4.0.23.pkg
sudo installer -pkg /tmp/xamarin.ios-16.4.0.23.pkg -target /
- name: Install MAUI workload
run: dotnet workload install maui
- name: Build artifacts
run: ./build.sh
41 changes: 21 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,32 @@ on:
workflow_dispatch:

jobs:
# SDK release is done from public/master branch.
confirm-master-branch:
name: Confirm release is run on public/master branch
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Branch name
run: |
BRANCHNAME=${GITHUB_REF##*/}
echo "pulling branch name, branch name is:"
echo $BRANCHNAME
if [ $BRANCHNAME != "master" ]
then
echo "You can only run a release from the master branch, you are trying to run it from ${BRANCHNAME}"
exit 1
fi
# SDK release is done from main branch.
confirm-main-branch:
name: Confirm release is run from main branch
uses: mParticle/mparticle-workflows/.github/workflows/sdk-release-repo-branch-check.yml@stable

release-to-nuget:
name: Release and Sync Repos
runs-on: macos-10.15
needs: ['confirm-master-branch']
runs-on: macos-14
needs: ['confirm-main-branch']
steps:
- name: Git checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Mono Framework
run: |
curl https://download.mono-project.com/archive/6.12.0/macos-10-universal/MonoFramework-MDK-6.12.0.206.macos10.xamarin.universal.pkg -o /tmp/MonoFramework-MDK-6.12.0.206.macos10.xamarin.universal.pkg
sudo installer -pkg /tmp/MonoFramework-MDK-6.12.0.206.macos10.xamarin.universal.pkg -target /
- name: Install Xamarin Android Framework
run: |
curl https://download.visualstudio.microsoft.com/download/pr/8cbf56b1-ef0d-466f-8cfe-fae4ba8c5080/e9e853fee3169b1c5128098942f19120/xamarin.android-13.2.2.0.pkg -o /tmp/xamarin.android-13.2.2.0.pkg
sudo installer -pkg /tmp/xamarin.android-13.2.2.0.pkg -target /
- name: Install Xamarin iOS Framework
run: |
curl https://download.visualstudio.microsoft.com/download/pr/ceb0ea3f-4db8-46b4-8dc3-8049d27c0107/3960868aa9b1946a6c77668c3f3334ee/xamarin.ios-16.4.0.23.pkg -o /tmp/xamarin.ios-16.4.0.23.pkg
sudo installer -pkg /tmp/xamarin.ios-16.4.0.23.pkg -target /
- name: Install MAUI workload
run: dotnet workload install maui
- name: Build artifacts
run: ./build.sh
- name: Release to Nuget
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ publish

# NuGet Packages Directory
packages
*.nupkg

# Windows Azure Build Output
csx
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Additions allow you to add arbitrary C# to the generated classes
before they are compiled. This can be helpful for providing convenience
methods or adding pure C# classes.

== Adding Methods to Generated Classes ==

Let's say the library being bound has a Rectangle class with a constructor
that takes an x and y position, and a width and length size. It will look like
this:

public partial class Rectangle
{
public Rectangle (int x, int y, int width, int height)
{
// JNI bindings
}
}

Imagine we want to add a constructor to this class that takes a Point and
Size structure instead of 4 ints. We can add a new file called Rectangle.cs
with a partial class containing our new method:

public partial class Rectangle
{
public Rectangle (Point location, Size size) :
this (location.X, location.Y, size.Width, size.Height)
{
}
}

At compile time, the additions class will be added to the generated class
and the final assembly will a Rectangle class with both constructors.


== Adding C# Classes ==

Another thing that can be done is adding fully C# managed classes to the
generated library. In the above example, let's assume that there isn't a
Point class available in Java or our library. The one we create doesn't need
to interact with Java, so we'll create it like a normal class in C#.

By adding a Point.cs file with this class, it will end up in the binding library:

public class Point
{
public int X { get; set; }
public int Y { get; set; }
}
Binary file not shown.
15 changes: 15 additions & 0 deletions Bindings/mParticle.MAUI.AndroidBinding/Transforms/EnumFields.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<enum-field-mappings>
<!--
This example converts the constants Fragment_id, Fragment_name,
and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
to an enum called Android.Support.V4.App.FragmentTagType with values
Id, Name, and Tag.
<mapping jni-class="android/support/v4/app/FragmentActivity$FragmentTag" clr-enum-type="Android.Support.V4.App.FragmentTagType">
<field jni-name="Fragment_name" clr-name="Name" value="0" />
<field jni-name="Fragment_id" clr-name="Id" value="1" />
<field jni-name="Fragment_tag" clr-name="Tag" value="2" />
</mapping>
-->
</enum-field-mappings>

14 changes: 14 additions & 0 deletions Bindings/mParticle.MAUI.AndroidBinding/Transforms/EnumMethods.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<enum-method-mappings>
<!--
This example changes the Java method:
android.support.v4.app.Fragment.SavedState.writeToParcel (int flags)
to be:
android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags)
when bound in C#.
<mapping jni-class="android/support/v4/app/Fragment.SavedState">
<method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
</mapping>
-->
</enum-method-mappings>

Loading

0 comments on commit ff98269

Please sign in to comment.