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

Resolve build settings to see if PRODUCT_BUNDLE_IDENTIFIER is present #71

Merged
merged 1 commit into from
Jun 25, 2022

Conversation

chuganzy
Copy link
Contributor

@chuganzy chuganzy commented Apr 21, 2022

Some projects might utilize config files, or might just inherit the root project settings.

To support these setup, instead of just seeing the build configuration only, this PR makes it to resolve the configuration to see if PRODUCT_BUNDLE_IDENTIFIER is present.

API doc is available here: https://www.rubydoc.info/gems/xcodeproj/Xcodeproj%2FProject%2FObject%2FXCBuildConfiguration:resolve_build_setting

@jdouglas-nz jdouglas-nz merged commit 07254b1 into SiarheiFedartsou:master Jun 25, 2022
@jdouglas-nz
Copy link
Collaborator

tests pass, thanks for the contribution and apologies for the slow update 🙇

@KeiroMidori
Copy link

@jdouglas-nz actually now I get an error: Cannot find app with $(PRODUCT_BUNDLE_IDENTIFIER) bundle ID in the App Store which makes sense because this specific scheme isn't on the appstore. So I went ahead and used the bundle_id argument instead but when doing so my CI is prompted for the scheme. So I went ahead and added the scheme argument but it is a conflicting argument with bundle_id. So now I have no way of using increment_version_number_in_xcodeproj anymore with my CI pipeline.

🙁

@jdouglas-nz
Copy link
Collaborator

@KeiroMidori is this as a result of the latest release?

For your particular setup, could you tell me how you'd want to invoke this code? Like, what arguments would you pass such that it could serve your usecase, but potentially everyone else's?

Alternatively - but maybe as well - could you provide me a stripped down version of your xcodeproj so that I could write a test against it ?

🙇‍♂️

@KeiroMidori
Copy link

Hey @jdouglas-nz, my project contains 3 schemes with 3 different bundle ids (for adhoc, prod and development). It only has 1 target though.

These 3 schemes are required to build .ipa(s) for different environment as you would imagine. But they are all synchronized on their version number.

So my use case is then I start a CI run to build and push a specific scheme, I'd like to get the latest Appstore version for the production scheme and increment the xcodeproj file accordingly even if the scheme's bundle id isn't the production one.

More detailed rundown:

Given that I have a project called MyApp.xcodeproj, and have 3 schemes for adhoc, dev and release let's call them MyApp-Adhoc, MyApp-Dev, and MyApp-Prod.

MyApp is live on the AppStore with version 1.0.0.

I want to push an new build for internal QA using my adhoc scheme via my CI pipeline. So I call increment_version_number_in_xcodeproj to fetch the latest AppStore version number and increment it. My expected result will be 1.0.1.

Let me know if that's clear enough.

@jdouglas-nz
Copy link
Collaborator

@KeiroMidori I should be able to create a hello world xcodeproj with that structure. Although when I have a PR up I'll need you to review the project file at the least if you are unable to provide me one - hopefully that's ok!

In the interim - would you be able to downgrade and be functional again while I look into this ?

@KeiroMidori
Copy link

@jdouglas-nz of course I would be happy to help review the PR. Thank you for taking the time on this.

Yes I should be able to downgrade in the meantime. 🙏🏽

@jdouglas-nz
Copy link
Collaborator

@KeiroMidori awesome, thanks! As much as I wish I could start this right now, I have to work my normal job 😭

I do have some time available this weekend to look and intend to, but this also depends on a conversation I'm having with a mortgage broker too 🙃 (trying to buy a house!). Should be fine though.

Hopefully you aren't completely blocked in the meanwhile 🤞

@KeiroMidori
Copy link

Oh that's so nice congratulations to you ! The house/mortgage obviously is much more important.

When you have time is perfect 🤙🏽

I won't let this block me don't worry about it

@KeiroMidori
Copy link

@jdouglas-nz any update on this?

@jdouglas-nz
Copy link
Collaborator

@KeiroMidori thanks for the bump. I am going to look at this next weekend; hope that's ok. My life has been chaotic recently 🫣😖

@chuganzy
Copy link
Contributor Author

chuganzy commented Aug 15, 2022

Hi, @jdouglas-nz and @KeiroMidori. Apologies for not responding here at all.. I just recently moved and had no chance to look into the conversation.
I can probably help looking into the issue soon! I will keep you all posted!

@chuganzy chuganzy deleted the resolve-config branch August 15, 2022 15:32
@chuganzy
Copy link
Contributor Author

chuganzy commented Aug 22, 2022

@KeiroMidori Can you make sure if your setup works with v0.5.0 to identify the root cause?
According to what you posted above, it looks like your CFBundleIdentifier in Info.plist has $(PRODUCT_BUNDLE_IDENTIFIER) as its value. However this plugin does not seem to resolve these build variants to get the actual bundle identifier from the beginning, and therefore it fails to get the app store version number.

If this is the case, I'd rather take it as a feature request (enhancement), and want to decouple the issue from this PR. I am happy to help adding it though!

@KeiroMidori
Copy link

@chuganzy yes it works with v0.5.0. And yes I think that's the issue. Definitely can be treated as a feature request. If you don't mind creating it that'd be great, I feel like you probably know more about the potential problem than me at this point.

@chuganzy
Copy link
Contributor Author

@KeiroMidori Thanks.. Though that is.. not what I expected😅😂
I thought it should not work with 0.5.0 neither.. I myself also tried to imitate your project setup and ran the script against 0.5.0, and it failed. Probably there is something missing on my end. Let me take another moment to see the root cause.

@KeiroMidori
Copy link

Never mind @chuganzy its bad recollection on my end. I did retry v0.5.0 and indeed it doesn’t work either. I changed $(PRODUCT_BUNDLE_IDENTIFIER) on all of my plist files to work around the problem.

So it’s up to you if you want to pursue this as a feature improvement. I do think a lot of people use this variable.

@chuganzy
Copy link
Contributor Author

@KeiroMidori That makes sense! Let me move the conversation to a new issue to tackle with this issue.

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.

None yet

3 participants