-
Notifications
You must be signed in to change notification settings - Fork 823
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
Improve INFOPLIST_FILE handling to only omit used Info.plist's from Copy Bundle Resources Build Phase #1027
Improve INFOPLIST_FILE handling to only omit used Info.plist's from Copy Bundle Resources Build Phase #1027
Conversation
1c74b05
to
56ef412
Compare
Thanks so much for looking at this @liamnichols, I like the way you're approaching it so far |
@yonaskolb: I hit a bit of a bump here while trying to think things through throughly... In theory, the value of the While I think it's probably uncommon to change the filename based on random build settings, I don't think it's unrealistic for people to have carried over These are the options that I came up with:
Option 3 would basically mean that if you defined Either way, we would probably have to document this a bit better somewhere. |
@liamnichols. I think we want to optimise for a working project. At the end of the day, if the Info.plist file is bundled as a resource it's not a major deal, and there will always be a way to remove this by explicitly setting all those files to resource none. So we should use our best efforts to exclude it, but within reason. Option 2 is something I don't want to handle. I think option 1 is fine. We'll check against the path, and if that includes build variables it just won't match and won't be excluded. |
Before I started trying to pass the phases in, I found a couple of method arguments that seemed to be redundant in
|
Looks good to me @liamnichols. Thanks for cleaning this up. This file and the PBXGenerator have had all sorts of hands in it changing different things, so they need a bit of love 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yonaskolb: I've now finished the implementation with 06bd547 to get the tests into a passing state. Again, feedback on the approach would be super appreciated 🙏 It was simpler than I was expecting but I wonder if I need to take extra care around resolving paths?
I could probably do with adding some extra tests to SourceGeneratorTests.swift to catch some edge cases but just wondering how much to add.
Cheers!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @liamnichols!
@liamnichols whenever you have time to update this, it would be good to release this, as it's a fix in some respects |
Ah thanks for reminding me. I’ll have some time over this weekend to get it ready 👍 |
…ce bsaed on 2.18.0 generator
…nfo.plist' to simulate scenario in yonaskolb#945
…iles for a target
…ource files for a target
…ource files for a target
…al methods when generating source files in a target
…d build phases in order to prioritise over 'default' value. Remove explicit Info.plist check from SourceGenerator. Update PBXProjGenerator to inject hash of build phases for resolved INFOPLIST_FILE values. Update SourceGeneratorTests to comply with change where only the FIRST Info.plist is excluded from copy bundle resources build phase, additionally resolve absolute path
06bd547
to
6dc456c
Compare
Things left to do:
|
Not sure if i need to do anything here actually. Let me know what you think @yonaskolb. This is ready now 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you again for your fantastic work here @liamnichols! 👏
Closes #1045
Background
Prior to #945, a lot of XcodeGen was build assuming that a file named Info.plist was the value used in
INFOPLIST_FILE
build setting. This file is different to other plists because it shouldn't be included in the copy bundle resources build phase.If
INFOPLIST_FILE
was named anything other than Info.plist, by default, XcodeGen would include the file in the build phase which would result in a warning.#945 took a stab at fixing this by relaxing the checks so that any file that had been suffixed with Info.plist would then be treated as an Info.plist to support the old(?) pattern of using a file named
{TargetName}-Info.plist
. This however caused a noticeable regression for projects that include the GoogleService-Info.plist file which should be treated as a resource (this file is nothing to do with an bundles info property list and instead is a resource used by popular Google SDKs.So I looked back at @yonaskolb's initial comment:
Description
In this change, I am taking a stab at improving things for both scenarios. To begin with in 5a856b8, I checked out 2.18.0 and added a GoogleService-Info.plist file to the resources and regenerated the fixtures as expected. I then went back to 2.19.0 and also generated the fixtures with a target which defines the Info.plist as App-Info.plist in
61e2c3b.
Now that we have updated fixtures that reproduce both use cases, it should now be a matter of changing things until the tests pass 😬
In
PBXProjGeneractor
, the finalINFOPLIST_FILE
build setting value for a given target isn't resolved until wayyyy after the array ofSourceFile
objects (which define the desiredbuildPhase
) are created. I figured that the first task would be to resolve these values upfront so that we can use the actualINFOPLIST_FILE
values to influence theSourceFile
's that we resolve (instead of guessing based on filename). So far, I've refactored the build setting resolution logic in 56ef412e6e87431a33ab71470a6ca130a1ac27c4 so that I now have a[Config: String?]
dictionary that contains theINFOPLIST_FILE
values for each build config of the target.What's Next
The next step is to somehow pass this information into
SourceGenerator.getAllSourceFiles(targetType:sources:)
so that it'll return aSourceFile
with it'sbuildPhase
value set toBuildPhaseSpec.none
for the real Info.plist files (to make the tests pass). This is where I'm a little stuck.After trying to poke around, I felt like it was quite difficult to pass the set of files deep into the
SourceGenerator
and before I continue, I want to confirm that I'm on the right tracks.Part of me did wonder if I could maybe instead just mutate the
target.sources
array before passing it into theSourceGenerator
since I could just pretend that it was just set in the spec file, but I wondered if it was wrong to override the value that was potentially set in the project spec in doing this. Ideally we should probably prioritise the explicitly set value before and just use.none
as a fallback before the result ofgetDefaultBuildPhase(for:targetType:)
.I've run out of time this evening on this one so before I look at it with a fresh pair of eyes later this weekend, I thought I'd push the changes up and maybe somebody else could give some input (👀 @yonaskolb 😬)