Launch Service register application bundle - macos

I have some internal application bundles inside my main application bundle (in Resources). After installing (with Installer), my application is placed in /Applications, but I can't find my "internal" application by their bundle ids.
If I manually go to the /Applications, select my application and navigate to its content in Finder, my "internal" application became visible.
I know that lsregister is responsible to register application bundles, I have this script in my postflight in pkg:
SREGISTER="/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister"
$LSREGISTER "/Applications/MY.app/Contents/Resources/MyMini.app"
But I need administration privileges in my installer, that's why this command is executed by root and does no effect to current user.
Is there any solution for this problem?
Thanks!

You could register your helper apps the first time your main app runs, rather than during installation. You'll need to find them by name and location rather than bundle ID. And instead of using the lsregister tool, you can use the LSRegisterURL function. Remember that an NSURL* can be cast to a CFURLRef by toll-free bridging.

It seems that there is no solution for this. Because I need to run the lsreginster for every user of the system, and newly created users after the installation will not see this helpers app.
The only way is put this application outside the main bundle (in subdirectory of the /Applications for example)

Related

install4j how to create custom installer for macOS single bundle archive

To create installer for macOS (i4j 9.0.2) I used option "Installer-macOS single bundle". But it is deprecated now. As advised I use "Archive-macOS single bundle archive" instead. I want to have same installation dialogs as before. So, I selected "Use setup application" and had to create custom installer application in section "Installer". I created new application same as default "Installer" - manually added there all screens and actions with the same values as in "Installer".
Is this correct?
Anyway installation dialogs on Mac run without icons and images. Also installation wizard default location is not "Applications". What is wrong?
I created new application same as default "Installer" - manually added there all
screens and actions with the same values as in "Installer". Is this correct?
You can put all the screens that you want to use in the macOS setup application into a screen group and then add a link to that screen group in the setup application. In that way you do not have to duplicate them.
Anyway installation dialogs on Mac run without icons and images
I do not see that behavior here. Please contact support#ej-technologies.com with a download link to a media file that exhibits this behavior together with the .install4j project file.
Also installation wizard default location is not "Applications".
The media file type is an archive, it does not have an installation directory, but the user drags the application bundle to the desired location. This is the default installation procedure on macOS. You can style the DMG so that it shows a symbolic link to /Applications as a target in the window. This makes it easier for the user. For more information on that topic, see
https://www.ej-technologies.com/resources/install4j/help/doc/concepts/dmgStyling.html

Not authorised to send Apple Events to Finder from helper bundle

I'm having issues with executing AppleScript from the application helper bundle, which is contained in my main application bundle.
I have a simple helper application bundle which only loads my script located in helpers' bundle Resources using NSAppleScript API and executes it. Script is really simple, it basically just deletes some other application bundle. I've tested the script as standalone and everything works fine. When I run the helper bundle everything falls apart. I'm getting -1743 error (Not authorised to send Apple Events to Finder). My helper bundle is not sandboxed, has enabled apple events in the entitlements file and I've added NSAppleEventsUsageDescription key to the plist. If I run this from Xcode it works, same if I execute the binary contained in the bundle from command line.
Any ideas what might be causing the issue?
I've managed to solve the problem by adding NSAppleEventsUsageDescription key to all Info.plist files up the bundle hierarchy.

Resetting mac application in xcode

How can I reset a cocoa application in Xcode? When I run my application from Xcode all user default are saved. I would like to reset (delete) my application to create a new one with new settings and run as it would be run first time.
I found one way - I change a name of my app to a different one and it is started as new. But how can I do this with an old name?
You can use the defaults command line tool to remove all the settings, you just need the bundle id of your app (which you can find in your Info.plist file), e.g. if your bundle id is "com.foo.barApp" then you can run this from a terminal shell:
defaults delete com.foo.barApp
Is your app limited to the App Store? If so, I don't think there's a way to delete your entire application, specifically because of the sandbox restrictions. We'd need more information on how you are planning to distribute it to help.
If you just want to delete your app settings, then clear whatever database you store your app data in - [NSUserDefaults +resetStandardUserDefaults], SQLite, App Library directory, whatever. That is dependent on how/where you are storing user data, there's no one size fits all solution.

Cocoa: how to Write file inside package contents of app

When we try to delete/uninstall Cocoa .app file ,we directly move the .app file to trash.
This does not ensure the deletion of app user data folder in application support.
The user data lies there hanging. So i wanted to save the user data/ files inside application itself (app->showPacakge contents->somewhere).
If it is not possible! Any ways of clearing app user data folder in application support when user moves app to trash ?
Not a great idea.
The package content is signed. Any modification will be detected by the OS and will prevent launching of the app.
Not to mention the fact that you might not have access to the Applications folder, where most users will keep their app.
if you are using packages for installing your application, then you can have pre-install script, which deletes user data in the application support folder.

PackageMaker installs nothing

i have a problem, which is exactly as here http://compgroups.net/comp.sys.mac.apps/PackageMaker-not-installing-my-app (no solution is offered)
simply said, with PackageMaker i create an installer, which should just copy the .app inside /Applications
all goes well, the installer has the apropriate size of 150MB, the install starts, iam promped for the install location and admin password, i click install, progress shows up and a window that installation was successfull, but when i look at the Applications, or the custom folder specified, its nothing there
i tryed the PackageManager from Xcode 3 and also 4, but the result is the same, i also tryed to set the file permission for everybody, so they are world writable, but no success
Are you testing the installer on the same machine where you are building the installer? If you've set the "Allow Relocation" box a install will simply overwrite your already existing app you used for packaging instead of installing to /Applications.
Don't create the package just to move the app inside /Applications.
Just zip your app bundle so that it becomes YourApp.app.zip, which is a perfectly acceptable way to distribute your app. Then the user can place the app bundle (after unpacking the zip) wherever the user wants.
Do you have "Include root in package" enabled for the package's contents? See this answer for an explanation of what it does and why you probably need it.

Resources