Skip to content

Commit 4f88105

Browse files
Ivan HernandezIvan Hernandez
authored andcommitted
Prioritize using the Xcode path set in the DEVELOPER_DIR environment variable when available.
1 parent 4405d29 commit 4f88105

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/ios-deploy/ios-deploy.m

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -314,19 +314,25 @@ CFStringRef copy_find_path(CFStringRef rootPath, CFStringRef namePattern) {
314314
CFStringRef copy_xcode_dev_path(void) {
315315
static char xcode_dev_path[256] = { '\0' };
316316
if (strlen(xcode_dev_path) == 0) {
317-
FILE *fpipe = NULL;
318-
char *command = "xcode-select -print-path";
317+
const char* env_dev_path = getenv("DEVELOPER_DIR");
318+
319+
if (env_dev_path) {
320+
strcpy(xcode_dev_path, env_dev_path);
321+
} else {
322+
FILE *fpipe = NULL;
323+
char *command = "xcode-select -print-path";
319324

320-
if (!(fpipe = (FILE *)popen(command, "r")))
321-
on_sys_error(@"Error encountered while opening pipe");
325+
if (!(fpipe = (FILE *)popen(command, "r")))
326+
on_sys_error(@"Error encountered while opening pipe");
322327

323-
char buffer[256] = { '\0' };
328+
char buffer[256] = { '\0' };
324329

325-
fgets(buffer, sizeof(buffer), fpipe);
326-
pclose(fpipe);
330+
fgets(buffer, sizeof(buffer), fpipe);
331+
pclose(fpipe);
327332

328-
strtok(buffer, "\n");
329-
strcpy(xcode_dev_path, buffer);
333+
strtok(buffer, "\n");
334+
strcpy(xcode_dev_path, buffer);
335+
}
330336
}
331337
return CFStringCreateWithCString(NULL, xcode_dev_path, kCFStringEncodingUTF8);
332338
}

0 commit comments

Comments
 (0)