muvixalex
(Alex Itelman - Muvix)
December 4, 2016, 4:21pm
1
Hello,
We are updating our Xcode App Bundle version from our Gradle script using:
defaults write com.apple.dt.Xcode IDEApplicationwideBuildSettings -dict-add MOE_BUNDLE_VERSION $project.ext.versionWithBuildNumberWithoutSnapshotSuffix".execute().waitFor()
And then setting the Bundle Version in Xcode to ${MOE_BUNDLE_VERSION}
This seems to work well when we’re building our ipa on our build machine, but when simply running from Xcode for debugging, when updating our global version in our main gradle script, the xcode project doesn’t recognise the change, and the app still has the previous version.
This is very inconvenient.
How can we make it work?
kisg
(Gergely Kis - Migeran)
December 6, 2016, 5:05pm
2
Hi,
we are using this tool from Apple in our Jenkins build pipeline script to update the version with the build number prior to running the Gradle build:
sh 'agvtool new-version -all ' + BUILD_NUMBER
It should be possible for you to add it to your build.gradle as well, so it runs before the actual build starts.
Would this be a solution for you?
Best Regards,
Gergely
muvixalex
(Alex Itelman - Muvix)
December 7, 2016, 1:03pm
3
If it works, why not?
Does this also set the bundle short version?
How to I put it in the gradle script?
Where do I get this tool from?
muvixalex
(Alex Itelman - Muvix)
December 7, 2016, 1:25pm
4
And what do I need to set in the info.plist in the bundle version and bundle short version?
muvixalex
(Alex Itelman - Muvix)
December 7, 2016, 2:32pm
5
I tried this method, it seems to set the version in the info.plist (I used new-marketing-version for the bundle short version), but the build fails on:
User supplied UIDeviceFamily key in the Info.plist will be overwritten. Please use the build setting TARGETED_DEVICE_FAMILY and remove UIDeviceFamily from your Info.plist.
I don’t know what’s the relation… But when I remove the call to agvtool this doesn’t happen.
muvixalex
(Alex Itelman - Muvix)
December 7, 2016, 2:49pm
6
Even when I actually remove the “UIDeviceFamily” from the plist like it suggests, it still doesn’t start the app from xcode, it just says “Build stopped” in the end…
muvixalex
(Alex Itelman - Muvix)
December 22, 2016, 1:21pm
7
Any other ideas for this?
muvixalex
(Alex Itelman - Muvix)
December 25, 2016, 3:25pm
8
I think Xcode doesn’t “like” the fact that the info.plist is changed during the build… So it just stops the build.
Any other idea?
muvixalex
(Alex Itelman - Muvix)
January 4, 2017, 12:50pm
9
Any help would be appreciated please
muvixalex
(Alex Itelman - Muvix)
March 2, 2017, 12:08pm
10
For anyone who might have the same problem:
I ended up using a pre-action in xcode similar to what is described here: (info.plist preprocessing header file)
README.md
## Automatic build versions from git in Xcode (and other goodies)
Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data.
### 1. Xcode Scheme pre-action
Edit Xcode Scheme and add a pre-action script.
Copy the contents of `preaction.sh` into the pre-action script box.
![](https://gist.githubusercontent.com/acrookston/55d69a16cd5363426dbf7a3d6a9ee6ce/raw/4cae5919e4227b48c264cc2bcb6d0419cecf4341/xcode-manage-preaction.png)
This file has been truncated. show original
build_environment.sh
#!/bin/sh
# build_environment.sh
#
# Created by Andrew C on 7/27/15.
# Released under MIT LICENSE
# Copyright (c) 2015 Andrew Crookston.
cd "${PROJECT_DIR}"
This file has been truncated. show original
development.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>README</key>
<string>Copy this file to config/environments/development.plist. DO NOT add it to the targets! It gets copied to environment.plist during build. See build_environment script for more.</string>
<key>AppGroup</key>
<string>your.app.group</string>
<key>HostName</key>
<string>localhost</string>
This file has been truncated. show original
There are more than three files. show original
And I also called this script from the gradle build script, so it works both with a gradle command line build and when building in xcode.