Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codesign with Enterprise profile does not work #163

Closed
AkhileshwarBV opened this issue Mar 26, 2015 · 26 comments
Closed

Codesign with Enterprise profile does not work #163

AkhileshwarBV opened this issue Mar 26, 2015 · 26 comments

Comments

@AkhileshwarBV
Copy link

Hi Team,

I can able to make a build with adhoch and development provisions profile with Gradle but am facing issue while making build with Enterprise provisioning profile

Does gradle support making build with In-house Provision profile?

@AkhileshwarBV AkhileshwarBV changed the title Gradle Enterprise certificate build issue Gradle In-house Provisioning _IPA certificate build issue Mar 26, 2015
@savage7
Copy link

savage7 commented Mar 26, 2015

This is perfectly supported. Just use your enterprise public key and provisioning profile as you would with all other profiles.

@renep
Copy link
Contributor

renep commented Mar 26, 2015

I don't have a enterprise profile myself, therefor I'm not able to test this. Therefor I cannot confirm that it works.

Normally I would think that it should work, but I looks like it does not. I'll try to get access to an enterprise profile to test this out myself.

@renep renep changed the title Gradle In-house Provisioning _IPA certificate build issue Codesign with Enterprise profile does not work Mar 26, 2015
@renep renep added the bug label Mar 26, 2015
@renep
Copy link
Contributor

renep commented Mar 26, 2015

@savage7 thanks for the answer, therefor this is not a bug as it looks ;-)

@renep renep removed the bug label Mar 26, 2015
@renep
Copy link
Contributor

renep commented Mar 26, 2015

What if the certificate is correct, but the error is in the provisioning profile?

Open in Provisioning Profile in a text editor and you should find the id for the organizational unit inside.

You can also try the specify the SHA as Identifier. the SHA is found at the bottom of the identifier. And you must remove the spaces.

@renep
Copy link
Contributor

renep commented Mar 26, 2015

What about the bundle identifier in the app, is it: com.republicservices.contacts

@renep
Copy link
Contributor

renep commented Mar 26, 2015

I think the correct identity should be 'identity = 'iPhone Distribution: Republic Services Inc.' when using the enterprise profile

@renep
Copy link
Contributor

renep commented Mar 26, 2015

what is the value of you bundle identifier?

@AkhileshwarBV
Copy link
Author

String bundleIdentifier = 'com.republicservices.contacts'

@renep
Copy link
Contributor

renep commented Mar 26, 2015

Maybe the problem is the 'Set CFBundleVersion ' + BundleVersion
I alway use a : after the Set: 'Set: CFBundleVersion ' + BundleVersion

You can also have

infoplist {
   bundleIdentifier = bundleIdentifier,
   version = BundleVersion
}

See: https://github.com/openbakery/gradle-xcodePlugin/blob/master/Documentation/Parameters.md#info-plist-parameters

Have you checked i the plist was properly modified?

@AkhileshwarBV
Copy link
Author

I have gone through https://github.com/openbakery/gradle-xcodePlugin/blob/master/Documentation/Parameters.md#info-plist-parameters
and following all the parameters specified in that

but for debugging that document is not sufficient

sorry I know am giving trouble but I am keep trying all the possible ways but I don't get result with In_house certificate

With adhoc certificate everything working as expected

If I use
infoplist {
bundleIdentifier = bundleIdentifier,
version = BundleVersion
}
I am getting following error

  • What went wrong:
    Could not compile build file '/Users/deltatechnology/Desktop/EmployeeDirectoryiOS/build.gradle'.

    startup failed:
    build file '/Users/deltatechnology/Desktop/EmployeeDirectoryiOS/build.gradle': 30: expecting '}', found ',' @ line 30, column 36.
    bundleIdentifier = bundleIdentifier,
    ^

    1 error

If I use infoplist {
commands = [

'Set: CFBundleVersion ' + BundleVersion,
'Set: CFBundleIdentifier ' + bundleIdentifier
]
}

  • What went wrong:
    Execution failed for task ':infoplistModify'.

    Command failed to run (exit code 1): '/usr/libexec/PlistBuddy /Users/deltatechnology/Desktop/EmployeeDirectoryiOS/EmpDirDemo/Info.plist -c Set: CFBundleVersion 1'

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

@AkhileshwarBV
Copy link
Author

Don't know is jenkins causing the issue or gradle with In_house certificate

@renep
Copy link
Contributor

