Skip to content

Commit

Permalink
Prefer Xcode to default library
Browse files Browse the repository at this point in the history
Otherwise if you have a Xcode beta but not a macOS beta you will not be
able to extract beta shared cache versions. If you want to prefer the
system install you can do so by passing /usr/lib/dsc_extractor.bundle
manually.
  • Loading branch information
keith committed Dec 11, 2023
1 parent 4d1bf29 commit a2ad3ad
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions dyld-shared-cache-extractor.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <assert.h>
#include <dlfcn.h>
#include <stdarg.h>
#include <stdio.h>
Expand All @@ -15,23 +16,21 @@ static int get_library_path(const char *candidate, char *output) {
return 0;
}

FILE *pipe = popen("xcrun --sdk iphoneos --show-sdk-platform-path", "r");
if (pipe && fgets(output, PATH_MAX, pipe) != NULL) {
output[strlen(output) - 1] = '\0';
strcat(output, "/usr/lib/dsc_extractor.bundle");
assert(pclose(pipe) == 0);
return 0;
}

const char *builtin = "/usr/lib/dsc_extractor.bundle";
if (access(builtin, R_OK) == 0) {
strncpy(output, builtin, PATH_MAX);
return 0;
}

FILE *pipe = popen("xcrun --sdk iphoneos --show-sdk-platform-path", "r");
if (!pipe)
return 1;

if (fgets(output, PATH_MAX, pipe) == NULL)
return 1;

output[strlen(output) - 1] = '\0';
strcat(output, "/usr/lib/dsc_extractor.bundle");

return pclose(pipe);
return 1;
}

__attribute__((noreturn))
Expand Down

0 comments on commit a2ad3ad

Please sign in to comment.