Unable to build Xcode projects using SwiftPM in MacPorts sandbox

Zero King l2dy at macports.org
Sun Mar 24 08:26:02 UTC 2024

Hi Ryan,

On Sat, Mar 23, 2024 at 11:19:03PM -0500, Ryan Schmidt wrote:
>On Mar 23, 2024, at 23:00, Zero King wrote:
>> I think it could be base's sandbox that prevented writes to the home directory, where SwiftPM stores its cache.
>If disabling sandboxing in macports.conf makes it work, then your suspicion is probably correct.

Yes, it was the sandbox. I set `sandbox_enable no` and this error was 

>MacPorts sets the HOME environment variable to point to a directory within workpath. It looks like it's ignoring that and trying to write to a subdirectory of the macports user's real home directory, /opt/local/var/macports/home. That would be a bug to file with Apple. It has been a long-standing problem that has affected MacPorts in other ways before.

SwiftPM seems to prefer the "idiomatic" cache directory, which is 
constructed from FileManager's .cachesDirectory that points to 


I'm not sure whether to file this as a bug. At its root is the 
FileManager, but I doubt Apple would change its API.

SwiftPM has a cache-path option that could be used to override the cache 
path, but I'm not sure how to use it in an Xcode project yet.


More information about the macports-dev mailing list