renep commented Mar 26, 2015

infoplist {
bundleIdentifier = bundleIdentifier,
version = BundleVersion
}

bundleIdentifier = bundleIdentifier cannot work, if you want to use a variable than rename it. e.g. I have in my build file:

project.ext.baseBundleIdentifier= 'com.example...'

infoplist {
  bundleIdentifier= project.ext.baseBundleIdentifier
}

also the , is not needed. (Sorry for the mistake=

Try the following in you build file:

project.ext.baseBundleIdentifier= 'com.republicservices.contacts'
project.ext.baseVersion= '1.0.0.0.0'


infoplist {
  bundleIdentifier= project.ext.baseBundleIdentifier
  version = project.ext.baseVersion
}

@AkhileshwarBV
Copy link
Author

I am getting following error with above syntax

  • What went wrong:
    Execution failed for task ':package'.

    No such property: BundleVersion for class: org.gradle.process.internal.DefaultJavaExecAction_Decorated

@renep
Copy link
Contributor

renep commented Mar 26, 2015

do you have a variable 'BundleVersion'? do you have it declared?

@AkhileshwarBV
Copy link
Author

No Renep, I dont have

@renep
Copy link
Contributor

renep commented Mar 26, 2015

There must be the BundleVersion somewere, otherwise you do not get this error.

@renep
Copy link
Contributor

renep commented Mar 26, 2015

What about?

String fileName = 'Employee Directory-'+BundleVersion+'-'+dateString+'-PROD.ipa'

@AkhileshwarBV
Copy link
Author

Sorry I changed the name of variable, I am trying it now

@AkhileshwarBV
Copy link
Author

With the suggested changes its working form my terminal but facing same problem with jenkins gradle

@renep
Copy link
Contributor

renep commented Mar 26, 2015

Have you checked if the Info.plist was properly modified and the bundle identifier is correct, and also the version was replaced?

@AkhileshwarBV
Copy link
Author

Yes renep there was change in plist

and now I removed plist from gralde and I set plist values from my app itself
still I have the same issue :(

I believe issue with bundle identifier , even I set bundle identifier statically issue is remain same

@renep
Copy link
Contributor

renep commented Mar 26, 2015

What you can try is to create a xcarchive first with 'gradle archive' and use the adhoc identifier and cert here.
The then create the ipa with 'gradle package' with the enterprise provisioning profile and cert. The 'package' task does not compile if an xcarchive exists. The ipa is signed during the package task.

the build.gradle should look like this:

buildscript {
    repositories {
        maven {
            url('http://openbakery.org/repository/')
        }
        mavenCentral()
    }
    dependencies {
        classpath group: 'org.openbakery', name: 'xcodePlugin', version: '0.10.+'
    }
}
apply plugin: 'xcode'

xcodebuild {
    configuration='Release'
    sdk = 'iphoneos'
    target = 'Contacts'

    signing {

        identity = 'iPhone Distribution: Republic Services Inc. (XXXXX)'
        certificateURI = 'file://localhost//Users/    YOUR-AD-HOC-KEY.p12'
        certificatePassword = 'pwd'
        mobileProvisionURI = 'file://localhost// YOUR-AD-HOC-PROV.mobileprovision'

            infoplist {
                bundleIdentifier= project.ext.baseBundleIdentifier
                version = project.ext.baseVersion
            }
    }   
}




gradle.taskGraph.whenReady { taskGraph ->

    if (taskGraph.hasTask(package)) {
        xcodebuild {
            signing {
                certificateURI = 'file://localhost//Users/deltatechnology/Desktop/Cer/In-House/contacts_inhouse_privateKey.p12'
                certificatePassword = 'pwd'
                mobileProvisionURI = 'file://localhost//Users/deltatechnology/Desktop/Cer/In-House/Employee_Directory_InHouse.mobileprovision'
        }
    }
}


package.doLast {
    String dateString
    task dateTask {
        Date date=new Date()
        println 'Date is '+date
        Date today = new Date();
        dateString = today.format("MM-dd-yyyy");
}
println 'new date is : '+dateString

@AkhileshwarBV
Copy link
Author

Here I am sending my output

pbnhhxe:EmployeeDirectoryiOS deltatechnology$ gradle archive
:cocoapods
Skipping installing pods, because the Pods directory already exists
:xcodebuildConfig
:infoplistModify
Updating /Users/deltatechnology/Desktop/EmployeeDirectoryiOS/EmpDirDemo/Info.plist
Set Info Plist Value: Set :CFBundleIdentifier com.republicservices.employeedirectory
Set Info Plist Value: Set :CFBundleVersion 1.0.0.0.0
:keychainClean
:keychainCreate
:provisioningClean
:provisioningInstall
:xcodebuild
OK - Compile: FindTableView.m

/Users/deltatechnology/Desktop/EmployeeDirectoryiOS/EmpDirDemo/Base.lproj/Main.storyboard:ejn-89-iYx: warning: Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
/Users/deltatechnology/Desktop/EmployeeDirectoryiOS/EmpDirDemo/Base.lproj/Main.storyboard:UMA-u9-bJt: warning: Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
/Users/deltatechnology/Desktop/EmployeeDirectoryiOS/EmpDirDemo/Base.lproj/Main.storyboard:Fz5-Az-v1O: warning: Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0

  OK - Compile: EmpDirDemo/FindCell.xib

:archive
convert plist to binary /Users/deltatechnology/Desktop/EmployeeDirectoryiOS/build/archive/Contacts.xcarchive/Products/Applications/Contacts.app/Base.lproj/Main.storyboardc/Info-8.0+.plist
convert plist to binary /Users/deltatechnology/Desktop/EmployeeDirectoryiOS/build/archive/Contacts.xcarchive/Products/Applications/Contacts.app/Base.lproj/Main.storyboardc/Info.plist
convert plist to binary /Users/deltatechnology/Desktop/EmployeeDirectoryiOS/build/archive/Contacts.xcarchive/Products/Applications/Contacts.app/EMP.momd/VersionInfo.plist
convert plist to binary /Users/deltatechnology/Desktop/EmployeeDirectoryiOS/build/archive/Contacts.xcarchive/Products/Applications/Contacts.app/Info.plist
convert plist to binary /Users/deltatechnology/Desktop/EmployeeDirectoryiOS/build/archive/Contacts.xcarchive/Products/Applications/Contacts.app/ResourceRules.plist

BUILD SUCCESSFUL

Total time: 28.154 secs
pbnhhxe:EmployeeDirectoryiOS deltatechnology$ gradle package
:cocoapods
Skipping installing pods, because the Pods directory already exists
:xcodebuildConfig
:infoplistModify
Updating /Users/deltatechnology/Desktop/EmployeeDirectoryiOS/EmpDirDemo/Info.plist
Set Info Plist Value: Set :CFBundleIdentifier com.republicservices.employeedirectory
Set Info Plist Value: Set :CFBundleVersion 1.0.0.0.0
:keychainClean
:keychainCreate
:provisioningClean
:provisioningInstall
:xcodebuild FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':xcodebuild'.

    Command failed to run (exit code 65): 'xcodebuild -configuration Release -sdk iphoneos -target Contacts CODE_SIGN_IDENTITY=iPhone Distribution: Republic Services Inc. CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist PROVISIONING_PROFILE=859a5506-85ef-4046-aeb1-94d479d31e25 DSTROOT=/Users/deltatechnology/Desktop/EmployeeDirectoryiOS/build/dst OBJROOT=/Users/deltatechnology/Desktop/EmployeeDirectoryiOS/build/obj SYMROOT=/Users/deltatechnology/Desktop/EmployeeDirectoryiOS/build/sym SHARED_PRECOMPS_DIR=/Users/deltatechnology/Desktop/EmployeeDirectoryiOS/build/shared OTHER_CODE_SIGN_FLAGS=--keychain=/Users/deltatechnology/Desktop/EmployeeDirectoryiOS/build/codesign/gradle-1427372986364.keychain'

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 4.139 secs
pbnhhxe:EmployeeDirectoryiOS deltatechnology$

@renep
Copy link
Contributor

renep commented Mar 26, 2015

Please read the post again:
#163 (comment)

@AkhileshwarBV
Copy link
Author

Hi Renep
I have added your build script in my project then

  1. first I executed the gradle archive
    then I executed gradle package command
    I have sent you the log out put

did I miss any thing if I missed anything please could you make me to understand

@renep
Copy link
Contributor

renep commented May 19, 2015

I know now for sure that the enterprise profile works.

To simplify things I have added in the latest version (0.11.2) that the signing.identity is optional to avoid errors.
I also fixed an error when frameworks are embedded into the framework

Maybe you give this version a try.

@renep renep closed this as completed May 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants