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

Cordova overwrites bundleIdentifier for all existing targets #538

Closed
wolfmanfx opened this issue Feb 19, 2019 · 29 comments · Fixed by #820
Closed

Cordova overwrites bundleIdentifier for all existing targets #538

wolfmanfx opened this issue Feb 19, 2019 · 29 comments · Fixed by #820

Comments

@wolfmanfx
Copy link

wolfmanfx commented Feb 19, 2019

Bug Report

When cordova (using 5.0.0) projects contains watch targets (watchkit, watch extension) which have their own bundle id setup correctly, cordova overwrites all targets with the same id.

Problem

Its not possible to pack new targets in the project and use cordova cli build
cordova build --platform ios --device --release

What is expected to happen?

It should not overwrite the PRODUCT_BUNDLE_IDENTIFIER of all targets.

What does actually happen?

Signing does not work anymore.

  • [ x] I searched for existing GitHub issues
  • [ x] I updated all Cordova tooling to most recent version
  • [x ] I included all the necessary information above

Updates by @brodybits:

This issue seems to also break functionality of plugins that do extensions to Xcode projects by using hooks. See below for discussions.

@janpio
Copy link
Member

janpio commented Feb 19, 2019

So did I understand correctly that using cordova build ios --device --release overwrite the bundle identifiers of other targets?

Can you pinpoint which files are changed to do this (quickly create a temp git project in platform/ios with git init, commit everything, then do the build, then look at the changed files to exactly pinpoint what files got edited)?

@wolfmanfx
Copy link
Author

Hi,
I create the project with cordova (I mean the xcode project) than I am patching the project.pbxproj and add 2 targets (watchapp, watchapp extension) when I stay within xcode everything is correct. But we build within travis so I am using the cli to create and export the ipa - but the signing process fails.

When I open the project.pbxproj the PRODUCT_BUNDLE_IDENTIFIER for all 3 targets are different and correct when I run
cordova build --platform ios --device --release
All PRODUCT_BUNDLE_IDENTIFIER within the project.pbxproj are overwritten which breaks all other targets.

Can you point to the code where the updates happen?

@dpogue
Copy link
Member

dpogue commented Feb 19, 2019

That happens here:

if (origPkg !== pkg) {
events.emit('verbose', 'Set PRODUCT_BUNDLE_IDENTIFIER to ' + pkg + '.');
proj.updateBuildProperty('PRODUCT_BUNDLE_IDENTIFIER', pkg);
}

@wolfmanfx
Copy link
Author

wolfmanfx commented Feb 19, 2019

Ok - pbxProject.prototype.updateBuildProperty = function(prop, value, build) calls var configs = this.pbxXCBuildConfigurationSection(); which returns all targets and we overwrite all targets so thats really a problem.

Looking here https://github.com/apache/cordova-node-xcode/blob/master/lib/pbxProject.js#L1128 I guess that function is not designed for the usecase to update just one target.

My vote would to not update the bundle id but if needed it should only update a specific target.

Any thoughts?

@dpogue
Copy link
Member

dpogue commented Feb 19, 2019

We have to update the bundle ID because that's how it gets set in the Info.plist

@wolfmanfx
Copy link
Author

The bundle id is set on creation but the overwrite happens on the build stage too - or does the cli can not distinct between initial creation and build step?

@wolfmanfx
Copy link
Author

It could also help to disable this behaviour through a flag or so, just thinking loud :)

@wolfmanfx
Copy link
Author

Another idea would to create a parameter for the build.json which defines the target project and we overwrite just the settings of the desired project instead of every target?

@wolfmanfx
Copy link
Author

So I am open for input as I am going to fork and fix that issuse.

@janpio
Copy link
Member

janpio commented Feb 20, 2019

The bundle id is set on creation but the overwrite happens on the build stage too - or does the cli can not distinct between initial creation and build step?

Probably because a build also runs the prepare command, which includes the code @dpogue linked to above.

@dpogue
Copy link
Member

dpogue commented Feb 20, 2019

Whatever the default behaviour is must not require people to know about Xcode build targets or require manually configuring things in build.json. It needs to just work out of the box for the basic use case of packaging up web content with an auto-generated Xcode project for iOS.

@wolfmanfx
Copy link
Author

Thx - I have created a PR which fixes the behavior, no new params added. I am open for feedback also for a better solution thx

@wolfmanfx
Copy link
Author

So I have pushed a new PR #545 this time I have added a new parameter to the build.json (optional) which is needed to sign mutliple targets with different budleids.

@msari-ipe-ext-1
Copy link

@dpogue Did you had time to review the changes - I know there are some styling things needs to be addressed but if its not gonna merged I wont put extra time into it ;)

@tombell
Copy link

tombell commented Feb 25, 2019

Experiencing this myself, after adding a call kit call directory extension to my project.

@janpio
Copy link
Member

janpio commented Feb 25, 2019

