Skip to content

Conversation

kcieplak
Copy link
Owner

@kcieplak kcieplak commented Oct 2, 2025

Fix a crash when unwrapping an optional 'mainModule' of a module.
In the case where a plugin has a dependency on a 'binaryTarget' there is no main module.

This only presents itself when you have defined the binaryTarget as
both a product and target.

  • Update method that determines plugin dependencies to handle binaryTarget types explicitly.
  • Add a PIF generation test that captures this behavior.

@kcieplak kcieplak force-pushed the topics/fix-gh-9067 branch from ad890c5 to dc9f56b Compare October 2, 2025 17:01
}
// For products with a main module, compare package identity and name
// (build triples are no longer used in the package graph)
guard let mainModule = mainModuleProduct.mainModule else { return false }
Copy link

@pmattos pmattos Oct 3, 2025

Choose a reason for hiding this comment

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

suggestion: I think we can move the guard to the top. For instance:

guard let mainModule = mainModuleProduct.mainModule else { 
    return mainModuleProduct.type == .executable &&
           mainModuleProduct.modules.only?.type == .binary
}
...

I also simplified the logic a bit :)

@kcieplak kcieplak force-pushed the topics/fix-gh-9067 branch 5 times, most recently from ca63fb1 to fec6d4e Compare October 3, 2025 17:21
Fix a crash when unwrapping an optional 'mainModule' of a module.
In the case where a plugin has a dependency on a 'binaryTarget'
there is no main module.

This only presents itself when you have defined the binaryTarget as
both a product and target.

* Update method that determines plugin dependencies to handle
  binaryTarget types explicitly.
* Add a PIF generation test that captures this behavior.
@kcieplak kcieplak force-pushed the topics/fix-gh-9067 branch from fec6d4e to 921daeb Compare October 3, 2025 17:57
Based on Review.
* Remove unwrapping and use the guarded mainModule variable.
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.

2 participants