I am trying to make my own VST plug-in Installer app. I have found a lot of little obstacles in CoreFoundation because I do not master OSX world (I am a Win32 guy). As a result, every line I have coded costed me hours or days.
Well, I am almost finishing this installer, but I have found a trouble that I really do not know ho to solve. The issue is the following:
The app installer is a bundle and inside this bundle there is a VST payload as a resource, this is, the VST plugin (that, in fact, is another bundle as you know). Well the purpose of the showed excerpt code is to handle the resource (the VST folder/bundle) and try to copy it to the Library/Audio/Plug-Ins/VST destination. All the references are tested and they worked. The problem is that the VST bundle is not copied because apparently there is not enough privileges to do such operation.
The osstatus output code is: [color=#FF0000]“afpAccessDenied” “Insufficient access privileges for operation” code -5000[/color]
[code] CFBundleRef mainBundle;
// Get the main bundle for the app
mainBundle = CFBundleGetMainBundle();
CFURLRef cfURLref;
cfURLref = CFBundleCopyResourceURL (mainBundle,
CFSTR("OnTime.vst"),
NULL,
NULL);
FSRef source, destDir;
CFURLGetFSRef(cfURLref, &source);
OSStatus osstatus;
Boolean isDirectory;
UInt8 pathIn[] = "/Library/Audio/Plug-Ins/VST";
FSPathMakeRef (
pathIn,
&destDir,
&isDirectory
);
osstatus = FSCopyObjectSync(&source, &destDir, NULL, NULL, kFSFileOperationOverwrite);
[/code]
Please, does anybody know how to solve this problem. For instance, how can I get the modal dialogue to allow a user to grant permission by inputting the password, or how can I circumvent this privileges or how can I say to the system that I have enough privileges to copy such bundle?
Any solution is good for me as far as I can get rid of this… nightmare!
Do you have to install it into the root library directory? If you put it in the user’s library folder that should work e.g. “~/Library/Audio/Plug-Ins/VST”.
Of course this is more of a work around than a solution.
#!/bin/sh
###
# Install
# call: installfile( src, dest )
###
srcdir="$1"
vstDir="/Library/Audio/Plug-Ins/VST"
#installdir()
{
# I should create the path
if [ ! -d "${vstDir}" ]; then
# if directory already exists leave it untouched
echo "Creating Directory"
mkdir -p "${vstDir}"
fi
}
if [ -e "${vstDir}/PlugIn.bundle" ]; then
rm -R "${vstDir}/PlugIn.bundle"
fi
cp -R -v "${srcdir}/PlugIn.bundle" "${vstDir}"
if [ -e "${vstDir}/PlugIn.bundle" ]; then
rm -R "${vstDir}/PlugIn.bundle"
fi
#cp -R "${srcdir}/PlugIn.bundle" "${vstDir}"
if [ ! -e "${vstDir}/PlugIn.bundle" ]; then
echo "Installing PlugIn Bundle"
cp -R "${srcdir}/PlugIn.bundle" "${vstDir}"
fi
If you just want to copy to ~/Library, you might want to just use some Cocoa calls (make your source file a .mm file so you can mix in some C++ if you want)
You can get the path to your plugin(in your resources folder)
NSString *installPlugIn=[[NSBundle mainBundle]pathForResource:@“OnTime” ofType:@“vst”];
Then use the NSFileManager to do the copying, something like
NSFileManager* fm = [NSFileManager defaultManager];
[fm copyPath:installPlugIn toPath:@"~/Library/Audio/etc" handler:nil];
[quote]If you just want to copy to ~/Library, you might want to just use some Cocoa calls (make your source file a .mm file so you can mix in some C++ if you want)
You can get the path to your plugin(in your resources folder)
NSString *installPlugIn=[[NSBundle mainBundle]pathForResource:@“OnTime” ofType:@“vst”];
Then use the NSFileManager to do the copying, something like
NSFileManager* fm = [NSFileManager defaultManager];
[fm copyPath:installPlugIn toPath:@"~/Library/Audio/etc" handler:nil];[/quote]
Thank you justin.
I am not good at Objective-C (at all!) but I’ll start to work on it. The Script shell solution encapsulated in code is another less smart solution but if there is no other option…
Nevertheless, I would like to make a last call for a native C++ CoreFoundation solution, anybody else, pleeeeeease?
[quote=“dave96”]Do you have to install it into the root library directory? If you put it in the user’s library folder that should work e.g. “~/Library/Audio/Plug-Ins/VST”.
Of course this is more of a work around than a solution.[/quote]
Dave you were absolutely and definitely right. This was the problem (and the solution!)
Out of interest do you need an application based installer package? Usually this is only needed if you have to copy custom resources or make file associations etc. I’ve always used a custom dmg installer as described here and dynamically loaded resources from the binary at run time. Its a nice, tidy and portable way to package an app.
I’m sure doing this and providing the root VST folder as the destination would show the Finder’s permission window.