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

feat: support multiple provisioning profiles #956

Closed
wants to merge 4 commits into from

Conversation

HarelM
Copy link

@HarelM HarelM commented Jul 27, 2020

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

Resolves #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

  • 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... :-(
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • 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.

@HarelM
Copy link
Author

HarelM commented Aug 20, 2020

anyone?

@timbru31
Copy link
Member

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?

@HarelM HarelM changed the title (iOS) Support multiple provisioning profiles (iOS) Support multiple provisioning profiles, Resolves #953 Aug 20, 2020
@HarelM
Copy link
Author

HarelM commented Aug 20, 2020

@timbru31 Updated the name, hope this is what you intended.

@timbru31 timbru31 linked an issue Aug 20, 2020 that may be closed by this pull request
3 tasks
@HarelM
Copy link
Author

HarelM commented Aug 20, 2020

@timbru31 done! Thanks for the review.
Let me know when a new version is available. :-)

@HarelM
Copy link
Author

HarelM commented Aug 26, 2020

@timbru31 anything else that I need to do? Can this be merged?

@breautek breautek requested a review from timbru31 August 29, 2020 00:15
Copy link
Contributor

@breautek breautek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm to me, but I'm unable to test cause I lack hardware... Would like at least one other PMC member that has a mac to review.

@HarelM
Copy link
Author

HarelM commented Sep 16, 2020

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... :-)

@HarelM
Copy link
Author

HarelM commented Oct 2, 2020

Anything I can do in order to move this request forward?

@brodycj
Copy link
Contributor

brodycj commented Oct 2, 2020

I would recommend that you follow up with us on the mailing list or on Slack.

@HarelM
Copy link
Author

HarelM commented Nov 2, 2020

@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... :-(

@ollm
Copy link
Contributor

ollm commented Oct 8, 2021

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\""
            ]
        }
    }
} 

@jlews
Copy link

jlews commented Dec 6, 2021

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.

@HarelM
Copy link
Author

HarelM commented Dec 6, 2021

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.

@CodeWithOz
Copy link

CodeWithOz commented Jan 24, 2022

@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.

@HarelM
Copy link
Author

HarelM commented Jan 24, 2022

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...

@CodeWithOz
Copy link

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.

@ollm
Copy link
Contributor

ollm commented Jan 24, 2022

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.

@HarelM
Copy link
Author

HarelM commented Jan 24, 2022

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

@CodeWithOz
Copy link

@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?

@ollm
Copy link
Contributor

ollm commented Jan 24, 2022

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.

Profile

@HarelM
Copy link
Author

HarelM commented Jan 24, 2022

@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...

@SteveGilvarry
Copy link

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.

@HarelM
Copy link
Author

HarelM commented Aug 8, 2022

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 :-)

@Makishima
Copy link

Could anyone say if there any workaround to use several profiles with cordova build?

@HarelM
Copy link
Author

HarelM commented Aug 31, 2022

This was my workaround, it didn't got merged, so I don't think there's another option besides building this manually from xcode...

Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM

Tested the following commands to confirm that the standard process continues to build successfully. (with & without build.json configurations)

  • cordova build ios
  • cordova build ios --debug
  • cordova build ios --release
  • cordova run ios (simulator) (ad-hoc)

I also uploaded the built release (ad-hoc) ipa to a physical device running iOS 15.6.1.

As for testing multiple provisioning profiles, I do not have a project to confirm the feature/settings.

@erisu erisu changed the title (iOS) Support multiple provisioning profiles, Resolves #953 feat: support multiple provisioning profiles Aug 31, 2022
@erisu
Copy link
Member

erisu commented Aug 31, 2022

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.

@HarelM
Copy link
Author

HarelM commented Aug 31, 2022

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...

@ollm
Copy link
Contributor

ollm commented Aug 31, 2022

I have send a pull request with the changes on the master branch #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?

@erisu
Copy link
Member

erisu commented Aug 31, 2022

@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
Copy link
Contributor

ollm commented Aug 31, 2022

@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)

@erisu erisu closed this in #1251 Sep 5, 2022
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

Successfully merging this pull request may close these issues.

Wrongly created exportOptions.plist file - multiple provisioning profile support
10 participants