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

Update build schema to force you to select correct target when building tests #1927

Merged
merged 1 commit into from
Feb 15, 2024

Conversation

amy-at-kickstarter
Copy link
Contributor

@amy-at-kickstarter amy-at-kickstarter commented Feb 1, 2024

📲 What

Force you to select the correct build schema when running tests via Xcode.

🤔 Why

Say you have an arbitrary target selected, and you try and run some tests by hitting the play button. In this example, I'm trying to run a test in Library-iOS-Tests, and I have the Kickstarter-iOS target selected, because I was running the app.

Screenshot 2024-02-01 at 11 19 09 AM

You might be treated to this linker error. However, look closely - why is it trying and failing to build KsApiTests?
Screenshot 2024-02-01 at 11 19 55 AM

This is odd - while Library-iOS depends on KsApi, Library-iOS-Tests does NOT depend on KsApiTests.

Looking into the dependency graphs, and it looks like the app is trying to build Kickstarter-iOS, and then as part of that, it included KsApiTests. That is also odd. First, why is it building Kickstarter-iOS instead of just Library-iOS and Library-iOS-Tests? And for that matter, why would Kickstarter-iOS (the app) depend on KsApiTests (a test bundle)?

Screenshot 2024-02-01 at 11 20 46 AM

It turns out the answer was in the schema. Kickstarter-iOS was set up so that it was associated with all of our tests, and it would try to run them (all!) if it was selected as the schema when you run any tests. As far as I can tell, this led to general Xcode and linker strangeness, until you either swapped targets or ran a full project clean.

Screenshot 2024-02-14 at 4 12 23 PM

The solution was to uncheck all those test boxes. Now, when you try to run a test in the same scenario, you get this handy pop-up that forces you to swap to the correct test target:

Screenshot 2024-02-01 at 11 21 59 AM

@amy-at-kickstarter amy-at-kickstarter force-pushed the feat/adyer/fix-coreaudiotypes-linker-error branch from d27d2a8 to ce200b9 Compare February 14, 2024 21:07
@amy-at-kickstarter amy-at-kickstarter changed the title Update build schemas to prevent linker errors Update build schema to force you to select correct target when building tests Feb 14, 2024
@amy-at-kickstarter amy-at-kickstarter force-pushed the feat/adyer/fix-coreaudiotypes-linker-error branch from ce200b9 to 8fd48bc Compare February 14, 2024 21:18
@amy-at-kickstarter amy-at-kickstarter marked this pull request as ready for review February 14, 2024 21:19
@amy-at-kickstarter amy-at-kickstarter self-assigned this Feb 14, 2024
Copy link
Contributor

@ifosli ifosli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@amy-at-kickstarter amy-at-kickstarter force-pushed the feat/adyer/fix-coreaudiotypes-linker-error branch from 8fd48bc to a0ac3ef Compare February 15, 2024 15:37
…ng tests

I found that this change improved the number of linker errors I got when running individual tests via Xcode.
@amy-at-kickstarter amy-at-kickstarter force-pushed the feat/adyer/fix-coreaudiotypes-linker-error branch from a0ac3ef to 20a7964 Compare February 15, 2024 16:06
@amy-at-kickstarter amy-at-kickstarter merged commit beb3b00 into main Feb 15, 2024
5 checks passed
@amy-at-kickstarter amy-at-kickstarter deleted the feat/adyer/fix-coreaudiotypes-linker-error branch February 15, 2024 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants