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 9.3 and iOS 11.1.2.
The ios-command-line-tool template is released into the public domain.