Index: src/OFPlugin.h ================================================================== --- src/OFPlugin.h +++ src/OFPlugin.h @@ -44,12 +44,15 @@ } /** * @brief Returns the plugin path for a plugin with the specified name. * - * E.g. on ELF systems, it appends .so, while on macOS and iOS, it creates the - * appropriate plugin path. This can also be prefixed by a directory. + * E.g. on ELF systems, it appends `.so`, while on macOS and iOS, it checks if + * there is a `.bundle` and if so uses the plugin contained in it, but + * otherwise falls back to appending `.dylib`. + * + * This can also be prefixed by a directory. * * @param name The name to return the plugin path for * @return The plugin path */ + (OFString *)pathForName: (OFString *)name; Index: src/OFPlugin.m ================================================================== --- src/OFPlugin.m +++ src/OFPlugin.m @@ -25,10 +25,11 @@ #ifdef HAVE_DLFCN_H # include #endif #import "OFPlugin.h" +#import "OFFileManager.h" #import "OFLocale.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFInitializationFailedException.h" @@ -44,19 +45,24 @@ return [[[self alloc] initWithPath: path] autorelease]; } + (OFString *)pathForName: (OFString *)name { -#if defined(OF_MACOS) - return [name stringByAppendingFormat: @".bundle/Contents/MacOS/%@", - name.lastPathComponent]; -#elif defined(OF_IOS) - return [name stringByAppendingFormat: @".bundle/%@", - name.lastPathComponent]; -#else - return [name stringByAppendingString: @PLUGIN_SUFFIX]; +#if (defined(OF_MACOS) || defined(OF_IOS)) && defined(OF_HAVE_FILES) + OFString *path = [name stringByAppendingPathExtension: @"bundle"]; + + if ([[OFFileManager defaultManager] directoryExistsAtPath: path]) +# if defined(OF_MACOS) + return [path stringByAppendingFormat: @"/Contents/MacOS/%@", + name.lastPathComponent]; +# elif defined(OF_IOS) + return [name stringByAppendingFormat: @"/%@", + name.lastPathComponent]; +# endif #endif + + return [name stringByAppendingString: @PLUGIN_SUFFIX]; } - (instancetype)initWithPath: (OFString *)path { self = [super init];