3

I want to import the bash PATH environment variable (where it is set in ~/.bash_profile) into one particular Xcode project (I'm using Xcode 11).

This is because I want to use a Makefile compile that Xcode project, and the Makefile uses the bash PATH environment variable. Specifically I use compilers and libraries that I installed using MacPorts, so I want Xcode to look in /opt/local/bin:/opt/local/sbin, like the Makefile does.

In Xcode I've tried adding these in Edit scheme > Environment Variables, and in Build Settings for both the project and its (external-build) target, as described in the answers to this question, but it hasn't appeared to have made a difference.

(The specific problem that I'm trying to fix is described in my question here.)

jms547
  • 201
  • 3
  • 11
  • 2
    I disagree with the close here. The full text of the reason given is: _Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming._ First, this DOES directly involve tools used primarily for programming. Second, as I understand it that refers to people asking things like, "what is the best compiler / editor / operating system?" This is a specific question needing a specific answer about a tool used in programming. It should not be closed. – MadScientist Mar 30 '20 at 15:25
  • Thanks for the support MadScientist! (I've edited the question to make my specific problem clearer, and to correct the link to my original question!) – jms547 Mar 30 '20 at 17:39
  • Are you invoking Xcode from a terminal? Or via the desktiop? If you invoke it from the terminal does it work? If so then you probably just need to fix your shell setup files. See the bash man page and look at the INVOCATION section. Most likely you want to put your PATH setting in `~/.bashrc` not `~/.bash_profile` but even that might not work... it depends on how MacOS handles it's login session setup. I don't use MacOS so I can't help more. – MadScientist Mar 30 '20 at 19:57
  • I was invoking Xcode via the desktop. Building from the command line works successfully (yey!) (```$ xcodebuild -scheme build```) and the code runs as expected. So Xcode could see the bash $PATH when ```xcodebuild``` was invoked from the command line. Now when I re-open the application from the desktop, the build succeeds (yey!) though I can't see the executable. The kicker though is that I can't seem to enter debug mode - my breakpoints don't stop the code. Nor does it seems the indexer has run as none of the methods and symbols are clickable or have hover-info. – jms547 Mar 31 '20 at 12:49
  • Those are quite different problems. You should ask about that specifically. Such a question would not use the `makefile` tag since it's not related. – MadScientist Mar 31 '20 at 18:01
  • yep. TBH I'd rather get the path env variable working so that I can use the IDE, but I'll return to this line of questioning if I can't get any further with that. Or maybe just try Eclipse... – jms547 Mar 31 '20 at 19:27
  • Did you try my suggestions above, of putting the path setting into `~/.bashrc` instead of `~/.bash_profile`? You may have to log out and log back in to see if it worked. If not you should Google around for "macos set PATH for desktop applications" or something like that. – MadScientist Mar 31 '20 at 21:42
  • yes, I just tried putting the path into ```~/.bashrc``` and the same problems persist. Googling what you suggested seems to indicate that the PATH environment variable for bash isn't the same as that for desktop applications. So currently trying to find the definitive answer to how add the bash PATH to whatever other PATHs MacOS might be setting... – jms547 Apr 01 '20 at 21:17

1 Answers1

1

I worked it out how to do the bigger issue that generated this question. See my answer to my original question.

I'm not sure which exact part, or which combination, imported the PATH correctly from bash into Xcode, answering this question.

I had definitely entered the PATH into Build settings and Environment Variables when I originally asked this question. Perhaps the difference was ticking the Pass build settings in environment checkbox in step 5 here, which I am not sure whether I did when I asked this question.

In any case it works now.

jms547
  • 201
  • 3
  • 11