Search Unity

Building a plugin for OS X using extant dylibs

Discussion in 'macOS' started by Tony-Lovell, Feb 20, 2016.

  1. Tony-Lovell


    Jul 14, 2014
    How do you actually build a plugin for OS X?

    The "ASimplePlugin" example no longer works with modern XCode versions. XCode (7.2.1) complains that my computer is not a suitable target for the result of the build. Googling that error message has offered me no real insight.

    My actual desire here is to build a Unity plugin that employs a 32 bit/64 bit libmylib.dylib that I've already built (I'd love not to have to include XCode in this process at all). When I try building a .bundle that includes my dylib (which I dragged into the proper panel of the project as shown in this Youtube video:
    ), the resultant bundle built does not include the dylib (as verified by "Show Package Contents")

    I've tried manually altering the pre-built ASimplePlugin.bundle included in the example, removing the MacOS/ASimplePlugin file and replacing it with my libmylib.dylib (renamed as "libmylib").

    I altered the info.plist file in two places to read as follows (** annotations are not in the file, of course)

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
    <plist version="1.0">
    <string>libmylib</string> ** I CHANGED THIS LINE **
    <string>com.companyname.libmylib</string> ** I CHANGED THIS LINE **

    FYI, "file Contents/MacOS/ASimplePlugin" yielded:

    Contents/MacOS/ASimplePlugin: Mach-O universal binary with 2 architectures
    Contents/MacOS/ASimplePlugin (for architecture i386):Mach-O bundle i386
    Contents/MacOS/ASimplePlugin (for architecture ppc7400):Mach-O bundle ppc

    "file Contents/MacOS/libmylib" returns something different (perhaps my problem is choice of a shared library):

    Contents/MacOS/libmylib: Mach-O universal binary with 2 architectures
    Contents/MacOS/libmylib (for architecture i386):Mach-O dynamically linked shared library i386
    Contents/MacOS/libmylib (for architecture x86_64):Mach-O 64-bit dynamically linked shared library x86_64

    When running these several variations, the Unity standalone on OS X bombs out with an "
    Abort trap: 6".

    I tried swapping in libmylib.a in place of libmylibe.dylib, and this caused a gentler failure -- exceptions in the standalone player:

    Couldn't open Assets/Plugins/libmylib.bundle/Contents/MacOS/libmylib, error: dlopen(Assets/Plugins/libmylib.bundle/Contents/MacOS/libmylib, 2): no suitable image found. Did find:
    Assets/Plugins/Opus/libmylib.bundle/Contents/MacOS/libmylib: unknown file type, first eight bytes: 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A

    Last edited: Feb 20, 2016
  2. Tony-Lovell


    Jul 14, 2014
    I edited this to provide more detail on my confusion.