From 78678de0cdcf05a18660f77e7f7101195c5d80ea Mon Sep 17 00:00:00 2001 From: David Koski <46639364+davidkoski@users.noreply.github.com> Date: Mon, 3 Nov 2025 06:33:21 -0800 Subject: [PATCH] add null check -- the bundleIdentifier is optional (#2709) * add null check -- the bundleIdentifier is optional * use variable --- mlx/backend/metal/device.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mlx/backend/metal/device.cpp b/mlx/backend/metal/device.cpp index e82d734a2..d1a427299 100644 --- a/mlx/backend/metal/device.cpp +++ b/mlx/backend/metal/device.cpp @@ -119,8 +119,10 @@ std::pair load_swiftpm_library( // if SWIFTPM_BUNDLE is a framework identifier, try loading from that auto frameworks = NS::Bundle::allFrameworks(); for (int i = 0, c = (int)frameworks->count(); i < c; i++) { - auto bundle = reinterpret_cast(frameworks->object(i)); - if (!strcmp(bundle->bundleIdentifier()->utf8String(), SWIFTPM_BUNDLE)) { + const auto bundle = reinterpret_cast(frameworks->object(i)); + const auto identifier = bundle->bundleIdentifier(); + if (identifier != nullptr && + !strcmp(identifier->utf8String(), SWIFTPM_BUNDLE)) { library = try_load_framework(device, bundle->resourceURL(), lib_name); if (library != nullptr) { return {library, nullptr};