What is a reasonable way for a script that runs otool to handle the need to agree to a new license?

I run otool from a script (actually from a program) and find it annoying that otool fails if I need to agree to a new version of the Xcode and SDKs license. Is there a way to test ahead of time whether this will happen, or detect when this problem occurs, so that I can display a dialog to tell me what I need to do?

This happened after upgrading from macOS Tahoe beta 1 to beta 3.

Answered by ssmith_c in 849698022

sudo xcodebuild -license

run it in an empty directory so it doesn't actually build anything. More info in the man page for xcodebuild.

Accepted Answer

sudo xcodebuild -license

run it in an empty directory so it doesn't actually build anything. More info in the man page for xcodebuild.

sudo xcodebuild -license run it in an empty directory so it doesn't actually build anything.

Except I'm running this from a program and I don't want to ask the user to do anything (including entering a password). I just want to find out the license status. If the status is OK, the program should keep running without user interaction.

Actually, it appears that sudo is not required to determine the status.

xcodebuild -license >junk 2>error

will write an error message to stderr if a new agreement is needed.

I take it back. That error message is written even after I have agreed, whether or not I run using sudo.

What is a reasonable way for a script that runs otool to handle the need to agree to a new license?
 
 
Q