mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-13 08:11:38 +08:00
add null check -- the bundleIdentifier is optional (#2709)
* add null check -- the bundleIdentifier is optional * use variable
This commit is contained in:
@@ -119,8 +119,10 @@ std::pair<MTL::Library*, NS::Error*> load_swiftpm_library(
|
|||||||
// if SWIFTPM_BUNDLE is a framework identifier, try loading from that
|
// if SWIFTPM_BUNDLE is a framework identifier, try loading from that
|
||||||
auto frameworks = NS::Bundle::allFrameworks();
|
auto frameworks = NS::Bundle::allFrameworks();
|
||||||
for (int i = 0, c = (int)frameworks->count(); i < c; i++) {
|
for (int i = 0, c = (int)frameworks->count(); i < c; i++) {
|
||||||
auto bundle = reinterpret_cast<NS::Bundle*>(frameworks->object(i));
|
const auto bundle = reinterpret_cast<NS::Bundle*>(frameworks->object(i));
|
||||||
if (!strcmp(bundle->bundleIdentifier()->utf8String(), SWIFTPM_BUNDLE)) {
|
const auto identifier = bundle->bundleIdentifier();
|
||||||
|
if (identifier != nullptr &&
|
||||||
|
!strcmp(identifier->utf8String(), SWIFTPM_BUNDLE)) {
|
||||||
library = try_load_framework(device, bundle->resourceURL(), lib_name);
|
library = try_load_framework(device, bundle->resourceURL(), lib_name);
|
||||||
if (library != nullptr) {
|
if (library != nullptr) {
|
||||||
return {library, nullptr};
|
return {library, nullptr};
|
||||||
|
|||||||
Reference in New Issue
Block a user