app-bundle vs. regular/"BSD utility" executables : what differences are there still?
Jeremy Huddleston Sequoia
jeremyhu at apple.com
Tue Jan 5 11:44:51 PST 2016
> On Jan 5, 2016, at 11:35, René J.V. Bertin <rjvbertin at gmail.com> wrote:
> On Tuesday January 05 2016 10:29:41 Jeremy Huddleston Sequoia wrote:
>> There are really two main difference between the two cases:
>> 1) The app bundles have an inherent main bundle (ie: [NSBundle mainBundle]).
> But CFBundleGetMainBundle() does return something equivalent for non-bundled applications...
It's set to the directory that contains the main executable. I'm not sure if that is a contract or just a behavior quirk. I don't see it documented as such, so I wouldn't rely on that behavior.
>> 2) Apps are (usually) launched by LaunchServices. You can exec them directly, but that is not the preferred way to do it (and may not always work in the future).
>> It's certainly possible for processes to draw GUI elements without being bundled, but it's less trivial.
> That's the impression I had, but I haven't been able to confirm that recently, other than a subtle difference if you invoke the bundle exec via its full path or via a symlink.
> Interaction with the elements can be more tricky; Qt5 applications I exec directly often do not show the menubar immediately until I cycle the foreground application. I suspect this has to do with the fact that Qt5 calls [NSApplication activateIgnoringOtherApps:] quite early (too early) during initialisation.
>> It's possible for a standalone executable to have an Info.plist. It is embedded in the executable in an __info_plist section. This can be done by the CREATE_INFOPLIST_SECTION_IN_BINARY Xcode build setting or by creating an __info_plist section manually at link time if not using Xcode (-Wl,-sectcreate,__TEXT,__info_plist,/path/to/my/Info.plist).
> I usually use CFBundleGetInfoDictionary() and CFDictionarySetValue(),
Yeah, don't do that. ;)
> but embedding the infodict like above is certainly easier once it contains more than 1 or 2 elements!
>> As far as spawning processes in general, please don't use system() or fork()/exec(). Please use the posix_spawn syscall instead as it is much cleaner and has less overhead.
> I'm not really familiar with that API, but a quick look suggests that the variant for spawning in "non-detached" fashion (spawnfd) is missing, correct?
>> The open utility is basically a CLI to LSOpenURLsWithRole(). It does not exec or spawn anything. It just calls into LSOpenURLsWithRole().
> Hmm, ok. I once wrote an alternative, but I cannot remember exactly why. Looks like I only simplified the calling syntax (`osxlaunch [-W] command [arguments]`).
> macports-users mailing list
> macports-users at lists.macosforge.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4109 bytes
Desc: not available
More information about the macports-users