查看FScript.app的代码(据报道它链接到大多数核心框架),我发现了以下方法:
- (void)loadSystemFrameworks // Contributed by Cedric Luthi
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSMutableArray *systemFrameworksPaths = [NSMutableArray arrayWithObject:@"/System/Library/Frameworks"];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"FScriptLoadPrivateSystemFrameworks"])
[systemFrameworksPaths addObject:@"/System/Library/PrivateFrameworks"];
for (NSString *systemFrameworksPath in systemFrameworksPaths)
{
for (NSString *framework in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:systemFrameworksPath error:NULL])
{
NSBundle *frameworkBundle = [NSBundle bundleWithPath:[systemFrameworksPath stringByAppendingPathComponent:framework]];
if ([frameworkBundle preflightAndReturnError:nil])
[frameworkBundle load];
}
}
[pool drain];
}
我认为链接到从应用程序定义的类就足以加载包含这些类的包。