Does MacPorts need ALL of Xcode?

Ryan Schmidt ryandesign at
Sun Oct 3 05:27:30 UTC 2021

On Oct 3, 2021, at 00:08, Ian Wadham wrote:

> OK, thanks Ryan, but how about ?
> It explicitly says to install Xcode first, as a dependency of MacPorts, and then do xcode-select —install, which is what I have been doing for 10 years or more as a MacPorts user. And I suppose almost all other MacPorts users have too.
> But in that time Xcode has grown from a gigabyte or two to 20 Gb on my current MacOS, Catalina 10.15.7. That is a significant slice of the SSD storage in a shop-standard MacBook Pro. So if a user does not need Xcode as a prerequisite of MacPorts, he/she should not have to carry the time and space overheads of downloading, installing and storing it.
> My question then is please can be re-written to help users who do not need Xcode for any other reason?

Yes, it can. Anyone can contribute updates to the documentation by submitting a pull request. Much of the Guide has not been updated in over a decade and is in dire need of rewrites or replacement.

>>> Couldn’t those ports list Xcode as a build dependency?
>> They do, by using this keyword:
>> use_xcode yes
> Chris Jones raised the point on 26/27 September on this thread that some ports require Xcode and gave this as the reason for MacPorts requiring Xcode.
> But how many ports are involved here? What percentage of users are likely to need them? And what is the worst that can happen to a user if he/she happens to run into one and does not have Xcode installed?

MacPorts will print a message saying Xcode is required to install that port.

> I tried port search use_xcode to try and shed some light on these questions, but it gave "no match … found”.

"port search" does not do a search of the entire literal contents of portfiles, but you can use grep to do that.

Ports that include the xcode portgroup also most probably require Xcode. I would have thought that the xcode 1.0 portgroup would declare "use_xcode yes" somewhere in it, but it doesn't seem to. Maybe that is an oversight.

According to this:

port file all | sort -u | xargs grep -El '^[[:space:]]*(use_xcode[[:space:]]yes|PortGroup[[:space:]]+xcode[[:space:]])' | wc -l

there are around 180 ports that require Xcode. There may be others that require Xcode but that do not so indicate yet.

More information about the macports-users mailing list