iOS Tutorial Managing multiple certificates / provision files

Discussion in 'iOS Tutorials' started by Erel, Dec 23, 2014.

  1. Erel

    Erel Administrator Staff Member Licensed User

    This tutorial is only relevant after you were able to build and install B4i-Bridge.
    If you haven't yet started with B4i then please go over these two tutorials instead:
    Creating a certificate and provisioning profile
    Installing B4i-Bridge and debugging first app


    5 different files are required in order to compile and sign an app:
    - B4i.keystore
    - B4i.p12
    - certSigningRequest.csr
    - Certificate file (ios_*.cer)
    - Provision file (.mobileprovision)

    The first three files are created by the IDE when you select Tools - Private sign key - Create new key.
    The certificate file is downloaded from Apple developer console based on the certSigningRequest.csr file.
    The provision file is also downloaded from Apple developer console and it internally references the certificate file.
    The provision file also references an App Id. Usually it will be a wildcard id (this means that it can be used with multiple package names).
    It is important to understand that you can create multiple certificates based on the same certSigningRequest.csr file.

    Sooner or later you will need to create more certificate files and / or provision files. For example you need to use a different pair of files when you are ready to upload your app to the store.

    Push notifications requires a non-wildcard provision profile. This means that this file can only be used with one specific app (based on the package name).

    B4i v1.5 adds two attributes which you can use to explicitly set the certificate file and the provision file:
    Code:
    #CertificateFile: ios_development.cer
    #ProvisionFile: Push.mobileprovision
    The files must be located in the keys folder and they must be derived from the same certSigningRequest.csr file.
    You can use these attributes together with the conditional compilation feature to select different files based on the compilation type.

    Note that if there are multiple certificate files (or provision files) and you don't explicitly set the file then the compiler will raise an error. That is unless there is a file named default.cer or default.mobileprovision. There is a bug in B4i v1.50 which makes it impossible to use a file named default.cer. It will be fixed in the next update.
     
    Last edited: Dec 24, 2014
    luke2012 likes this.
  2. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Hi.
    I add my friend's device and register App ID for each friend.
    Now when i want to create certificate for each my friend,it's disable.
    You said no need to create certificate but i cannot use provision in other device
    Please guide me
    [​IMG]
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    You should use the same certificate for all the devices. Make sure to download the new provision file after you added the new device.
     
    luke2012 likes this.
  4. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Thank you so much Erel
    You are very busy.
    I do use same crtificate for my friend device but when i send provision file to my friend and use
    in b4i not work and get error profision file
    Do i send my certificate to my friend(of course i send but again get error)
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    You need to send all the files from the key folder to your friend. He then need to open Tool - Private Sign Key, enter the password and select Set Password.
     
  6. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Ok I test it future.
    Thanks very much
     
  7. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Thank you It's ok Erel
     
  8. Ramezanpour

    Ramezanpour Active Member Licensed User

    Hi there
    I can create a profile and then the files I download it
    Then I delete profiles created? (Udid not remove)
    Can be used from this profile?
    Does it work?
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Not sure that I understand the question. Sorry.
     
    Ramezanpour likes this.
  10. Ramezanpour

    Ramezanpour Active Member Licensed User

    Is it possible to use deleted profiles ?
    (after making, download and delete) is
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    No. It will not work.
     
    Ramezanpour likes this.
  12. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Hi again.
    I have problem in create provision file again
    I create a certificate file and then register udid and create app id and finally create provision file but when i use in b4i return below error
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this issue.
     
  14. Arf

    Arf Active Member Licensed User

    Do I need to create a new Private Sign Key for the store version of my app, or just use the same one I've been using for development and create the release certificate etc from that?

    And do I need to fill out names and all the info in the signing certificate? My development one is all 'Unkown' fields aside from the password.
     
    Last edited: Dec 3, 2015
  15. Erel

    Erel Administrator Staff Member Licensed User

  16. kc1

    kc1 Member Licensed User

    Erel,

    My Local Mac successfully compiled, installed, and ran my B4i generated app on an iPhone. Meaning, my certificate and provisioning were done correctly.

    Then I tried to use Xcode by itself and wrote a simple "Hello World" program for testing. The app compiled and ran fine on the simulator. However, when I tried to run the app on a physical iPhone, it asked me for my B4i keychain password during the Build phase as follows:

    Keychain.png

    I tried different passwords and none of them work.

    I don't know enough about certificates and provisioning to resolve this issue.

    Perhaps the solution is to use the Hosted Mac Builder Service for my B4i and use Xcode to learn Swift programming, that way I will maintain two different development and deployment certificates?

    If I can use two different certs, how do I go about resolving the Xcode codesign issue? How do I tell it not to use the B4i Local Mac provision?

    What is your suggestion? What is the best solution and how do I go about achieving my goal?

    Thank you,

    KC
     
    Last edited: Jul 25, 2016
  17. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
  18. luke2012

    luke2012 Well-Known Member Licensed User

    Hi Erel,
    please can you give me an example that show how to set the conditional compilation (I'm not familiar with it) within B4i in order to manage Dev and Production profiles within the apps ?
    So suppose that I have a "iOS App Development" cert and a "App Store and Ad Hoc" cert (and the related prov. files) and I wish to handle this profiles based in the compile mode (debug / release) that I select from the IDE.

    Considering this two attributes how I can set the conditional compilation ?

    Code:
    #CertificateFile: ios_development.cer
    #ProvisionFile: Push.mobileprovision
    Thanks in advance for your help.
     
  19. Erel

    Erel Administrator Staff Member Licensed User

    You don't need an "iOS App Development" certificate at all. Use only the App Store and Ad Hoc certificate.

    It is important to test your app in release mode and you cannot do it with a store provision profile.
    With that said you can write something like:
    Code:
    #If RELEASE
       #ProvisionFile: MYAppStore.mobileprovision   
    #Else
      #ProvisionFile: MyApp.mobileprovision
    #END IF
     
Loading...