Process.Start within application bundle on Mac (using MonoMac) - macos

I am using MonoMac do develop a very simple application for Mac. I have a solution consisting of two projects: the main project, and the auto updater. The main project references the auto updater, so that the auto updater becomes a part of the application bundle of the main application.
When running the main application, I want to launch the auto updater if there is a new update. On windows, this is a simple Process.Start("C:\path\to\updater.exe"); On Mac, however, this seems to be problematic. When doing it the above mentioned way (both when using absolute and relative paths to the updater.exe), nothing happens, and debugging simply says that the process has been ended already when I try to get any information.
I have attempted to launch the updater using AppleScript:
do shell script "mono /path/to/bundle.app/Contents/MonoBundle/updater.exe"
But this produces the error "No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting". This same error appears when I try to start the main executable the same way, and I know that the Info.plist is configured correctly for this (since I am indeed able to start the app), so there must be something else that is wrong.
Am I doing something obviously wrong? I just want to start the updater from the main executable, how I do it doesn't matter.

Related

Fileprovider does not get loaded when application is run from /Applications folder

I have developed a functional Application that uses the new NSFileProviderReplicatedExtension.
Everything worked as expected until I started deployment and realized, that my application cannot add domain successfully while being run from /Applications folder.
Calling:
[NSFileProviderManager addDomain:fileProviderDomain completionHandler:^(NSError * _Nullable error){}];
This call results in error:
Error Domain=NSFileProviderErrorDomain Code=-2001 "The application cannot be used right now." UserInfo={NSLocalizedDescription=The application cannot be used right now.}
Running the application from XCode build dir or ˜/Desktop fileprovider extension works as expected.
Upon closer inspection in console around a moment of calling "addDomain", I can see a line that does not come up when running the application from a different location.
kernel Sandbox: fileproviderd(448) deny(1) file-read-data /Applications/TestFileProvider.app
I have tried changing about everything in codesign and sandbox in build settings but no change.
I have also tried making app in Obj-C and swift too - makes no difference.
Any suggestions?
For reference here is my question on apple developer forums:
https://developer.apple.com/forums/thread/696254

Cannot run exported application

I've developed a simple MacOS application (i.e. a product consisting of main application and launch helper application) with Xcode 9.4. Application runs fine in Xcode. I've archived and exported the app (either "Export without re-signing" or "Development" using "Automatic signing"). The export process runs without errors.
However, it is not possible to the application. Upon starting outside of Xcode, nothing happens; no error message etc.
How can this be further diagnosed?
Finally found it thanks to #clemens. Embedded libraries have their place inside the generated package in /Contents/Frameworks. Since I had previously embedded a login item I had set a /Contents/Library/LoginItems target path that was used below Frameworks which is clearly not the expected place. Removing the library, cleaning the path and re-adding fixed it for me.

Windows Universal app crashes after Associating identity with Store

I'm creating a cordova app for Windows.
Now when I build this normally (with my own identity of which I have no clue where he gets it from) everything works fine and my app launches with success.
Although when I then associate my app with the Store, and have my actual app name + package name etc filled in for me, I get a blank screen when trying to run my app.
The head and body tags stay empty and no error is thrown in my JavaScript console.
Any idea of why this happens? The problem definitely is that I associate my app with the Store and then something happens which makes my app crash or fail to start.
But why does it do this? And how can I resolve it?
(currently building with VS2017)
edit
Alright, so I figured out that because the package name changed, I had to edit that as well in the manifest. Now My main root component is loaded, but it isn't setting the app root to any page, just a blank screen. (with a menu that can open on swipe).
Alright, so my Microsoft assigned package name was different than my own. This caused the app to look for my own package name instead of the Microsoft one I associated with.
The solution was quite simple, just set your widget-id in your config.xml to the Microsoft assigned package name and rebuild your solution.
(I was using Ionic framework so re-execute ionic build windows --release --prod --arch="arm")

Unable to find APP_BUNDLE_PATH. Cannot find a built app that is linked with calabash.framework

I am running calabash-cucumber in xcode 5.0.1 on OSX 10.9.1, but getting this error while executing the test script. I have installed calabash framework successfully, but don't know why this error occurs.
Error... Unable to find APP_BUNDLE_PATH.
Cannot find a built app that is linked with calabash.framework
Please build your app from Xcode
You should build your calabash target.
Alternatively, specify APP_BUNDLE_PATH in features/support/01_launch.rb
This should point to the location of your built app linked with calabash.
(RuntimeError)
/Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.9.168/lib/calabash-cucumber/launch/simulator_helper.rb:178:in `app_bundle_or_raise'
/Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.9.168/lib/calabash-cucumber/launcher.rb:307:in `relaunch'
/Users/mymac/Desktop/myproject/myproj/features/support/01_launch.rb:29:in `Before'
Does your simulator or device contain the YourApp-cal target installed? Check weather you run the YourApp-cal target once from the xcode to install the app with calabash server on simulator or device.
Then Check you have followed setup Process
You need to have xcode tools installed too.
Check these things too.
Build the yourApp-cal target and run using xcode once.
While App is running open a Terminal(console) and type calabash-ios console. If your ruby environment is correct it will open you a ruby console.
In that console type
server_version['version']
and
Calabash::Cucumber::FRAMEWORK_VERSION
you should get something like "0.9.164"
calabash.framework is installed correctly in your app.
If so You should go to the file /YourProject/features/support/01_launch.rb open it check weather app bundle path is specified or not (if it is commented out calabash automatically detect the default app bundle path) if you are building your app to somewhere else than the default place you need to specify the appbundle path here in this file.
Tell us more details after check this list so we can help you more..
I hit the same issue, the way I got around to it is, on Xcode's top-right corner there is "Identity and Type" window. There you will find the full path of anything that you select on left (Project Explorer window).
Now usually on the ProjectExplorer window you should have "Classes", "Common", "Frameworks", "Other Sources", "Product", "Resources", "Scripts" etc. (It might be slightly different project by project). Inside "Product" is where your .app lives.
Select your app and you'll see the whole path on "Identity and Type" window.
Copy and paste it to "support/launch.rb" where it says APP_BUNDLE_PATH.
Should work now.
Edit 29/07/14: Do you see
HTTPServer: Started HTTP server on port 37265 on 'All output' window of Xcode (my version of Xcode is 5.1) when you build ?
There is a better way to set up calabash so you won't have this problem.
It involves creating a configuration, rather than a -calabash target. Basically you
1. create a configuration
2. add calabash framework to that configuration in build settings
3. add framework search path to find that framework
4. create a scheme to run calabash
The longer version can be found
http://fangmobile.com/2014/05/08/do-you-love-calabash-ios-but-hate-that-cal-second-target/
Deleting the contents of /Library/Developer/Xcode/DerivedData and compiling again solved this problem for me.
My error message was Unable to auto detect APP_BUNDLE_PATH.

Mac OS X: How to launch an application (.app) from a "Command Line Tool" type of app?

In Xcode 4.6, I created a new application based on the "Command Line Tool" project template.
How can I programmatically start another application (.app application bundle) from that "Command Line Tool" app?
There are numerous ways to accomplish this, using Launch Services and or NSWorkspace.
One of the more flexible ways to identity a bundled application is via its bundle identifier (CFBundleIdentifier), which is a string like com.apple.TextEdit. This allows you to identify an application without having to hard-code an assumed path where the application will be found, or by hard-coding the name of the application bundle, both of which a user could easily change. You can use NSWorkspace's launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier: to launch the app. If you don't already know it, you can obtain the bundle identifier of an application bundle by checking its AppName.app/Contents/Info.plist file. Then use the following code:
if (![[NSWorkspace sharedWorkspace]
launchAppWithBundleIdentifier:#"com.apple.TextEdit"
options:NSWorkspaceLaunchDefault
additionalEventParamDescriptor:NULL
launchIdentifier:NULL]) {
NSLog(#"launching app failed!);
}
Important: NSWorkspace is part of the AppKit.framework framework, which is not initially included in the "Command Line Tool" project template. To add it to your project, select the target in the list of targets like shown in the image below, and click the + button to add additional frameworks.
Add both AppKit.framework and Cocoa.framework.
That will result in all 3 being listed in the Link Binary With Libraries step. At that point, you can remove both the Foundation.framework and AppKit.framework from the linking stage, and leave just the Cocoa.framework, like below:
Have you tried "open"? At least in terminal "open" runs files and/or apps.

Resources