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 / XShellUninstallVS.txt
Created December 14, 2013 00:18
Fixing the Xamarin installation after uninstalling the "Xamarin Shell" extension from "Tools -> Extensions and Updates" in Visual Studio
If you uninstall the "Xamarin Shell" extension from "Tools -> Extensions and Updates" in Visual Studio, you will get a "'ShellPackage' package did not load correctly" error even after uninstalling and re-installing both Xamarin VS extensions.
## Cause
Uninstalling the "Xamarin Shell" from "Tools -> Extensions and Updates" sets a value on [1] named "Mono.VisualStudio.Shell,1.0", with the data:
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\COMMON7\IDE\EXTENSIONS\XAMARIN\SHELL\1.0.0\
[1] Computer\HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\ExtensionManager\PendingDeletions
@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 / 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. -->
@brendanzagaeski
brendanzagaeski / TestAppViewController.cs
Last active September 19, 2016 16:38
Obtaining the subnet mask of network interfaces on Xamarin.iOS and Xamarin.Mac
// Obtaining the subnet mask of network interfaces on Xamarin.iOS and Xamarin.Mac
//
// On Xamarin.iOS and Xamarin.Mac, `NetworkInterface.OperationalStatus` always
// returns: `OperationalStatus.Unknown`
// https://github.com/mono/mono/blob/f48ceb9860676c342f4c91fbc2e34ea600d839c6/mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs#L552-L556
//
// Additionally, on all "Linux-like" platforms, including iOS and Mac,
// `UnicastIPAddressInformation.IPv4Mask` is not implemented
// https://github.com/mono/mono/blob/f48ceb9860676c342f4c91fbc2e34ea600d839c6/mcs/class/System/System.Net.NetworkInformation/UnicastIPAddressInformation.cs#L165-L167
//
@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 / FetchRepositoriesWithCompletionArgsAction.cs
Created January 10, 2014 06:16
Example of a generated Task return value for `[Async (ResultTypeName = "FetchRepositoriesWithCompletionArgs")]`, using `Action<bool, NSError, NSArray>` as the delegate type. This results in generic return value names like "Arg1".
public class FetchRepositoriesWithCompletionArgs {
public bool Arg1 { get; set; }
public NSError Arg2 { get; set; }
public NSArray Arg3 { get; set; }
public FetchRepositoriesWithCompletionArgs (bool arg1, NSError arg2, NSArray arg3) {
this.Arg1 = arg1;
this.Arg2 = arg2;
this.Arg3 = arg3;
}
@brendanzagaeski
brendanzagaeski / FetchRepositoriesWithCompletionArgsNamed.cs
Created January 10, 2014 06:12
Example of a generated Task return value for `[Async (ResultTypeName = "FetchRepositoriesWithCompletionArgs")]` using a named delegate. The names of the return values match the names of the delegate's arguments.
public class FetchRepositoriesWithCompletionArgs {
public bool Success { get; set; }
public NSError Error { get; set; }
public NSArray Repositories { get; set; }
public FetchRepositoriesWithCompletionArgs (bool success, NSError error, NSArray repositories) {
this.Success = success;
this.Error = error;
this.Repositories = repositories;
}
@brendanzagaeski
brendanzagaeski / SafariHistoryPlist.cs
Created December 10, 2013 17:35
Read Safari History.plist using NSPropertyListSerialization in Xamarin C#. See https://github.com/animetrics/PlistCS or http://www.codeproject.com/Tips/406235/A-Simple-PList-Parser-in-Csharp for pure C# alternatives.
var plistFile = System.IO.File.OpenRead("/Users/anyuser/Library/Safari/History.plist");
NSPropertyListFormat format = NSPropertyListFormat.Binary;
NSError error;
NSData plistXml = NSData.FromStream(plistFile);
plistFile.Close();
var plistObject = (NSDictionary)NSPropertyListSerialization.PropertyListWithData (
plistXml,
NSPropertyListReadOptions.MutableContainersAndLeaves,
@brendanzagaeski
brendanzagaeski / gist:7817256
Last active December 30, 2015 10:39
Two common build errors about missing properties for new projects in Xamarin.iOS

"Error Application Name is not set in iOS Application Property Page"

"Error Identifier is not set in iOS Application Property Page"

To fix this problem, open the Project Properties, and under the "iOS Application" tab, fill in the "Application Name", "Identifier", and "Version" fields (see also the screenshot of the "Project Properties" -> "iOS Application" settings in the Xamarin docs)

@brendanzagaeski
brendanzagaeski / add_play_services.bat
Created December 4, 2013 01:34
Windows translation of add_play_services.sh. Pseudo-batchfile.
mkdir google-play-services_lib
cd google-play-services_lib
xcopy C:\Users\_your_username_\AppData\Local\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib .
C:\Users\_your_username_\AppData\Local\Android\android-sdk\tools\android update project -p .
REM Get Ant from http://ant.apache.org/bindownload.cgi
set PATH="%PATH%";"C:\Program Files (x86)\Java\jdk1.6.0_39\bin"
C:\_path_\_to_\ant.bat release