This issue usually happens for the Xcode projects involving Cocoapods with more dependencies during [CP] Check Pods Manifest.lock script execution.

PhaseScriptExecution [CP]\ Check\ Pods\ Manifest.lock /Users/xxx/Library/Developer/Xcode/DerivedData/xxx/Build/Intermediates.noindex/xxx.build/Debug\ (Staging)-iphonesimulator/OV.build/Script-05BB3CCD2FBD4842F78B0F4F.sh (in target 'xxx' from project 'xxx')
cd /Users/xxx/Documents/Projects/<project-name>
/bin/sh -c /Users/xxx/Library/Developer/Xcode/DerivedData/xxx/Build/Intermediates.noindex/xxx.build/Debug\\\ \\\(Staging\\\)-iphonesimulator/xxx.build/Script-05BB3CCD2FBD4842F78B0F4F.sh

error: unable to spawn process (Argument list too long) (in target 'xxx' from project 'xxx')

The direct solution to fix this problem is setiing the build system to Legacy Build Sysrtem via ‘File -> Workspace Settings’

Legacy Build System could work till Xcode 11.x versions. However, with Xcode 12.x the above approach won't work as the Legacy Build system will be deprecated in future versions of Xcode.

Bummer !!! What’s the solution? How can we fix it?

The solution is to inspect the below Build Setting properties.

Make sure these Custom compiler Flags contain only compiler related items

However, with pod install these fields will be appended with $(inherited) values of the pods listed in the podfile creating huge number of enytries which is causing “Arguments list too long (Unable to spwan the process /bin/sh)

Hope this helps, Feel free to comment for any more clarifications. Happy Coding !!