Skip to content

Add StoreKit Configuration support to Xcode Schemes. #3185

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yanks
Copy link

@yanks yanks commented May 20, 2025

This change satisfies requirements of #3130, allowing the user to supply a relative path to a storekit configuration file based on the workspace root:

xcodeproj(
<snip>
    xcschemes = [
        xcschemes.scheme(
            name = "MyApp",
            run = xcschemes.run(
                launch_target = ":MyApp",
                storekit_configuration = "path/to/StoreKitConfig.storekit",
            ),
        ),
</snip>
)

The result is this written to the relevant xcscheme:

      <StoreKitConfigurationFileReference
         identifier = "../../path/to/StoreKitConfig.storekit">
      </StoreKitConfigurationFileReference>

A few notes:

  • I'm pushing this out a bit early, because I couldn't figure out a great way to resolve a label to a given filegroup to a reasonable path relative to the project root. xcschemes_json encodes as a string into the rule, and it seems a bit unwieldy to have to resolve this issue for something that will never be modeled within bazel anyway (as this is an Xcode-only feature). I would love input on this! I think the tradeoff of just requiring the file to be relative to the workspace root to be sufficient, but happy to discuss.
  • There are a few more tests I'd like to write, and some guardrails on the file itself (project generation should fail when it can't resolve the path to storekit file)

Here's a screenshot of this working within our project:
Screenshot 2025-05-20 at 6 41 34 PM

brentleyjones
brentleyjones previously approved these changes May 20, 2025
Copy link
Contributor

@brentleyjones brentleyjones left a comment

Choose a reason for hiding this comment

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

Approve only to get CI to run.

@@ -256,6 +256,7 @@ def _launch_action_test(ctx):
diagnostics = None,
env = env,
working_directory = None,
storekit_configuration = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make this alphabetical.

@@ -590,6 +590,7 @@ def info_constructors_test_suite(name):
env_include_defaults = "1",
launch_target = xcscheme_infos_testable.make_launch_target(),
xcode_configuration = "",
storekit_configuration = "",
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, and everywhere.


return result.joined(separator: "/")
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
}

@@ -0,0 +1,26 @@
import Foundation
extension URL {
func relativize(from source: URL) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

We haven’t needed this until now. I question if we still need it. Is there a way to make sure it comes in correctly from Starlark instead?

Copy link
Author

Choose a reason for hiding this comment

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

I struggled with this a lot. I suppose I could relativize this within starlark and provide a relative path there, but there is no great way to get a true path to the file via the rule itself. The schemes are encoded via json and supplied here: https://github.com/MobileNativeFoundation/rules_xcodeproj/blob/main/xcodeproj/internal/xcodeproj_incremental_rule.bzl#L835

And other things within the scheme match up based on identifier encodings, but this requires a path that is relative to the resultant scheme directory itself in the generated xcodeproj from what I can tell. I am happy to do it differently, but I think the outcome ends up being something considerably more complex. I'm not particularly experienced in working with rules_xcodeproj, so after banging my head on this for a little bit I threw up my hands and went with this. Open to suggestions!

Copy link
Contributor

Choose a reason for hiding this comment

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

Mainly we want to be able to "cache" things in Bazel. Doing this work in the generator means it's re-done every time the generator runs. I'll leave it up to the other @MobileNativeFoundation/rules_xcodeproj-maintainers on what they think about this.

@brentleyjones brentleyjones dismissed their stale review May 20, 2025 23:08

Only approved to run CI.

@chrisballinger
Copy link

Oh perfect, thank you for diving into this!

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.

3 participants