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

build: add private frameworks directory to Darwin's native paths #23166

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/std/zig/system/NativePaths.zig
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub fn detect(arena: Allocator, native_target: std.Target) !NativePaths {
if (std.zig.system.darwin.isSdkInstalled(arena)) sdk: {
const sdk = std.zig.system.darwin.getSdk(arena, native_target) orelse break :sdk;
try self.addLibDir(try std.fs.path.join(arena, &.{ sdk, "usr/lib" }));
try self.addFrameworkDir(try std.fs.path.join(arena, &.{ sdk, "System/Library/PrivateFrameworks" }));
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's a good idea to include PrivateFrameworks by default.

Copy link
Contributor Author

@tensorush tensorush Mar 10, 2025

Choose a reason for hiding this comment

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

Could you explain why? I still think having the build system look first in frameworks and then in private frameworks under the native SDK path is a good default.

Copy link
Contributor

Choose a reason for hiding this comment

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

The private framework is not meant to be used by developers, if developers want to use it anyway, they need to set the required paths all by themselves.

For example clang don't include the private framework path by default.

Copy link
Contributor Author

@tensorush tensorush Mar 10, 2025

Choose a reason for hiding this comment

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

Private frameworks can be used by developers. They are called private because App Store apps aren't allowed to use them, only Apple apps are. See: https://theapplewiki.com/wiki/Filesystem:/System/Library/Frameworks

Public frameworks are allowed to be used in App Store apps. Private frameworks are intended to be used only by Apple's apps, and are more unstable against firmware changes, but many of the interesting features are in the private frameworks.

What shouldn't be done is searching for frameworks under root, instead of the Xcode SDKs path, which is the source of our confusion in #17017.

Copy link
Contributor Author

@tensorush tensorush Mar 10, 2025

Choose a reason for hiding this comment

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

But I see how this might be a workaround for the fact that zig is unable to find frameworks under root, while clang seems to be able to.

try self.addFrameworkDir(try std.fs.path.join(arena, &.{ sdk, "System/Library/Frameworks" }));
try self.addIncludeDir(try std.fs.path.join(arena, &.{ sdk, "usr/include" }));
}
Expand Down
Loading