Sandbox is not allowed to open documents in Terminal - macos

Recently I developed an application in Xcode using Swift that starts up the Terminal like this and:
open -a /Application/Utilities/Terminal.app /project/run_stack.sh
After exporting the Application and trying to run it I get this message if my Terminal is running already or I have previously started the same command from the same app (the command is executed through a menu item).
ru_stack.sh can’t be opened because Sandbox is not allowed to open documents in Terminal.
Anyone know why this happens ? If I run it on my Mac it works fine and each time a new terminal starts on the call but when I tried the application on my friend's Mac we get that error in the described cases.

I was having the same problem. I ended up setting iTerm2 as the "Open With" application for .sh files and that fixed my issue. https://iterm2.com/

Related

App only fails when running from finder - How to find error?

I've got a MacOS app, written in Python, using Tkinter, and built into a MyAppName.app bundle with pyinstaller.
When I run open -a MyAppName in terminal, everything works, great.
When I run /path/to/app/dist/MyAppName.app/Contents/MacOS/main, it works and I see terminal output. Great!
However, when I double-click on MyAppName.app, it bounces around in the icon tray a bit then disappears. If I change the app to just open a message box, it works, so I know it's something about the app itself that's wrong.
How can I debug this? Is there some way I can see the logs from the app after opening it in finder, so I can find out what is crashing?

Calling open in Terminal in MacOS brings another program to the foreground

I have two application bundles (called ProgramA and ProgramB) that I have written for MacOS. If I use open in Terminal to launch one of them it will launch just fine. But if I try to use open to launch the other one while the first one is open, it will instead bring to the foreground the already launched app. For instance, if ProgramA is already open and I use open -a ProgramB, Program A will instead come to the foreground.
I know I can use open -n -a ProgramB to ensure a new app is launched, but I would like to keep the behavior of bringing the app to the foreground if it already running. If I double-click the icon in Finder the apps will open as expected. The apps are being launched by another app so just using Finder isn't an option.
I thought maybe the issue was a duplicate key in the Info.plist that is used by the system, but that doesn't seem to be an issue. The values for the following keys are unique between the two apps:
CFBundleIdentifier
CFBundleExecutable
CFBundleName
Is there a way I can get open to launch the correct app if other app is already running?

How can I launch Chrome from Terminal on Mac OSX?

I am an aspiring software engineer and in doing some studying and development work I have found that it would be very convenient to have a Terminal command which would launch chrome in a new window with the first argument being passed as the URL to launch (or a local HTML file). Is there a way to do this on Mac OSX (I'm on Sierra 10.12.4)? I tried searching but the only guide I found was 5 years old and doesn't seem to work.
Bonus:
It would be even better if we could force the new window to open with the Inspection window already opened showing source code and page structure!

How to tell finder that my application is installed?

I am working on a cocoa application. I see a strange behaviour on Mac OS 10.6.8..!
My Cocoa application has an Automator action inside it. I want it to be listed in Automator as soon as I install it.
The conditions are as follows:
1. After installation, user should not go to the installed path.
2. User should not launch the application.
I mean, I am seeing this bug only for above mentioned situations. If I go to the installed folder, or launch the application, the automator app gets listed.
I didn't see this defect on Mac OS 10.7.5 or Mac OS 10.8.2..
Also I tried touch command via terminal just in case thinking that if any kind of Access updating is required and all. But that wasn't the case.
Any suggestions? Can I run any kind or Shell/Applescript while installing [After installation of the application] so that I can list the automator action in automator?
Any advice or help would be great!!
You can have a .txt file with the below script and then you have to add postflight script when taking .pkg file in Package Maker.
open "/Applications/yourAppName.app"
Try this Terminal command.
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister .../Whatever.app
You shouldn't hard-code the path, though, as users sometimes stick apps in weird locations (citation: I do it :).

Replaced Finder kiosk

I am trying to make a kiosk, I actually wanted to lauch my app before the Finder got launched, I wrote the following command:
defaults write com.apple.loginwindow Finder ~/Desktop/myapp.app
and it worked, but now I have a huge issue, my Finder wont get launched at all, instead everytime my application is launched when I press the Finder, Before I was getting erroR -10810 but I fixed that. I tried reversing the process but it isnt working. My mac is useless and I cant get to my files.
Target is to reverse the process and make my finder works again as normal

Resources