覆盖SystemVersion.plist(Objective-c)
我正在编写一个应用程序,可以在短时间内(几秒钟)更改您的Mac OS X版本,以启动一个针对您的版本的新旧应用程序 它从SystemVersion.plist(/System/Library/CoreServices/SystemVersion.plist)读取版本,然后设置所需的新版本。 保存(覆盖)文件并启动应用程序,然后重新更改版本 到原始版本 这是代码的第一部分(读取版本并尝试覆盖) 问题在于覆盖SystemVersion.plist(Objective-c),objective-c,macos,security,authorization,overwrite,Objective C,Macos,Security,Authorization,Overwrite,我正在编写一个应用程序,可以在短时间内(几秒钟)更改您的Mac OS X版本,以启动一个针对您的版本的新旧应用程序 它从SystemVersion.plist(/System/Library/CoreServices/SystemVersion.plist)读取版本,然后设置所需的新版本。 保存(覆盖)文件并启动应用程序,然后重新更改版本 到原始版本 这是代码的第一部分(读取版本并尝试覆盖) 问题在于“writeToFile”。如果我在桌面上写东西,一切正常,它会创建一个新文件。此外,如果我将文
“writeToFile”
。如果我在桌面上写东西,一切正常,它会创建一个新文件。此外,如果我将文件复制到我的桌面并在那里覆盖它,也会很好。但它需要覆盖/System/Library/CoreServices/
中的内容
我想我需要授权什么的。然而,我已经研究过了,但这似乎是一个可怕的大量的工作,我的头脑是混乱的,因为这一点
难道没有一种更简单的方法可以做到这一点吗?也许有一个类可以提供帮助
注意:Mac OS X 10.8 Mountain Lion Developer Preview 3(Xcode 4.3.1)您需要ROOT访问权限,谷歌如何实现这一点。不过,正如您所知,更改系统版本并不好。为什么不更改应用程序中的系统版本约束呢?我知道我需要具有root访问权限,但这涉及到创建整个helper应用程序,不是有一个简单的代码,只需几行代码就可以了吗?我知道改变系统版本是不好的。。我知道这种风险。@LaC,因为这并不总是有效;)
// 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");
}