Marcos Cobeña Morián: Me gusta, no me gusta, me gusta.

After great success last year, we’re bringing Xamarin Dev Days back in 2016 and are working with our partners and community members to bring full day mobile development events to a town or city in your area! What are Dev Days? Xamarin Dev Days are an intense, hands-on learning experience. More than just your average […]
The post Xamarin Dev Days is Back and Coming to a Town Near You appeared first on Xamarin Blog.
This week on the Xamarin Podcast, Pierce and I share our experiences in building connected apps with Azure Mobile Apps. We’ll walk you through the different options you have for mobile backends in Azure and take a look at other technologies, such as Microsoft Cognitive Services, Azure Functions, and Azure Search, that you can add […]
The post Podcast: Building Connected Apps with Azure Mobile Apps appeared first on Xamarin Blog.
ICYSTT: In Case You See This Too
Humor me. I’m trying this acronym as a way of signaling the content of posts where I struggle through a problem and come out the other side with some findings.
Thanks to my teammate Ryan O. for piling onto this problem to help.
Recently, some of the command-line build scripts for an iOS project starting failing. Specifically, the build steps around archiving the project. Of course, the problem only showed up after updating some of the tools on the machine.
In this particular build pipeline, FAKE is the build system of choice. The bundled XamarinHelper
adds an easy iOSArchive
task that generates a command something like this:
mdtool -v archive "-c:Release|iPhone" -p:YourApp.iOS your_solution.sln
Ordinarily, this command builds the project, then generates an .xcarchive
.
mdtool archive
doesn’t work
Oh no! Is mdtool
deprecated?
Well, not really as Xamarin’s Mikayla points out. However, more and more we’re being pointed toward xbuild
or msbuild
since mdtool
is just an interface into those other systems.
So, while mdtool
may not be officially deprecated, the archive
command broke as of Xamarin Studio 6 as commented on here and hinted at over here. Previously, the archive command would first build the iOS project, then archive. No longer the case as of this write-up. Maybe Xamarin will patch things up in a future release?
Before I get to the fix, I want to warn you about a squirrel we chased. Once realizing that the mdtool archive
command had changed — and therefore the FAKE
iOSArchive
task — we tried running the FAKE
iOSBuild
task immediately before the iOSArchive
task to make sure a build happens.
The build happened and an archive was created, but the build still failed. There are additional steps in my build pipeline that export the archive as an .ipa. This one-two punch of iOSBuild
and iOSArchive
ultimately generated a bad archive. Turns out, if your achive is bad, you won’t be able to export and may see errors such as:
xcodebuild: WARNING: -exportArchive without -exportOptionsPlist is deprecated
...
** EXPORT FAILED **
We chased that squirrel before realizing that the generated archive was simply bad. Although, duly noted, the export step needs to change.
You can anecdotally recognize a bad archive by viewing the Xcode Archive Organizer, selecting an archive from the list, and verifying that the Export, Validate, and Submit buttons are grayed out.
This post was the most helpful.
Down the page a bit, a Xamarin employee suggests using an xbuild
command explicitly:
xbuild /p:Configuration=Release /p:Platform=iPhone /p:ArchiveOnBuild=true /t:"Build" MyProject.csproj
He goes on to explain how the ArchiveOnBuild
property works. Not entirely familiar with xbuild
, I whittled the suggestion down to a simpler:
xbuild /p:Configuration=Release /p:ArchiveOnBuild=true /t:"Build" MyProject.csproj
The Platform
property wasn’t described, so because I didn’t want to include something I wasn’t sure of, I removed that bit.
The project builds, but no archive is generated
Well, running that command certainly built the app, but no .xcarchive
was generated, and my app didn’t show up in the Xcode Archive Organizer.
You guessed it — Platform
was necessary. Putting that property back fixed the script:
xbuild /p:Configuration=Release /p:Platform=iPhone /p:ArchiveOnBuild=true /t:"Build" MyProject.csproj
The
Platform
property is the platform target (e.g.- iPhone, iPhoneSimulator, x86, etc.)
Executing this command built the project, and generated an archive, but the archive wasn’t listed under my iOS Apps in Xcode Archive Organizer.
Archive shows up in Xcode Archive Organizer under Other Items instead of under iOS Apps.
If you read the entire post from the problem #1 fix, you already know what’s going on. If you jump down to this comment you’ll see that the CFBundleVersion
must be present and populated in the archive’s Info.plist
.
This isn’t necessarily a big problem if your application’s Info.plist
is correct. Your app will still export correctly and be able to be submitted to the App Store. However, this comment provides a suggestion that works perfectly.
/usr/libexec/PlistBuddy -c "Add :ApplicationProperties:CFBundleVersion string "your build number here"" path/to/archive.xcarchive/Info.plist
Adding that command to your build pipeline will ensure that the archive files correctly under the iOS Apps section of the Xcode Archive Organizer.
That’s it! Build scripts work again. The community did a great job helping with the various fixes, but I wanted to compile everything into a single how-to. Maybe it will save someone else some time.
I’d love your feedback. Let me know if this helped you or if you ran into different kinds of problems.
The rise of smartphones and changing user behavior over the past seven years have forced organizations to start delivering more and more mobile solutions, with apps a big part of this. There are unique challenges when it comes to enterprise mobile app delivery, however. The ecosystem is fragmented, yet users continue to have high expectations. […]
The post How to be Successful with Mobile DevOps appeared first on Xamarin Blog.