One of the things I dread is installing stuff on my box. And by installing I refer to those things using the OS X installer that copy themselves deep within the system. I am aware of lsbom and /Library/Receipts but whenever I can avoid it I choose not to install.
I especially don't like installing frameworks because they make my system incompatible with "vanilla" systems. I may at some point ship an application that depends on a framework that works fine on my system but instantly fails on a "vanilla" system, the dynamic linker complaining "image not found" as it tries to load the missing framework.
The solution is using a framework without actually installing it in /System/Library.
This can be done in XCode but I prefer the console - I find using gcc and the linker from the command line a good habit as it acts as a constant reminder of the process XCode hides away behind the build button.
Here's how to use gcc to compile a simple binary against a framework, without the framework being installed on the system:
Our example above replaces any digit with an NSString with the digit "5".
It uses the RegexKit framework which I've previously unarchived on the Desktop (click right on RegexKit_Framework.pkg -> choose "Show Package Contents" -> unzip Archive.pax)
When running the binary you have to remember to set the DYLD_FRAMEWORK_PATH environment variable:
I especially don't like installing frameworks because they make my system incompatible with "vanilla" systems. I may at some point ship an application that depends on a framework that works fine on my system but instantly fails on a "vanilla" system, the dynamic linker complaining "image not found" as it tries to load the missing framework.
The solution is using a framework without actually installing it in /System/Library.
This can be done in XCode but I prefer the console - I find using gcc and the linker from the command line a good habit as it acts as a constant reminder of the process XCode hides away behind the build button.
Here's how to use gcc to compile a simple binary against a framework, without the framework being installed on the system:
#import <Cocoa/Cocoa.h>
#import <RegexKit/NSString.h>
int main()
{
NSAutoreleasePool * pool = [NSAutoreleasePool new];
NSString * t = @"This is a string with 12 or more characters on line 1";
NSLog(@"t is %@", t);
NSString * nodigits = [t stringByMatching:@"(\\d)"
replace:RKReplaceAll
withReferenceString:@"5"];
NSLog(@"\nInput: >>> %@\nOutput: >>> %@", t, nodigits);
[pool release];
return 0;
}
Our example above replaces any digit with an NSString with the digit "5".
It uses the RegexKit framework which I've previously unarchived on the Desktop (click right on RegexKit_Framework.pkg -> choose "Show Package Contents" -> unzip Archive.pax)
diciu$ gcc regexp.m -framework Cocoa -framework RegexKit -F/Users/diciu/Desktop/
When running the binary you have to remember to set the DYLD_FRAMEWORK_PATH environment variable:
diciu$ DYLD_FRAMEWORK_PATH=/Users/diciu/Desktop/ ./a.out
2008-12-17 20:12:49.979 a.out[3925:10b]
Input: >>> This is a string with 12 or more characters on line 1
Output: >>> This is a string with 55 or more characters on line 5