Create installer that runs application on login - xcode

I have spent more time on this task than I did actually creating the application.
I want to create an installer for my app that will:
Install the app into /Applications
Make the application launch on boot (it's just a menu bar status based app)
Number 1 is easy but I can get absolutely nowhere with getting #2 to work. I know I need to setup a postscript install somewhere I don't know how to make the script (I believe I need to put it in loginitems) and how to make it initialize as part of the package. My understandign from research is I need to look into making a postflight script but there is nothing at all in Package Manager for that.
Can someone please point me to something that works in 10.6+?
I've tried the script here in Add app to OSX "Login Items" during a Package Maker installer postflight script but it doesn't really explain where/how to actually add the script.

Launch at login can be a piece of cake or an absolute nightmare depending on wether or not your app is sandboxed. If it isn't sandboxed, then you can use LSSharedFileList to modify the login items preference pane: https://github.com/Mozketo/LaunchAtLoginController
If it is sandboxed then you're going to need to create a helper app: http://blog.timschroeder.net/2012/07/03/the-launch-at-login-sandbox-project/
The above tutorial didn't work for me on yosemite, I had to follow apple's sample code: https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLoginItems.html#//apple_ref/doc/uid/10000172i-SW5-SW1
As for the installer, check this answer here: https://stackoverflow.com/a/11487658/1320911

Related

open a sideloaded UWA app with parameters

I have created a wpf app and have been learning how to deploy it as a side loaded windows store app through an appinstaller package.
I now want to launch the app through a shell command with parameters. I did setup a protocol, but it doesnt seem to open the app. to make things worse I do not have permission to see the contents of the windowsApps folder it should be installed in.
can anybody explain how i can launch this app with an argument? Also can anybody explain how the file structure is setup inside the windowsApps folder?
In the end i setup a protocol in the declarataions of my package manifest for my app to allow it to be opened through a url eg myapname:
here is an explanation of how this works
the full uri that is called is passed in the app parameters so i put custom handling in to allow me to pass waht i want in as a querystring
so for example i could call mayapp:?arg1=myvalue or myapp:localhost:80?myarg=myvalue

How to programmatically uninstall App that install DriverKit system extension

I have an app that installs a DriverKit system extension when it launches.
If I then drag this app to the Bin from /Applications then I am prompted about that the app also manages a system extension and that the system extension also will be removed.
I would like to have an uninstaller that removes the app. I have tried to remove the app in the uninstaller with rm -rf, but then the system extension is not removed.
I have also tried the trash terminal utility (can be installed with brew install trash) to check if something similar could be used from the uninstaller, but without luck.
Is there a way to programmatically remove an app and also the system extension that the app installs.
Good question! I don't have a fully baked answer, but enough suggestions to try that they won't fit in a comment, so here goes anyway:
Try using Cocoa APIs for "trashing" files. This answer gives a good rundown. I don't know how this will cope with the system extension confirmation though.
If you definitely want to pop up the confirmation dialog, using AppleScript to tell the Finder to delete the file is a great approach. I can confirm the solution given in this answer works but it will show the confirmation dialog, which may or may not be what you want.
You can uninstall a system extension (including a dext) using the systemextensionsctl uninstall command. Unfortunately, this will always pop up an authentication dialog, even if you run it with root privileges. But depending on what you're doing, that might be preferable to the above.

Script to Swift

I searched a lot but couldn't find any solution. I wrote a basic script on my mac that will open steam,write my password and keystroke return. It worked fine as a script then I import this code to xcode to make UI,added steam button and exported as "shortcuts.app" so when I press the steam button steam runs but but it doesn't enter my password neither keystroke return. I tried to upload the code to github. I believe there is a simple solution for this that I don't know.
https://gist.github.com/abigado/25a429efd98d439dc78d
By the way I get this when I build the app in xcode but app runs. Don't know if this is the problem.
2015-06-27 20:07:37.404 Shortcuts[877:18363] Failed to connect (theWindow) outlet from (NSApplication) to (NSApplication): missing setter or instance variable
Remove the second script AppDelegate– and probably corresponding end– line.

Launch Service register application bundle

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)

Rename a directory in installer

I am working on a Windows application which needs to be able to update itself. When a button is pressed it starts the installer and then the parent application exits. At some point during the installer, the installer attempts to rename the directory that the parent application was running from and fails with "Access Denied" If you run the installer from the desktop it works.
I am using CreateProcess to start the installer, is there some way of using this or another API to create the installer completely independantly from the parent application so that it doesn't retain some attachment to the directory.
I'm not convinced that launching the installer separately will solve your issue. It sounds more like a permissions problem that you might be able to solve using ACL manipulation. If the app doesn't already have permissions to mess with that folder, you might be able to write a custom action to remedy the problem by adding the necessary permissions to your process.
Another way of doing this is to make sure that the directory deletion is happening within a custom action that you control (as in, you own/maintain the code that performs the deletion, rather than rely on MsiExec to do it for you). Then, set that custom action to run in the System context so that it will have the same permissions as a service. That should provide your installer with sufficient rights to remove the folder.
You should use the normal update system within the windows installer.
your access denied message appears because file/directory is in use.
renaming directories isn't also not a good idea.
what happened if the user clicks "repair" or "uninstall" ?
you can start the msi with shellexec. after that terminate you app immediately.
you should check that in the msi that your app is NOT running anymore.
do the update. if a file is in use the installer automatically wants to reboot to replace the stuff.
CreateProcess should work if you are passing it the right parameters. Don't reference the parent process in any way and set most things to NULL. If that doesn't work, then you can try WinExec().

Resources