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!
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With