iOS Tutorial Managing multiple certificates / provision files

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:
B4X:
#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.
 
Last edited:

omidaghakhani1368

Well-Known Member
Licensed User
Longtime 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
Untitled.png
 

omidaghakhani1368

Well-Known Member
Licensed User
Longtime 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)
 

Ramezanpour

Active Member
Licensed User
Longtime 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?
 

omidaghakhani1368

Well-Known Member
Licensed User
Longtime 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
Check dependencies
Code Sign error: No codesigning identities found: No codesigning identities (i.e. certificate and private key pairs) that match the provisioning profile specified in your build settings (“dehghan”) were found.
CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 8.4'
warning: all apps should include an armv7 architecture (current ARCHS = "arm64").
 

Arf

Well-Known Member
Licensed User
Longtime 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:

kc1

Member
Licensed User
Longtime 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:

luke2012

Well-Known Member
Licensed User
Longtime 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 ?

B4X:
#CertificateFile: ios_development.cer
#ProvisionFile: Push.mobileprovision

Thanks in advance for your help.
 

Erel

B4X founder
Staff member
Licensed User
Longtime 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:
B4X:
#If RELEASE
   #ProvisionFile: MYAppStore.mobileprovision   
#Else
  #ProvisionFile: MyApp.mobileprovision
#END IF
 
Top