unable to find utility "pngcrush", not a developer tool or in PATH

I have just moved a large existing XCode workspace to XCode 10.2.1. In one of the MacOS projects, the target includes a "Copy Bundle Resources" build step to copy various files, including a number of PNG files. This has worked for years without problems on XCode 7 and earlier, but now I get a slew of the following pair or error messages:


"unable to find utility "pngcrush", not a developer tool or in PATH"

and

"Command CopyPNGFile emitted errors but did not return a nonzero exit code to indicate failure"


"pngcrush" does exist in "/Applications/Xcode.app/Contents/Developer/usr/bin/pngcrush". The target does appear to build successfully despite the fact that errors arr reported. What can I do to fix this problem?


Thank You



Larry

Replies

On my system w/Xcode 10.2.1, it's in:


/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/


Updating the path should fix it.

I had a post-action script in a Xcode 14.1 scheme that showed this pngcrush error after adding PNG assets to one of our frameworks. The xcodebuild commands from the script worked normal when called from a terminal, but failed with above error when called from the post-action script of the scheme.

Changing the XCODE_DEVELOPER_DIR_PATH, nor the general PATH however did not resolve the issue.

There a numerous settings for PATHs in Xcode, so I'll save you some days and share which setting solved it for me in Xcode 14.1. Add this line to or before your post-/pre-action script: unset TOOLCHAINS

I had found that for some reason Xcode 14.1 had set TOOLCHAINS to empty, which causes this path failure issue when CopyPNG tries to compress a PNG with pngcrush.

P.S: Doing so I also found another such misconfigured XCODE_DEVELOPER_DIR_PATH causing false warnings about the developer path being relative instead of absolute. If this setting being empty generates warnings , you can add

unset XCODE_DEVELOPER_DIR_PATH

before your script.