How is signing supposed to work?

We would like to use Gradle to launch apps on local devices and create ipa’s for delivery.

For signing purposes, we have to configure the provisioningProfile and signingIdentity in the gradle build file, as described here:

Our signing block looks like this:

signing {
    developmentTeam 'number'
    provisioningProfile project.file('profiles/someProvisioningFile.mobileprovision').absolutePath
    signingIdentity 'iPhone Distribution: Company name (number)'

when running ./gradelw moeLaunch the following error occurs:


Build settings from command line:
    CODE_SIGN_IDENTITY = iPhone Distribution: Company name (number)
    CONFIGURATION_BUILD_DIR = /Users/username/path/client/ios-moe/build/moe/xcodebuild/Release-iphoneos
    DSTROOT = /Users/username/path/client/ios-moe/build/moe/xcodebuild/dst
    OBJROOT = /Users/username/path/client/ios-moe/build/moe/xcodebuild/obj
    PROVISIONING_PROFILE = a136c960-f8de-4566-beb2-6873b0fde1b6
    SDKROOT = iphoneos10.1
    SHARED_PRECOMPS_DIR = /Users/username/path/client/ios-moe/build/moe/xcodebuild/shared_precomps
    SYMROOT = /Users/username/path/client/ios-moe/build/moe/xcodebuild/sym

=== BUILD TARGET Projectname OF PROJECT Projectname WITH CONFIGURATION Release ===

Check dependencies
Projectname has conflicting provisioning settings. Projectname is automatically signed, but provisioning profile com.projectname.customer dist has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor, or switch to manual signing in the project editor.
Code signing is required for product type 'Application' in SDK 'iOS 10.1'
Code signing is required for product type 'Application' in SDK 'iOS 10.1'


The following build commands failed:
        Check dependencies
(1 failure)
:client:ios-moe:moeMainReleaseIphoneosXcodeBuild FAILED

FAILURE: Build failed with an exception.

If we leave the provisioningProfile and signingIdentity out ./gradlew moeIpaBuild creates an ipa file with the development profile.

We already have managed to create a deployment application archive via XCode, but we would like to configure everything via Gradle to have continuous delivery.

Any suggestions how we should configure it?

Thanks in advance

Right now probably the best method is the following:

  1. keep the Xcode project and Gradle on automatic signing by default (so it works for your developers out of the box. (If it does not work then you can try to set it to manual with an AdHoc signing configuration)
  2. On your CI server (e.g. Jenkins), use the following method to build:
./gradlew moeIpaBuild  # will create a developer signed build

export MOE_GRADLE_EXTERNAL_BUILD=true # Do not call Gradle from Xcode
cd ios
xcodebuild archive -project xcode/ios-moe.xcodeproj \
                                   -scheme ios-moe \
                                   -configuration Release \
                                   -archivePath ./build/project.xcarchive \
                                   DEVELOPMENT_TEAM=TEAMNAMEHERE \
                                   "CODE_SIGN_IDENTITY=iPhone Distribution: YOURKEYNAME" \

xcodebuild -exportArchive \
                   -archivePath ./build/project.xcarchive \
                   -exportOptionsPlist ./exportOptions.plist \
                   -exportPath ./build

By design you should not even have to call ./gradlew, but there is a known bug that prevents xcodebuild archive from working if Gradle is called as part of its build process. This is why the MOE_GRADLE_EXTERNAL_BUILD variable is needed.

Thanks for your answer!

We will use this workaround for the time being.

Dear keesvandieren!

Gradle ‘moeIpaBuild’ task, settings the Scheme in xcode, Developer Team, Provisioning Profile name in the code signing options is required!
Just fixed the plugin documentation to reflect this requirement.

1 Like

Thanks! Currently our work for the customer-project on which we are using MOE is finished. On future changes in the app, we will try again to create IPA’s using Gradle.