Simplify project files with Xcodegen templates #2153
Draft
+156
−193
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

🎟️ Tracking
📔 Objective
When I added Sourcery to BitwardenKit (#2136), I wondered if we could simplify some of the duplication in our project files.
This is an attempt at using Xcodegen's templates to share some common logic between targets.
There's two categories of templates that I've added:
CommonTarget: this is meant for app or framework targets and mainly includes all files other than tests and test helpers (mocks, fixtures, etc).TestTarget: a unit testing target which excludes ViewInspector and snapshot tests.SnapshotTestTarget: a test target for snapshot tests.ViewInspectorTestTarget: a test target for ViewInspector tests.SourceryTarget: a template for a target that needs a Sourcery pre-build script.The templates are defined in project-common.yml.
Going forward, adding Sourcery to a target is simplified to adding
SourceryTargetto the list of a target's templates (and adding the generated file to any test targets):Note
One issue I ran into is how we handle fixtures differently between targets. In
BitwardenKitwe include fixtures inBitwardenKitMocksand exclude them from the test targets so that they can be shared. Other targets include the fixtures in the test targets. I ended up not using the templates for the BitwardenKit test targets for this reason (51342b0). We could consider moving these fixtures into a "SharedFixtures" directory which would facilitate adding aMockTargettemplate though.Diff of the project files before and after:
The only noticeable change here of the project files is the removal of the
gitignorefiles, which I intentionally excluded. So even though this changes a bunch of stuff, I hope I've minimized any potential issues 🤞.⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes