Change accessibility setting on Mac for command line program
you have to export your app via Product > Archive > Export... > Export
  as a Mac Application, then move the app to wherever you want it (i.e.,
  your Applications folder). Then, you'll be able to find the app in
  Security &amp; Privacy to give it accessibility permissions


Credit to: vincefior
In a comment on this stackoverflow question: