-
Notifications
You must be signed in to change notification settings - Fork 4
Handle Info.plist lookup in versioned frameworks #261
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
base: main
Are you sure you want to change the base?
Conversation
|
||
const contents = await fs.promises.readFile(infoPlistPath, "utf-8"); | ||
return { infoPlistPath, contents }; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing Info.plist
Causes Unhelpful Error
The readInfoPlist
function tries to read the versioned Info.plist
path without confirming it exists. If neither the unversioned nor versioned Info.plist
is found, this leads to an unhelpful "file not found" error, which can complicate debugging framework structures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intentionally consistent with the original behaviour. Happy to try-catch and rethrow with a cause
if preferred. @kraenhansen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A try-catch with a rethrow moving the error to cause
could definitely make a failure easier to debug 👍
In the current code, it would however have to re-introduce the checking on error code to determine if it was indeed a missing file which caused the failure.
Another alternative (which I prefer) could be another helper to determineInfoPlistPath
with two fs.existSync
checks internally and finally throwing a meaningful error from that if none of the candidates paths exists. If we did that, reading the contents could be surrounded with a try-catch expecting a specific filepath to be readable.
About
This PR fixes the following error I encountered when autolinking a framework built for macOS (which I brought up on Discord):
The error indicates that it was unable to find
Info.plist
at the root of the framework. Indeed, it should have been looking elsewhere.Details
iOS frameworks conventionally have this "unversioned" structure, where the
Info.plist
is placed at the root of the framework:macOS frameworks conventionally have a "versioned" structure, where the
Info.plist
is instead nested atVersions/Current/Info.plist
:This PR first checks for an
Info.plist
at the root, then falls back to checking at the nested path.