This project shows how to compile a command line tool for iOS using Xcode. Xcode offers a template called "Command Line Tool" for macOS, but that template is not available for iOS. Nonetheless, Xcode can be persuaded to build standalone Mach-O executables for iOS as well.
This technique has been tested with Xcode 14.1 and iOS 12.0 (just copy the built binary into my jailbroken device and run it).
The ios-command-line-tool template is released into the public domain.