Skip to content

Instantly share code, notes, and snippets.

View brendanzagaeski's full-sized avatar

Brendan Zagaeski brendanzagaeski

  • Microsoft
  • Boston, MA, United States
View GitHub Profile
@brendanzagaeski
brendanzagaeski / XamarinVSiOSAppStore.md
Last active May 8, 2018 02:34
A couple ways to submit (publish, upload) a Visual Studio Xamarin.iOS app to the App Store

A couple ways to submit (publish, upload) a Visual Studio Xamarin.iOS app to the App Store

Option 1: upload an IPA created via the "Build Adhoc IPA" command

  1. Pick the "Ad-Hoc" build configuration.

  2. Change the provisioning profile in "project options -> iOS Bundle Signing" to an AppStore provisioning profile.

  3. Rebuild the project.

@brendanzagaeski
brendanzagaeski / gist:9337026
Last active January 30, 2025 17:31
Prevent the Xamarin.Android bindings generator from converting a get or set method to a property
# Prevent the Xamarin.Android bindings generator from converting a `get` or `set` method to a property
Xamarin.Android Java bindings projects will by default automatically bind any Java method that starts with "get" to be the getter of a C# property. To prevent this in specific cases, you can set the `propertyName` attribute of the method to the empty string. The same is true for methods that start with "set", except that they will only be converted to property setters if there is already a corresponding property getter. This requirement prevents the creation of set-only properties (see also http://msdn.microsoft.com/en-us/library/ms229006.aspx).
So for example, you would add something like the following to the Metadata.xml file:
```
<attr path="/api/package[@name='com.example.testandroidlib']/class[@name='MyClass']/method[@name='getNumberTen']" name="propertyName"></attr>
```
@brendanzagaeski
brendanzagaeski / AndHUDNullCheck.patch
Created March 5, 2014 20:42
Patch to prevent NullReferenceException in AndHUD
diff --git a/AndHUD/AndHUD.cs b/AndHUD/AndHUD.cs
index 2022fcb..6d57870 100644
--- a/AndHUD/AndHUD.cs
+++ b/AndHUD/AndHUD.cs
@@ -222,10 +222,12 @@ namespace AndroidHUD
}
else
{
- Application.SynchronizationContext.Post(state => {
- progressWheel.SetProgress (progress);
@brendanzagaeski
brendanzagaeski / gist:9378181
Last active February 11, 2016 21:16
Xamarin.Android.Support vs. Mono.Android.Support: use Xamarin.Android.Support
Recommendation: use the Xamarin.Android.Support.* components instead of the Mono.Android.Support.* libraries
As discussed on [1], the Xamarin.Android.Support.* components are now recommended over the Mono.Android.Support.* libraries. One reason for this is that the Xamarin.Android.Support components can be updated more frequently to keep pace with new releases from Google. Eventually, the Mono.Android.Support will be removed from Xamarin.Android. All new code should use the Xamarin.Android.Support libraries.
[1] https://bugzilla.xamarin.com/show_bug.cgi?id=15205
## Xamarin.Android.Support components in binding projects
At the moment, there's a limitation with using Xamarin.Android.Support components in Xamarin.Android Java binding projects. Specifically, the bindings projects do not yet "know" how to automatically reference the `.jar` files used by the components. This leads to error messages like:
@brendanzagaeski
brendanzagaeski / gist:9417060
Last active January 8, 2019 09:25
NullReferenceException in ClientRuntimeChannel constructor on Xamarin.Android 4.12

To solve both of the problems from the stack traces below, follow these steps:

  1. Add the following to an XML file in the project:

    <?xml version="1.0" encoding="utf-8" ?>
    <linker>
    	<assembly fullname="System.ServiceModel">
    		<type fullname="System.ServiceModel.Channels.ChannelFactoryBase`1">
    
    
@brendanzagaeski
brendanzagaeski / Metadata.xml
Last active December 7, 2021 14:22
Some Metadata.xml fixes for binding the Socialize Android SDK (http://getsocialize.com/sdk/) in Xamarin.Android
<metadata>
<!-- Some Metadata.xml fixes for binding the Socialize Android SDK (http://getsocialize.com/sdk/) in Xamarin.Android
Note that this is not a complete set of fixes. These changes only address the first round of compile errors. -->
<!-- Fixes for duplicate EventArgs, as discussed on:
http://docs.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/#Problem_Duplicate_custom_EventArgs_types
Error message: Error CS0102: The type `SomeClass` already contains a definition for `p0' (CS0102) -->
<attr path="/api/package[@name='com.socialize.auth.twitter']/interface[@name='TwitterAuthListener']/method[@name='onError' and count(parameter)=1 and parameter[1][@type='com.socialize.error.SocializeException']]" name="argsType">AuthTwitterErrorEventArgs</attr>
<attr path="/api/package[@name='com.socialize.facebook']/interface[@name='Facebook.DialogListener']/method[@name='onComplete' and count(parameter)=1 and parameter[1][@type='android.os.Bundle
@brendanzagaeski
brendanzagaeski / Socialize.cs
Created March 17, 2014 23:16
Hand-adjusted binding for `Socialize.SocializeActivityLifecycleListener` property in the Socialize Android SDK. Works around https://bugzilla.xamarin.com/show_bug.cgi?id=17788 ("Error CS1061: Type ... does not contain a definition for `Handler' and no extension method `Handler'..." and "Error CS1729: The type ... does not contain a constructor t…
using System;
using Android.Runtime;
namespace Com.Socialize
{
public partial class Socialize
{
static IntPtr id_getSocializeActivityLifecycleListener;
static IntPtr id_setSocializeActivityLifecycleListener_Lcom_socialize_ui_SocializeActivityLifecycleListener_;
@brendanzagaeski
brendanzagaeski / TwitterAuthWebView.cs
Created March 18, 2014 18:26
Work around for Xamarin.Android binding of methods in the Socialize SDK's `ITwitterAuthWebView` that are inherited as properties from `WebView`
using System;
using Android.Views;
using Android.Webkit;
namespace Com.Socialize.Auth.Twitter
{
/// <summary>
/// Use "wrapper" methods to work around these two binding errors:
/// Error message: Error CS0535: `Com.Socialize.Auth.Twitter.TwitterAuthWebView' does not implement interface member `Com.Socialize.Auth.Twitter.ITwitterAuthWebView.SetLayoutParams(Android.Views.ViewGroup.LayoutParams)' (CS0535)
/// Error message: Error CS0535: `Com.Socialize.Auth.Twitter.TwitterAuthWebView' does not implement interface member `Com.Socialize.Auth.Twitter.ITwitterAuthWebView.SetVisibility(int)' (CS0535)
@brendanzagaeski
brendanzagaeski / gist:9679610
Created March 21, 2014 04:37
Xamarin.iOS does not support the System.Dynamic namespace
# Xamarin.iOS does not support the System.Dynamic namespace [1]
[1] http://docs.xamarin.com/guides/ios/advanced_topics/limitations/#No_Dynamic_Code_Generation
This also means that Xamarin.iOS app projects cannot use PCLs that depend on System.Dynamic.
## Error messages when trying to use a PCL that depends on System.Dynamic
### Visual Studio, without the Xamarin.iOS `System.Dynamic.Runtime` facade assembly (see also [2])
@brendanzagaeski
brendanzagaeski / Metadata.xml
Created March 28, 2014 14:22
Metadata transforms to remove warnings in Xamarin.Android Flurry SDK binding
<metadata>
<!-- warning BG8401: Skipping Com.Flurry.Sdk.Cf.D, due to a duplicate field, method or nested type name-->
<!-- warning BG8401: Skipping Com.Flurry.Sdk.Cf.F, due to a duplicate field, method or nested type name-->
<!-- warning BG8401: Skipping Com.Flurry.Sdk.Cf.G, due to a duplicate field, method or nested type name-->
<remove-node path="/api/package[@name='com.flurry.sdk']/class[@name='cf']" />
<!-- warning BG8401: Skipping Com.Flurry.Sdk.Eh.A, due to a duplicate field, method or nested type name-->
<remove-node path="/api/package[@name='com.flurry.sdk']/class[@name='eh']" />
<!-- Warning BG8C00: For type Com.Flurry.Sdk.Bx, base interface com.flurry.sdk.cl.a does not exist. -->