cordova-ios
cordova-ios copied to clipboard
(iOS) Support multiple provisioning profiles, Resolves #953
Platforms affected
ios
Motivation and Context
When using a plugin that creates a new target it is currently impossible to sign it using cordova command line. See issue #953
Description
Added the option to set multiple provisioning profiles only in the build.json file.
Testing
I've tested this code on the app I'm writing.
Checklist
- [x] I've run the tests to see all new and existing tests pass ~I added automated test coverage as appropriate for this change~ Couldn't understand how... :-(
- [x] Commit is prefixed with
(platform)
if this change only applies to one platform (e.g.(android)
) - [x] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords) ~I've updated the documentation if necessary~ not sure how to do it since this is only available when using a json file.
anyone?
Can you name the issues this PR would close? I see some references but not sure if any of those should be closed with this PR?
@timbru31 Updated the name, hope this is what you intended.
@timbru31 done! Thanks for the review. Let me know when a new version is available. :-)
@timbru31 anything else that I need to do? Can this be merged?
Any one? Can this be merged? I would really like to migrate of my fork and to this repo, hopefully using a npm version, but a git commit will also do as long as I'm not using my getting-out-dated-fork... :-)
Anything I can do in order to move this request forward?
I would recommend that you follow up with us on the mailing list or on Slack.
@brodybits I tried slack and didn't got any response to my post... I'm currently using this my fork in a production app which behaves as expected, so I'm guessing this is as good as it gets in terms of testing. And in general I don't think this change is a breaking change as I wrote it with backwards compatibility in mind... I really hoped it wouldn't take so much time to merge a pull request... :-(
I can confirm that @HarelM solution works, I would appreciate if the pull request it's merged.
Also the build.json
documentation should be updated: https://cordova.apache.org/docs/en/10.x/guide/platforms/ios/#using-buildjson
Current usage in build.json
(And it still works):
{
"ios": {
"release": {
"codeSignIdentity": "iPhone Distribution",
"developmentTeam": "XXXXXXX",
"packageType": "app-store",
"provisioningProfile": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"iCloudContainerEnvironment": "Production",
"buildFlag": [
"-UseModernBuildSystem=0",
"EMBEDDED_CONTENT_CONTAINS_SWIFT = YES",
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
"LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
]
}
}
}
Multiple profile usage in build.json
whith @HarelM solution:
{
"ios": {
"release": {
"codeSignIdentity": "iPhone Distribution",
"developmentTeam": "XXXXXXX",
"packageType": "app-store",
"provisioningProfile": {
"app.package.name": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"app.package.name.NotificationService": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
},
"iCloudContainerEnvironment": "Production",
"buildFlag": [
"-UseModernBuildSystem=0",
"EMBEDDED_CONTENT_CONTAINS_SWIFT = YES",
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
"LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
]
}
}
}
I'm currently really blocked by this. Does anyone know of a workaround that will allow me to edit the exportOptions.plist
file after cordova generates it, but before the archive is exported? From what I can tell, this all happens inside the cordova compile
command and there's no hook that will allow me to do this.
You can fork cordova-ios and apply this change if you want the latest version or you can take my fork and use it in package.json
as a git reference and not use the official vesion.
@HarelM can you confirm that the multiple profile usage of build.json
suggested by @ollm works with your fork? I've tried using it for my multiple profiles (main app and share extension) but the build step fails with the error error: "ShareExt" requires a provisioning profile with the App Groups feature. Select a provisioning profile in the Signing & Capabilities editor. (in target 'ShareExt' from project '{Project Name}')
. Of course the ShareExt
provisioning profile actually exists and is specified in the build.json
as @ollm suggested, so that means the build step is not finding it correctly.
I can't confirm this anymore unfortunately. Since this was ignored for far too long I have found a solution that does not use the shareext plugin and thus are not using my fork and do not need two provisioning profiles anymore... Sorry... Maybe @ollm is still using it and can confirm this is still valid. As a side note, it might be that the provisioning profile exists but lack the App Group features...? Sorry I can't truly help. It used to work when I used it back then...
Okay thanks for confirming. Can you share the alternate solution you found please? And on my end yes I've confirmed that the profile has the App Groups feature.
Yes, I still use them to display images in push notifications
First I recommend that you check if the two or more profiles appear in the file ./projectName/platforms/ios/exportOptions.plist
after build, I build using the command line like this cordova build ios --device --realese --buildConfig build.json
.
Like this:
<?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>compileBitcode</key>
<false/>
<key>method</key>
<string>app-store</string>
<key>iCloudContainerEnvironment</key>
<string>Production</string>
<key>teamID</key>
<string>XXXXXX</string>
<key>provisioningProfiles</key>
<dict>
<key>app.package.name</key>
<string>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</string>
<key>app.package.name.NotificationService</key>
<string>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</string>
</dict>
<key>signingStyle</key>
<string>manual</string>
<key>signingCertificate</key>
<string>iPhone Distribution</string>
</dict>
</plist>
If the profiles don't appear, open the files ./projectName/platforms/ios/cordova/lib/build.js
and ./projectName/platforms/ios/cordova/build
and check that the @HarelM changes are present, if they are not you can edit these same files manually or reinstall the cordova-ios
fork.
I basically associate the files and urls with my app, nothing else. I use some plugins for that, mainly web intent and deep links. You can see my code in the following places: iOS hack: https://github.com/IsraelHikingMap/Site/blob/be555a25e37b6d274d11f74a998986a5b27881a1/IsraelHiking.Web/src/index.html#L137 The main service I use: https://github.com/IsraelHikingMap/Site/blob/be555a25e37b6d274d11f74a998986a5b27881a1/IsraelHiking.Web/src/application/services/open-with.service.ts And a lot of definitions in the config.xml: https://github.com/IsraelHikingMap/Site/blob/be555a25e37b6d274d11f74a998986a5b27881a1/IsraelHiking.Web/config.xml
@ollm thanks for the additional info, I'll check to see if that fixes my problem.
@HarelM thanks a lot for sharing. I don't use angular so please confirm if this is a correct description of your workaround: you use the config.xml
file to specify all the file types that your app can receive from a share, and when the share happens (in the form of a deep link), you parse the shared information and route to the appropriate part of your app. Is that accurate?
If it is, I have one more question: did you have to take any additional steps to make your app a share target for those file types, or was it sufficient to only specify them in the config.xml
file?
Something that I have forgotten to comment on is that I think it is necessary to have Automatically manage signing
disabled (That's how I have it), although I'm not entirely sure.
@CodeWithOz in general, yes. The index.html is not related to angular and is super important for iOS. I use other plugins to handle intent in android, I don't remember now exactly which one, you can check my package.json file...
Can I ask what is preventing merging this and what I can do to assist to move it forward? Would be very useful for my notification service extension allowing me to build via command line, maybe not everyones use case but it works and doesn't impact those not using them.
BTW, I'm currently migrating to Capacitor where this is not longer a concern as you simply create the exportOptions.plist
file, check it in and use it how ever you see fit.
I did returned to this code in order to understand how to write the file and the command line to archive and export in xcode, but other than that this is no longer needed :-)
Could anyone say if there any workaround to use several profiles with cordova build?
This was my workaround, it didn't got merged, so I don't think there's another option besides building this manually from xcode...
Can you rebase against the main branch?
The PR has changes to file bin/templates/scripts/cordova/build
which has been removed in the main branch. This file should be deleted.
This PR is two years old now. I can't say I fully remember what I did there although the change wasn't big, so in theory I should be able to remember. Having said that, I no longer use Cordova as I migrated to Capacitor, so feel free to copy the code and use it, or create a different PR. Sorry...
I have send a pull request with the changes on the master branch https://github.com/apache/cordova-ios/pull/1251, I can confirm that these changes work on cordova-ios
version 6.2.0
, but I haven't tested it on the master version yet.
Could you tell me how can I install cordova-ios
master version in my project to test it?
@ollm any of these variants should work.
If you want to install the main branch of your fork, on github.
-
cordova platform add github:ollm/cordova-ios
-
cordova platform add [email protected]:ollm/cordova-ios.git
-
cordova platform add https://github.com/ollm/cordova-ios.git
Note: The path contains ollm
, which represents your fork of the repo. If you want to use anyone elses fork, just update the path.
Or you can install from a local directory.
-
cordova platform add /path/to/cordova-ios
@ollm any of these variants should work.
If you want to install the main branch of your fork, on github.
cordova platform add github:ollm/cordova-ios
cordova platform add [email protected]:ollm/cordova-ios.git
cordova platform add https://github.com/ollm/cordova-ios.git
Note: The path contains
ollm
, which represents your fork of the repo. If you want to use anyone elses fork, just update the path.Or you can install from a local directory.
cordova platform add /path/to/cordova-ios
Thanks, I have tested the changes and it works perfectly with multiple provisioning profiles (I have tested with 2 profiles)
If there is anything else I need to do to get the branch merged, please let me know (eg documentation)