Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the IPA output location of a Xamarin.iOS project?

If I were to want to use some sort of continuous integration or command line build, and have the IPA output to a custom location, how would I go about doing this in Xamarin.iOS?

Thanks!

like image 474
cobey Avatar asked Jun 16 '16 22:06

cobey


2 Answers

In Xamarin release Cycle 7 the output location of the IPA file changed. You have two options, the first is to edit your .csproj file and the seond is to edit Xamarin.iOS.Common.Targets.

1. Project edit

The following will move your .IPA file back to where it used to go. Alternatively you can enter your own path in DestinationFolder

<PropertyGroup>
    <CreateIpaDependsOn>
        $(CreateIpaDependsOn);
        CopyIpa
    </CreateIpaDependsOn>
</PropertyGroup>
<Target Name="CopyIpa" Condition="'$(OutputType)' == 'Exe' And '$(ComputedPlatform)' == 'iPhone' And '$(BuildIpa)' == 'true'">
    <Copy SourceFiles="$(IpaPackagePath)" DestinationFolder="$(OutputPath)" />
</Target>

2. Targets file

Perhaps more useful if you have a lot of iOS projects. Keep in mind that if you update Xamarin you will need to back up this file first.

On your Mac, open /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/2.1/Xamarin.iOS.Common.targets and change the following lines

<PropertyGroup>
    <_IpaOutputPath>$(DeviceSpecificOutputPath)$(_AppBundleName) $([System.DateTime]::Now.ToString('yyyy-MM-dd HH-mm-ss'))</_IpaOutputPath>
    <_IpaOutputDir>$(_IpaOutputPath)\</_IpaOutputDir>
    <IpaPackageName Condition="'$(IpaPackageName)' != '' And !$(IpaPackageName.EndsWith ('.ipa', StringComparison.OrdinalIgnoreCase))">$(IpaPackageName).ipa</IpaPackageName>
    <IpaPackageName Condition="'$(IpaPackageName)' == ''">$(_AppBundleName).ipa</IpaPackageName>
    <IpaPackagePath>$(_IpaOutputDir)$(IpaPackageName)</IpaPackagePath>
</PropertyGroup>

to

<PropertyGroup>
    <_IpaOutputPath>$(OutputPath)</_IpaOutputPath>
    <_IpaOutputDir>$(_IpaOutputPath)\</_IpaOutputDir>
    <IpaPackageName Condition="'$(IpaPackageName)' != '' And !$(IpaPackageName.EndsWith ('.ipa', StringComparison.OrdinalIgnoreCase))">$(IpaPackageName).ipa</IpaPackageName>
    <IpaPackageName Condition="'$(IpaPackageName)' == ''">$(_AppBundleName).ipa</IpaPackageName>

    <IpaPackagePath>$(_IpaOutputDir)$(IpaPackageName)</IpaPackagePath>
</PropertyGroup>

Source

like image 178
AllDayer Avatar answered Nov 15 '22 09:11

AllDayer


The best way to alter the IPA output location is actually to use an MSBuild target to copy the file to a desired location, after the build is complete. Doing so is a safe approach, as it allows for a customer locations to be set, without modifying Xamarin system files, which could be altered during an update.

Before doing any of the steps below, you will want to back up your project folder, in case something is edited incorrectly in the csproj file.

To accomplish this, you will want to place the following MSBuild target at the end of your project file, right before the closing tag:

<Target Name="CopyIpa" Condition="'$(OutputType)' == 'Exe' And '$(ComputedPlatform)' == 'iPhone' And '$(BuildIpa)' == 'true'">
    <Copy   SourceFiles="$(IpaPackagePath)" DestinationFolder=“[PathToOutput]”/>
</Target>

This will copy the IPA from the variable $(IpaPackagePath) to whichever path you set as the DestinationFolder.

like image 22
cobey Avatar answered Nov 15 '22 09:11

cobey