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

Fix logic related PBXVariantGroup #1296

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

takeshi-1000
Copy link

@takeshi-1000 takeshi-1000 commented Dec 5, 2022

Fixed logic in PBXVariantgGroup to meet the requirements of one my project.

  • Even if there is no localize file in Base.lproj, recognize localize file as PBXVarientGroup, generate appropriate PBXFileReference, and generate PBXBuildFile for appropriate target. Localized strings resources are not detected correctly #763
  • To be able to add a PBXVariantGroup of one target A to another B target
    • Add the path of the file that is the source of the PBXVariantGroup you want to add to source. (Please refer to the fix for Tests/Fixtures/TestProject/project.yml in this PR)

Description

Previous behavior

SourceGenerator generated a PBXVariantGroup object, created a reference associated with it, and generated a PBXBuildFile object to be added to any target.

This PR

Changed the logic so that the PBXVariantGroupGenerator creates a PBXVariantGroup object and a reference to it, and the SourceGenerator creates a PBXBuildFile object to which targets to add.

It seemed possible to complete it within SourceGenerator as it is now, but I created PBXVariantGroupGenerator for the following background.

・When implementing a function to add a PBXVariantGroup that belongs to one target group to another target, the source code in the SourceGenerator could become complicated and huge, making the code difficult to read. Specifically, the code around the link below is the process of adding targets for other groups.

let variantGroup: PBXVariantGroup? = pbxVariantGroupInfoList

Concern

  • My approach slows down the CLI execution speed. This is because the parsing of the target source code is done extra for the parsing of LocalizeDir.
  • Due to the above, it was necessary to prepare common logic that depends on extracting the source code to be analyzed. (This makes TargetSourceFilterable compliant with SourceGenerator and PBXVariantGroupGenerator.) It may not be the most suitable method, but I took the method of conforming to the protocol for the time being.

Also Please let us know if you have any other suggestions.
Thanks.

## SourceGenerator
- adapt SourceGenerator to TargetSourceFilterable
- refactor variant group logic
- add logic where you can add target membership to another target

## PBXProjGenerator
- apply. new PBXProjGenerator

## SourceType
- add new sourceType
@takeshi-1000
Copy link
Author

I will check ci problem.

@takeshi-1000
Copy link
Author

@yonaskolb
Could you check this pull request, if possible ?

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.

1 participant