func GetMtouchArch(propertyGroup PropertyGroup) (string, error) {
	length := len(propertyGroup.MtouchArch)
	if length > 0 {
		return propertyGroup.MtouchArch[length-1], nil
	}
	return "", fmt.Errorf(getterErrorMsg, "mtouchArch")
}
GetMtouchArch gets the MtouchArch from the given property group.
package project
import (
	"encoding/xml"
	"fmt"
	"path/filepath"
	"regexp"
	"strings"
	"github.com/bitrise-io/go-utils/fileutil"
	"github.com/bitrise-io/go-utils/log"
	"github.com/bitrise-io/go-xamarin/constants"
	"github.com/bitrise-io/go-xamarin/utility"
)
type Project struct {
	XMLName        xml.Name        `xml:"Project"`
	Text           string          `xml:",chardata"`
	DefaultTargets string          `xml:"DefaultTargets,attr"`
	ToolsVersion   string          `xml:"ToolsVersion,attr"`
	Xmlns          string          `xml:"xmlns,attr"`
	PropertyGroups []PropertyGroup `xml:"PropertyGroup"`
	ItemGroups     []ItemGroup     `xml:"ItemGroup"`
	Imports        []Import        `xml:"Import"`
}
type Import struct {
	Text      string `xml:",chardata"`
	Project   string `xml:"Project,attr"`
	Label     string `xml:"Label,attr"`
	Condition string `xml:"Condition,attr"`
}
type PropertyGroup struct {
	XMLName       xml.Name `xml:"PropertyGroup"`
	Text          string   `xml:",chardata"`
	Condition     string   `xml:"Condition,attr"`
	Configuration []struct {
		Text      string `xml:",chardata"`
		Condition string `xml:"Condition,attr"`
	} `xml:"Configuration"`
	Platform []struct {
		Text      string `xml:",chardata"`
		Condition string `xml:"Condition,attr"`
	} `xml:"Platform"`
	ProjectGUID               []string `xml:"ProjectGuid"`
	ProjectTypeGuids          []string `xml:"ProjectTypeGuids"`
	OutputType                []string `xml:"OutputType"`
	RootNamespace             []string `xml:"RootNamespace"`
	AssemblyName              []string `xml:"AssemblyName"`
	TargetFrameworkVersion    []string `xml:"TargetFrameworkVersion"`
	AndroidApplication        []string `xml:"AndroidApplication"`
	AndroidManifest           []string `xml:"AndroidManifest"`
	AndroidResgenFile         []string `xml:"AndroidResgenFile"`
	AndroidResgenClass        []string `xml:"AndroidResgenClass"`
	MonoAndroidResourcePrefix []string `xml:"MonoAndroidResourcePrefix"`
	MonoAndroidAssetsPrefix   []string `xml:"MonoAndroidAssetsPrefix"`
	DebugSymbols              []string `xml:"DebugSymbols"`
	DebugType                 []string `xml:"DebugType"`
	Optimize                  []string `xml:"Optimize"`
	OutputPath                []string `xml:"OutputPath"`
	DefineConstants           []string `xml:"DefineConstants"`
	ErrorReport               []string `xml:"ErrorReport"`
	WarningLevel              []string `xml:"WarningLevel"`
	AndroidLinkMode           []string `xml:"AndroidLinkMode"`
	AndroidManagedSymbols     []string `xml:"AndroidManagedSymbols"`
	AndroidUseSharedRuntime   []string `xml:"AndroidUseSharedRuntime"`
	MandroidI18n              []string `xml:"MandroidI18n"`
	MtouchArch                []string `xml:"MtouchArch"`
	AndroidSupportedAbis      []string `xml:"AndroidSupportedAbis"`
	BuildIpa                  []string `xml:"BuildIpa"`
	AndroidKeyStore           []string `xml:"AndroidKeyStore"`
}
type ItemGroup struct {
	XMLName   xml.Name `xml:"ItemGroup"`
	Text      string   `xml:",chardata"`
	Reference []struct {
		Text    string `xml:",chardata"`
		Include string `xml:"Include,attr"`
	} `xml:"Reference"`
	ProjectReferences []ProjReference `xml:"ProjectReference"`
	Compile           []struct {
		Text    string `xml:",chardata"`
		Include string `xml:"Include,attr"`
	} `xml:"Compile"`
	None []struct {
		Text    string `xml:",chardata"`
		Include string `xml:"Include,attr"`
	} `xml:"None"`
	AndroidResource []struct {
		Text    string `xml:",chardata"`
		Include string `xml:"Include,attr"`
	} `xml:"AndroidResource"`
}
type ProjReference struct {
	XMLName                 xml.Name `xml:"ProjectReference"`
	Text                    string   `xml:",chardata"`
	Include                 string   `xml:"Include,attr"`
	Project                 string   `xml:"Project"`
	Name                    string   `xml:"Name"`
	ReferenceOutputAssembly string   `xml:"ReferenceOutputAssembly"`
	Private                 string   `xml:"Private"`
}
const getterErrorMsg = "could not find %s"
func ParseProjectContent(content string) (Project, error) {
	var project Project
	if err := xml.Unmarshal([]byte(content), &project); err != nil {
		return Project{}, fmt.Errorf("failed to unmarshall conent. Error: %v", err)
	}
	return project, nil
}
func ParseProject(path string) (Project, error) {
	projectDefinitionFileContent, err := fileutil.ReadStringFromFile(path)
	if err != nil {
		return Project{}, fmt.Errorf("failed to parse project at (%s), error: %s", path, err)
	}
	return ParseProjectContent(projectDefinitionFileContent)
}
func GetProjectGUID(project Project) (string, error) {
	for _, propertyGroup := range project.PropertyGroups {
		length := len(propertyGroup.ProjectGUID)
		if length > 0 {
			guid := propertyGroup.ProjectGUID[length-1]
			return strings.ToUpper(trimIDFixes(guid)), nil
		}
	}
	return "", fmt.Errorf(getterErrorMsg, "project guid")
}
func GetOutputType(project Project) (string, error) {
	for _, propertyGroup := range project.PropertyGroups {
		length := len(propertyGroup.OutputType)
		if length > 0 {
			return strings.ToLower(propertyGroup.OutputType[length-1]), nil
		}
	}
	return "", fmt.Errorf(getterErrorMsg, "project guid")
}
func GetAssemblyName(project Project) (string, error) {
	for _, propertyGroup := range project.PropertyGroups {
		length := len(propertyGroup.AssemblyName)
		if length > 0 {
			return propertyGroup.AssemblyName[length-1], nil
		}
	}
	return "", fmt.Errorf(getterErrorMsg, "assembly name")
}
func GetAndroidManifestPath(project Project) (string, error) {
	for _, propertyGroup := range project.PropertyGroups {
		length := len(propertyGroup.AndroidManifest)
		if length > 0 {
			return propertyGroup.AndroidManifest[length-1], nil
		}
	}
	return "", fmt.Errorf(getterErrorMsg, "Android manifest path")
}
func GetResolvedAndroidManifestPath(project Project, projectDir string) (string, error) {
	relativePth, err := GetAndroidManifestPath(project)
	if err != nil {
		return "", err
	}
	relativePth = utility.FixWindowsPath(relativePth)
	return filepath.Join(projectDir, relativePth), nil
}
func GetIsAndroidApplication(project Project) (bool, error) {
	for _, propertyGroup := range project.PropertyGroups {
		length := len(propertyGroup.AndroidApplication)
		if length > 0 {
			return boolParse(propertyGroup.AndroidApplication[length-1]), nil
		}
	}
	return false, fmt.Errorf(getterErrorMsg, "Android application")
}
func GetConfiguration(propertyGroup PropertyGroup) (string, error) {
	for _, configuration := range propertyGroup.Configuration {
		if configuration.Text != "" {
			return configuration.Text, nil
		}
	}
	return "", fmt.Errorf(getterErrorMsg, "configuration")
}
func GetPropertyGroupCondition(propertyGroup PropertyGroup) (string, error) {
	if propertyGroup.Condition == "" {
		return "", fmt.Errorf(getterErrorMsg, "condition")
	}
	return propertyGroup.Condition, nil
}
func GetResolvedConfiguration(propertyGroup PropertyGroup) (string, error) {
	conditionText, err := GetPropertyGroupCondition(propertyGroup)
	if err != nil {
		return "", err
	}
	if matches := regexp.MustCompile(`'\$\(Configuration\)\|\$\(Platform\)'\s*==\s*'(?P<config>.*)\|(?P<platform>.*)'`).FindStringSubmatch(conditionText); len(matches) == 3 {
		return matches[1], nil
	}
	if matches := regexp.MustCompile(`'\$\(Configuration\)'\s*==\s*'(?P<config>.*)'`).FindStringSubmatch(conditionText); len(matches) == 2 {
		return matches[1], nil
	}
	return conditionText, nil
}
func GetResolvedPlatform(propertyGroup PropertyGroup) (string, error) {
	conditionText, err := GetPropertyGroupCondition(propertyGroup)
	if err != nil {
		return "", err
	}
	if matches := regexp.MustCompile(`'\$\(Configuration\)\|\$\(Platform\)'\s*==\s*'(?P<config>.*)\|(?P<platform>.*)'`).FindStringSubmatch(conditionText); len(matches) == 3 {
		return matches[2], nil
	}
	if matches := regexp.MustCompile(`'\$\(Platform\)'\s*==\s*'(?P<platform>.*)'`).FindStringSubmatch(conditionText); len(matches) == 2 {
		return matches[1], nil
	}
	return conditionText, nil
}
func GetPlatform(propertyGroup PropertyGroup) (string, error) {
	for _, platform := range propertyGroup.Platform {
		if platform.Text != "" {
			return platform.Text, nil
		}
	}
	return "", fmt.Errorf(getterErrorMsg, "platform")
}
func GetOutputPath(propertyGroup PropertyGroup) (string, error) {
	length := len(propertyGroup.OutputPath)
	if length > 0 {
		return propertyGroup.OutputPath[length-1], nil
	}
	return "", fmt.Errorf(getterErrorMsg, "output path")
}
func GetOutputDir(propertyGroup PropertyGroup, projectDir, configuration, platform string) (string, error) {
	relativePth, err := GetOutputPath(propertyGroup)
	if err != nil {
		return "", err
	}
	relativePth = utility.FixWindowsPath(relativePth)
	relativePth = strings.Replace(relativePth, "$(Configuration)", configuration, -1)
	relativePth = strings.Replace(relativePth, "$(Platform)", platform, -1)
	return filepath.Join(projectDir, relativePth), nil
}