add null check -- the bundleIdentifier is optional (#2709)

* add null check -- the bundleIdentifier is optional

* use variable
This commit is contained in:
David Koski
2025-11-03 06:33:21 -08:00
committed by GitHub
parent ed9c6b1117
commit 78678de0cd

View File

@@ -119,8 +119,10 @@ std::pair<MTL::Library*, NS::Error*> 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<NS::Bundle*>(frameworks->object(i));
if (!strcmp(bundle->bundleIdentifier()->utf8String(), SWIFTPM_BUNDLE)) {
const auto bundle = reinterpret_cast<NS::Bundle*>(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};