1

我正在编写一个应用程序,它可以在短时间内(几秒钟)更改您的 Mac OS X 版本,以启动一个旧版本或新版本的应用程序。

它从 SystemVersion.plist (/System/Library/CoreServices/SystemVersion.plist) 中读取版本,然后设置新的所需版本。保存(覆盖)文件并启动应用程序,然后将版本更改回原始版本。

这是代码的第一部分(读取版本并尝试覆盖)

// Get SystemVersion.plist as Dictionary 
NSBundle *bundle = [NSBundle bundleWithPath:@"/System/Library/CoreServices"];
NSString *SystemVersionString = [bundle pathForResource:@"SystemVersion" ofType:@"plist"];
NSMutableDictionary *SystemVersionDir = [NSDictionary dictionaryWithContentsOfFile:SystemVersionString];

// Get current version (Systemversion, ProductUserVisibleVersion)
NSString *SystemVersion = [SystemVersionDir objectForKey:@"ProductVersion"];

// Get desired version from text field
NSString *DesiredVersion = [_Text_version stringValue];

[_Text_Info setStringValue:SystemVersion];

// Set new version
[SystemVersionDir setObject:DesiredVersion forKey:@"ProductVersion"];

// Write (save) plist
if([SystemVersionDir writeToFile:@"/System/Library/CoreServices/SystemVersion.plist" atomically:YES])
{
    NSLog(@"YES");
}
else 
{
    NSLog(@"NO");
}

问题出在'writeToFile'. 如果我写到我的桌面或一切正常,它会创建一个新文件。此外,如果我将文件复制到我的桌面并在那里覆盖它,它会很好。但它需要覆盖/System/Library/CoreServices/.

我想我需要授权什么的。但是,我已经对此进行了研究,但似乎工作量很大,因此我的头脑一团糟。

没有更简单的方法可以做到这一点,也许是一个有帮助的类?

注意:Mac OS X 10.8 Mountain Lion 开发者预览版 3 (Xcode 4.3.1)

4

0 回答 0