Skip to content

feat(app): Implement FirebaseLinkXmlProcessor to merge package linker rules natively during builds#1490

Merged
AustinBenoit merged 4 commits into
mainfrom
feature/upm-linker-processor
Jul 15, 2026
Merged

feat(app): Implement FirebaseLinkXmlProcessor to merge package linker rules natively during builds#1490
AustinBenoit merged 4 commits into
mainfrom
feature/upm-linker-processor

Conversation

@AustinBenoit

Copy link
Copy Markdown
Contributor

Description

Provide details of the change, and generalize the change in the PR title above.

Implement automated linker rules merging for UPM packages to prevent managed code stripping from removing reflection-accessed methods (like FirebaseAuth and FirebaseAppCheck).

This will run as an editor script in unity.
Leverages https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Build.IUnityLinkerProcessor.GenerateAdditionalLinkXmlFile.html
As suggested from https://discussions.unity.com/t/the-current-state-of-link-xml-in-packages/814559/5


Testing

Describe how you've tested these changes.

Built UPM and Unity Packages and tested locally.
Will test again once the packages are built in CI


Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

@wiz-9635d3485b

wiz-9635d3485b Bot commented Jul 14, 2026

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 1 Medium
Software Management Finding Software Management Findings -
Total 1 Medium

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces FirebaseLinkXmlProcessor to automate the merging of link.xml files from Firebase UPM packages and Assets/Firebase into a single temporary linker file, preventing managed code stripping of reflection-accessed methods. Feedback suggests improving XML parsing robustness by validating the <linker> root element and filtering for element nodes, as well as narrowing the file search pattern from *link.xml to exactly link.xml to avoid processing unrelated files.

Comment on lines +63 to +74
if (doc.DocumentElement != null) {
// Traverse the child elements under the root <linker> element of each link.xml.
// NOTE: We only support and extract `<assembly>` elements at this time. Root-level
// `<type>` or `<linker>` attributes other than assembly declarations are ignored.
foreach (XmlNode child in doc.DocumentElement.ChildNodes) {
if (child.Name == "assembly") {
XmlNode importedNode = mergedLinkxmlDoc.ImportNode(child, true);
root.AppendChild(importedNode);
hasAssemblies = true;
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To ensure robustness and avoid processing unrelated XML files, we should validate that the root element of the XML document is indeed <linker>. Additionally, we should verify that the child node is an element node before checking its name, preventing potential issues with comments or whitespace nodes.

          if (doc.DocumentElement != null && doc.DocumentElement.Name == "linker") {
            // Traverse the child elements under the root <linker> element of each link.xml.
            // NOTE: We only support and extract `<assembly>` elements at this time. Root-level
            // `<type>` or `<linker>` attributes other than assembly declarations are ignored.
            foreach (XmlNode child in doc.DocumentElement.ChildNodes) {
              if (child.NodeType == XmlNodeType.Element && child.Name == "assembly") {
                XmlNode importedNode = mergedLinkxmlDoc.ImportNode(child, true);
                root.AppendChild(importedNode);
                hasAssemblies = true;
              }
            }
          }

private void FindLinkXmlFiles(string dir, HashSet<string> files) {
if (!Directory.Exists(dir)) return;
try {
foreach (var file in Directory.GetFiles(dir, "*link.xml", SearchOption.AllDirectories)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using the wildcard *link.xml can match unrelated files (e.g., custom_link.xml or backup_link.xml) that are not actual Unity linker files. Since Unity specifically looks for files named exactly link.xml, we should restrict the search pattern to "link.xml" to prevent merging incorrect files.

        foreach (var file in Directory.GetFiles(dir, "link.xml", SearchOption.AllDirectories)) {

@AustinBenoit AustinBenoit added the tests-requested: quick Trigger a quick set of integration tests. label Jul 14, 2026
@AustinBenoit AustinBenoit requested a review from a-maurice July 14, 2026 19:12
@github-actions github-actions Bot added the tests: succeeded This PR's integration tests succeeded. label Jul 14, 2026
@github-actions

Copy link
Copy Markdown

✅  Integration test succeeded!

Requested by @firebase-workflow-trigger[bot] on commit 52b36f9
Last updated: Tue Jul 14 13:19 PDT 2026
View integration test log & download artifacts

Comment thread editor/app/src/FirebaseLinkXmlProcessor.cs Outdated
Comment thread editor/app/src/FirebaseLinkXmlProcessor.cs
}

// Get all link.xml files from Assets/Firebase.
string assetsFirebasePath = Path.GetFullPath("Assets/Firebase");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Talked offline, but good to verify this won't cause issues with the link xml files in the Assets essentially being double defined

@AustinBenoit AustinBenoit Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have verified that the link.xml double inclusion does not impact the building or cause any errors.

Comment thread editor/app/src/FirebaseLinkXmlProcessor.cs Outdated
Comment thread editor/app/src/FirebaseLinkXmlProcessor.cs Outdated
…nfo logs, elevate missing assembly log to warning
@AustinBenoit AustinBenoit requested a review from a-maurice July 15, 2026 19:48
@AustinBenoit AustinBenoit merged commit 4572f98 into main Jul 15, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests: succeeded This PR's integration tests succeeded. tests-requested: quick Trigger a quick set of integration tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants