Even disabling SIPs and logging in as the root user, I was unable to copy the file or any file to /usr/bin. That's some serious security. So why is there even an option to disable SIPs at all if I still can't change these areas.
There is more to SIP than just directory permissions. In the past, you could have done this by disabling SIP.
Apple is a curious case of the Schrödinger's company. It is both alive and dead. Everyone is obsessed with having the very latest version of every Apple software update. But at the same time, they expect that nothing has ever changed, or should ever change, in the operating system.
At least, this is the perspective from the internet at large. When developing for Apple platforms, it is better to use the current documentation from Apple instead of searching the internet. The internet is a source of frustration and misinformation.
Also got it to work by setting App sandbox for any of the user folders: Downloads, Pictures, Music, and Movies to "read only" or "read/write". (see photo). and move the utility to one of them. But this is not where I wanted it to be.
This is not a viable solution. Unfortunately, since you've just posted it on the internet, someone in the future is going to try it and then get frustrated when it gets rejected by App Review.
Interestingly. I created a command line utility to test this separate from a sandboxed app, and it worked just fine from /usr/local/bin.
Yes. That's how the sandbox works. But don't get too excited. Turning off the sandbox does enable access to more locations in the file system, but not all locations.
I would prefer to have it in /usr/local/bin, which is where I have several of my own command line utilities. This way, it's in the path and I can use it in a terminal window and from within my APP.
You can always modify your path. But I want to re-iterate that this app might not function properly in the sandbox. Consider the difficulty that you've had when trying to run your app from the sandbox. The developers of the "codeview" app have probably never tried to run it from the sandbox. If you experience any problems, they will be unable or unwilling to help.