@tombell Have a look at PR #545 then - there is some discussion on how to best solve this. Any opinions are welcome in there.

@dpogue dpogue added this to the 5.0.1 milestone Mar 15, 2019
@dpogue dpogue modified the milestones: 5.0.1, 5.0.2 Apr 17, 2019
@NiklasMerz
Copy link
Member

As @tombell I also have this problem with the call directory plugin and the share/openwith plugin, too.

What can I do the help this getting merged. My tests with the PR were successful.

@msari-ipe-ext-1
Copy link

I am using my branch in productive with an apple watch extension - everything working 👍

@NiklasMerz
Copy link
Member

NiklasMerz commented Nov 4, 2019

@msari-ipe-ext-1 Great to hear!

How do I use multipleProvisioningProfiles? What is the value paramter for? The UUID or the name of the provisioning profile?

I always have trouble with setting provioning profiles automatically for the main app and extensions. This breaks in strange ways.

@msari-ipe-ext-1
Copy link

Hi,

In the build.json you can get multiple key value pairs

"multipleProvisioningProfiles": [ { "key": "de.some.html5", "value": "SOME-Enterprise" }, { "key": "de.some.html5.watchkitapp", "value": "SOMEWE-Enterprise" }, { "key": "de.some.html5.watchkitapp.watchkitextension", "value": "SOMEWE Extension-Enterprise" } ],

@NiklasMerz
Copy link
Member

Yes exactly that's what I am asking. What is value? I this the UUID or the name of the provisioning profile? It looks like you mean profile names, but this does not work for me. But I always need to set provisioning profiles in Xcode because Cordova and plugin hooks can't set them anyhow.

@NiklasMerz
Copy link
Member

NiklasMerz commented Dec 16, 2019

Just to add my perspective on this again shortly. For us this is a critical app because our app uses two plugins that have hooks to add extensions to the Xcode project (calldirectory and share extension). The changes in Cordova 5 mean that the extensions Xcode config gets broken every time the app builds.

I agree that @msari-ipe-ext-1 's solution is to broad and confusing with the prov. profile feature that's why my fork tries to solve this with #708 . We are going to set the prov. profiles anyways by hand or via the plugins hooks. This works for us with this fork and cordova-node-xcode forked around these issues (apache/cordova-node-xcode#79).

I am open to polish #708 as much as possible to get that in a good state to be merged.

@brodycj brodycj changed the title Cordova overwrites bundleIdentifier for all exiting targets Cordova overwrites bundleIdentifier for all existing targets Dec 16, 2019
@brodycj brodycj added this to the 6.0.0 milestone Dec 16, 2019
@brodycj
Copy link
Contributor

brodycj commented Dec 16, 2019

I have updated the title, pushed the milestone to 6.0.0, and added an update to the description. Thanks again @NiklasMerz for your input and contributions so far.

I would like to target the next major release of any components to be updated due to the nature of what is being changed and potential risk of breaking something else.

I would like to find a smooth way to move this forward, unfortunately dealing with very limited maintainer resources (see apache/cordova#163) and lack of understanding of this functionality. I am getting ready to sign off, can take another look in the next day or so.

It would be extremely helpful if someone could walk me and others through:

pascalspadone pushed a commit to alcmeon/cordova-ios that referenced this issue Feb 14, 2020
@kapfab
Copy link

kapfab commented Mar 5, 2020

In case some of you are stuck until this issue is fixed, as a workaround, you can temporarily force the target value of the bundle identifier of the app extension directly in it's Info.plist, so the build does not use the bad project setting.

@ludufre
Copy link

ludufre commented Mar 5, 2020

In case some of you are stuck until this issue is fixed, as a workaround, you can temporarily force the target value of the bundle identifier of the app extension directly in it's Info.plist, so the build does not use the bad project setting.

How?

@kapfab
Copy link

kapfab commented Mar 5, 2020

In case some of you are stuck until this issue is fixed, as a workaround, you can temporarily force the target value of the bundle identifier of the app extension directly in it's Info.plist, so the build does not use the bad project setting.

How?

There is a CFBundleIdentifier entry in the Info.plist file whose value usually references the associated project setting ($(PRODUCT_BUNDLE_IDENTIFIER)). Change this value to the expected bundle identifier.

@NiklasMerz NiklasMerz linked a pull request Mar 14, 2020 that will close this issue
5 tasks
@brodycj
Copy link
Contributor

brodycj commented Mar 29, 2020

What is the status of this? Anyone?

@NiklasMerz
Copy link
Member

NiklasMerz commented Apr 2, 2020

I cannot get my head around how to fix this properly but this is definitly an issue and I hacked around it.

Cordova iOS 5 definitly causes issues for the tiny percentage of apps that use more than the default target (watch, share, calldirectory extensions).

@HarelM
Copy link

HarelM commented Jul 27, 2020

I've sent a related to this: #956 and opened a relevant issue: #953 and a bug #955.
Would love your input on my findings and work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment