How to increment build number for xcode project with Azure DevOps - ios

I have an iOS project, for CI/CD was selected Azure DevOps, I created pipeline and configured it according to documentation. It creates builds and upload to Apple Center, the only one thing I cant find out how to manage is how to increment build number, now I am doing it manually in xcode before generating a build.
Before we used fastlane, and it has such a possibility. So the question is how to increment build number with Azure pipeline, or at least force it to run fastlane file, to do it before the build is created?
Thanks in advance for any advice.
Update:
Its after creation of test project and installing extension Mobile App Tasks for iOS and Android, I cant add it to the list of tasks in the pipeline:
How to include it?
Update:
In case someone struggling as me:
After I wrote into support, so the issue was quit simple:
"And these task points these new available Android tasks and iOS tasks, we can view them from the Utility tasks when selecting tasks in pipelines, as below."

You can install the Mobile App Tasks for iOS and Android extension that gives you the ability to "bump version":
Change app's version name and code at build time.
Inputs:
sourcePath: Path to info.plist
versionCode: code number that must be an integer
versionCodeOffset: a specific number to increment the version code
versionName: user visible name (short code)
printFile: output the file before and after changing variables

Related

Continuous Integration with Automated Functional Testing for iPhone Application

What I need Actually?
We create the iPhone application for Mobile & iPad and the code is always checked in to the repository.
1) When ever the code is checked in to the code repository, that has to under go the automation testing and confirm the build does not failed or the app itself will works as per teh functional test scripts.
2) If there is any Build failure, mail has to be triggered to the developers.
3) The build is sucess and automation scripts are executed and that is also passed, next step is to deploy to the apple store and submit for review, necessary information for apple store is made available in configuration files.
Existing reference in stack overflow:
Continuous Integration for Xcode projects?
**Reference**: http://stackoverflow.com/questions/212999/continuous-integration-for-xcode-projects/17097018#17097018
Continuous integration for iphone xcode
**Reference**: http://stackoverflow.com/questions/1544119/continous-integration-for-iphone-xcode
Some of other references also was checked, which just give me the idea of how to execute functional script during code checkin, which is actual works like any CI tools likes Jenkins etc.
Above said reference are also discussed during 2009/2013, which are evry old.
What is available when researched?
I came to know about using using Hudson on the mac, which is very old version and not much supportive and also found Xcode OS X Server which is a product of apple itself where the reviews are not good and implementation is not feasible for my requirement.
Please share me the the approach of how to achieve this, also is that is possible to do CI process a one touch go for IOS, I found something similar to android with few confirmation from user.
At-least execution of Tests and creating an .ipa file in ios will be great.

Can you ask for user input for TFS 2015 CI build?

This seems simple enough, but I can't find a solution for this online.
I am integrating SonarQube into our build definitions that get triggered on check in. I want the version SonarQube uses to be tied back to the project number defined by the business side of things.
Ideally, I would like to be able to prompt the user for input. When you go to check in and it kicks off the build, it would ask you for the project number to be used as the version for SonarQube. Is this something TFS 2015 supports?
User input for build definitions
As far as I know, build definitions that are not manually triggered do not prompt for user input. A prompt allowing users to set build variables is shown for manually triggered builds from the VSTS web page.
SonarQube project version
I would recommend against you using the build or assembly version in your build tasks. This is because the SonarQube concept of version is quite different from the build concept. SonarQube uses versions as a baselining mechanism / to determine the leak period. If you up the version number often, the leak period is going to be too short to be actionable.
I'd recommend keeping the SonarQube project version in sync with your release schedule instead.
The short answer to this question is no, there is no way to prompt for input on a non-manually triggered CI build.
Here's what we did to work around this:
I wrote a Powershell script to read a config file and set the values to environment variables exposed to later build steps. Those variables are then what are specified in the Sonar Begin Analysis build task. I packaged that script up as a custom build task that will read a "sonar.config" file. This means all we have to do is add a "sonar.config" file to each solution we want to run Sonar analysis for, defining the key, name and version for the project, and then this build task will populate all necessary environment variables as the first step in the build.
So not a perfect solution, but it gets the job done without us having to add a lot of extra code to our solutions.

Versioning of Xamarin iOS apps

I wanted to know how you deal with the versioning of your iOS apps. CFBundleShortVersionString should match with the version submitted to iTunes Connect and CFBundleVersion is your unofficial build number.
For CFBundleShortVersionString often the format {MajorVersion}.{MinorVersion}.{Revision} is used. One could use the {Build} number for the CFBundleVersion. Another possibility would be to use some sort of revision number from the VCS or in my case the SHA1 hash of the commit of GIT.
If you submit an app to the app store the CFBundleVersion is used to determine if your app is an update. It is only allowed to use digits and the dot separator here and it should be higher than the older version. So using a hash doesn't work here and there is no revision number in GIT. Once the app is ready for release the app can use the same value for CFBundleShortVersionString and CFBundleVersion if you have some different naming for the build number which is not compatible with the app store.
Currently the only thing which comes to my mind is to manually enter the version number if the app is ready for release. So you start counting if you have v. 1.0.0 and increases the number if you provide a new release. If you have a new beta version (e.g. you are planning a new release 2.0.0), what do you use for CFBundleVersion? Or what if you use continous integration and a new build is generated each day at midnight?
Also is there an automated process which connects Xamarin Studio, Info.plist and GIT so that for example the build number is increased on each commit? And how does such a process look like?
Bonus question: What information do you show the user in the about dialog of the app?
This is not full answer on how to handle inserting version into Info.plist and iOS versioning but instead how MonoDevelop/XamarinStudio creates version number from GIT commits. Which you can probably use to hack some way to update your Info.plist.
https://github.com/mono/monodevelop/tree/master/scripts
This folder has 3 files .sh and .bat are just to compile third file(.cs) and execute it.
So if you look into this .cs file you will see:
How to get "git.exe"
How to run blame on version.config(this is file where you manually insert versions like(5.5, 5.7, 5.8...)
How to run "rev-list --count " + hash + "..HEAD" which means count all commits between last change to version.config file and current commit. So if version.config was changed 143 commits ago, version will be 5.5.0.143, you can of course still use 3rd place for service packs.
And also some output of this informations like for example buildinfo which can then be used by other parts of build process to insert into Info.plist.
I hope this helps you to solve your problem.

Using Xcode bots for continuous integration: shared schemes vs. build configurations

I am currently in the process of setting up an iOS application with Xcode bots for continuous integration on a Mac OSX Server instance. The source code is hosted on a remote git repository, so it will not be hosted on the Mac OSX Server. The application is available in several countries. In order to solve this efficiently we chose to have different build configurations depending on:
Which server environment it's going towards:
Development environment
Stage environment
Production environment
Which country is being built
I have watched the Continuous Integration with Xcode 5 & Testing in Xcode 5 WWDC 2013 videos but there are still a few things unclear.
When adding a shared scheme Xcode creates a new ApplicationName.xcscheme file.
Looking in this XML file there is a section near the end of the file:
<ArchiveAction
buildConfiguration = "Gondor Production Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
The create a new bot dialouge doesn't seem to have an option specifing which build configuration you wish to build the application with.
Now in order to mimize git conflicts of hell what is the best approach here?
To have multiple shared schemes for each build configuration or to simply change one scheme in your feature/release branch when you are creating new bots?
The different release builds have different Bundle Identifiers, different code signing identities and different development teams.
When switching development team the project.pbxproj file removes these "CODE_SIGN_IDENTITY" strings. Is the best approach here to have a shell script checking that:
The appropriate "CODE_SIGN_IDENTITY" string exists and matches the appropriate values
The "DevelopmentTeam" string exists and matches the appropriate values
Or can I accomplish this through adding a user defined setting?
You can specify the build configuration in the build scheme under the "Archive" section. What you are wanting todo would require different schemes that you would then create a bot from.

iOS App Store Releases in Continuous Integration Environment

I am currently using Jenkins on an independent server for iOS continuous integration. Jenkins builds, tests, and creates HTML links so the app can be downloaded from ad-hoc devices (Continuous Delivery).
Whenever I make an App Store release I get the code of the build I want and I make a build out of it. This presents a problem, since the although the code is the same, the binary is not guaranteed to be the same since two different machines are involved.
You usually read that in continuous integration releases should be a non-event. This works for me for the everyday builds but, what is the best approach to make App Store releases in a continuous integration environment?
I ended up adding a new job in Jenkins which only builds an .xcodearchive. That job belongs to a pipeline and is the last task to be executed. The command used to build the archive is:
xcodebuild -scheme ${JK_SCHEMA_NAME} -archivePath ${JK_OUTPUT_DIR}/${JK_ARCHIVE_NAME} clean archive "CODE_SIGN_IDENTITY=${JK_CODE_SIGN_IDENTITY}" "GCC_PREPROCESSOR_DEFINITIONS=${GCC_PREPROCESSOR_DEFINITIONS} ${JK_GCC_PREPROCESSOR_DEFINITIONS}" "PROVISIONING_PROFILE=${JK_PROVISIONING_PROFILE_UDID}"
This way I can make sure the flow to deliver an app from commit to final binary for the store is completely automated (or at least doesn't need human interaction). The version numbers are correctly set, and that there are no changes in source code or compiling options that can alter the final archive uploaded to the store.

Resources