xcode 可以以编程方式编辑 Info.plist 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12817272/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:45:53  来源:igfitidea点击:

Editing Info.plist possible programmatically?

objective-cxcodeplist

提问by Ambili B Menon

I have set my Facebook-AppId in the Info.plist. But I wish to edit it because its dynamic. How shall I do it programmatically?

我已经在 Info.plist 中设置了我的 Facebook-AppId。但我希望编辑它,因为它是动态的。我将如何以编程方式执行此操作?

回答by Jigar Pandya

Probably write in info.plist is not good idea and it doesn't work because you are trying to write the dictionary to a .plist file inside your App bundle, which is read only. Thus it would not work and also would have more rejection chances even if you get it done other way.

可能在 info.plist 中写入不是一个好主意,它不起作用,因为您试图将字典写入 App 包内的 .plist 文件,该文件是只读的。因此,即使您以其他方式完成它,它也不会起作用,并且也会有更多的拒绝机会。

BTW why Info.Plist only? I mean why you can not have it in other way e.g nsuserdefaults or sql

顺便说一句,为什么只有 Info.Plist?我的意思是为什么你不能以其他方式拥有它,例如 nsuserdefaults 或 sql

回答by DrummerB

You can't edit the Info.plist of your app. You don't have write access to that file (assuming you want to release this on the App Store).

您无法编辑应用程序的 Info.plist。您没有对该文件的写访问权限(假设您想在 App Store 上发布此文件)。

回答by Jordi Kroon

The only way to write a plist file is to copy it from the bundle to the document folder of your app.

编写 plist 文件的唯一方法是将它从包中复制到应用程序的文档文件夹中。

After that you can write. Here is a good tutorial but there are much more. Just google. http://ipgames.wordpress.com/tutorials/writeread-data-to-plist-file/

之后就可以写了。这是一个很好的教程,但还有更多。只是谷歌。 http://ipgames.wordpress.com/tutorials/writeread-data-to-plist-file/