Skip to content

Cannot launch executable through symbolic link (v1.1.0) #10

@blochberger

Description

@blochberger

When launching the executable through a symbolic link, the application is started differently, i.e., outside of the application bundle. This disconnects the command-line tool from the information property list (Info.plist). When trying to access the main bundle of the application in

Bundle.main.bundleIdentifier! + ".ContentBlocker"

the process fails to detect the bundle identifier, which is usually obtained from the default information property list. This causes a forced unwrap of nil and crashes the process.

Related questions on Stack Exchange (unanswered at the time of writing):

Ideas

Usually, the information property list can be embedded into the executable itself, e.g., to enable the App Sandbox for command-line utilities, see https://stackoverflow.com/a/60282941/5082444. Simply enabling the corresponding Xcode setting did not create the respective section in the binary, though.

As explained in a601899, creating a separate command-line executable will not work either.

Workarounds

  • Use an shell alias instead of a symbolic link, as suggested in the README.
  • Create a wrapper script somewhere in PATH:
    #!/bin/sh
    '/Applications/Blocki.app/Contents/MacOS/Blocki' "$@"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmacosPlatform: macOS

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions