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

Prioritize using the Xcode path set in the DEVELOPER_DIR environment … #533

Merged
merged 1 commit into from
Sep 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/ios-deploy/ios-deploy.m
Original file line number Diff line number Diff line change
Expand Up @@ -314,19 +314,26 @@ CFStringRef copy_find_path(CFStringRef rootPath, CFStringRef namePattern) {
CFStringRef copy_xcode_dev_path(void) {
static char xcode_dev_path[256] = { '\0' };
if (strlen(xcode_dev_path) == 0) {
FILE *fpipe = NULL;
char *command = "xcode-select -print-path";
const char* env_dev_path = getenv("DEVELOPER_DIR");

if (env_dev_path && strlen(env_dev_path) > 0) {
strcpy(xcode_dev_path, env_dev_path);
} else {
FILE *fpipe = NULL;
char *command = "xcode-select -print-path";

if (!(fpipe = (FILE *)popen(command, "r")))
on_sys_error(@"Error encountered while opening pipe");
if (!(fpipe = (FILE *)popen(command, "r")))
on_sys_error(@"Error encountered while opening pipe");

char buffer[256] = { '\0' };
char buffer[256] = { '\0' };

fgets(buffer, sizeof(buffer), fpipe);
pclose(fpipe);
fgets(buffer, sizeof(buffer), fpipe);
pclose(fpipe);

strtok(buffer, "\n");
strcpy(xcode_dev_path, buffer);
strtok(buffer, "\n");
strcpy(xcode_dev_path, buffer);
}
NSLogVerbose(@"Found Xcode developer dir %s", xcode_dev_path);
}
return CFStringCreateWithCString(NULL, xcode_dev_path, kCFStringEncodingUTF8);
}
Expand Down