I feel your pain, these types of things always tend to be hairy, regardless of using RubyMotion or objc/Xcode. I haven’t had to do this myself yet, but I’ll try to give a high level overview of what –as I understand it– you need to do.
There are two apps of importance:
1. The ‘helper’ application. This application is nothing more than a ‘boot’ application for the actual app, a trampoline if you will. It does this by simply calling -[NSWorkspace launchApplication:] once the application has started and passing in the main app's bundle path. This application has to be at a specific location inside the main app, more on that later. This app might probably exit after launching the main app, but the blog post doesn’t mention this explicitly, so you’ll need to verify this.
2. The actual dockless status bar app. Besides the normal work you want this app to do, it is also responsible for registering the ‘boot helper’ application with Launch Services. You do this by using the code that the blog post mentions that’s inside the setStartAtLogin:enabled: method. In that method they register the location of the ‘boot helper’ application (the path inside the main app) and then set it to be a ‘login item’. On the next boot of the system the helper application will be started and launch the main dockless status bar app.
The two build phase steps are:
1. As RubyMotion only builds one app per project you’ll have to create two projects, one for each app. Simply build the ‘boot helper’ app first and use the build product in the main project.
2. The ‘boot helper’ application has to be placed in another path than where normal resources would be, this is the path alluded to before. To do this I suggest that you place it in, for instance, a HelperApp subdir and use the power of Ruby to hook copying this app into the build process. Here’s an example that you can copy into your Rakefile:
class Motion::Project::App
class << self
#
# The original `build' method can be found here:
#
https://github.com/HipByte/RubyMotion/blob/master/lib/motion/project/app.rb#L75-L77
#
alias_method :build_before_copy_helper, :build
def build(platform, options = {})
# First let the normal `build' method perform its work.
build_before_copy_helper(platform, options)
# Now the app is built, but not codesigned yet.
destination = File.join(config.app_bundle(platform), 'Library/LoginItems')
info 'Create', destination
FileUtils.mkdir_p destination
info 'Copy', 'path/to/helper'
FileUtils.cp_r 'path/to/helper', destination
end
end
end
You can further inspect what the RubyMotion build process does by either checking out the code here:
https://github.com/HipByte/RubyMotion/tree/master/lib/motion, or simply on your local machine in /Library/RubyMotion/lib.
HTH
> --
> You received this message because you are subscribed to the Google Groups "RubyMotion - Ruby for iOS" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
rubymotion+...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/rubymotion/3d2dc51c-72ef-40a8-b809-24b1a20dc750%40googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.