简体   繁体   English

在react native中编辑后无法保存info.plist

[英]info.plist can not be saved after editing in react native

The problem I have is when I edit the MyProject/ios/info.plist , I save it successfully. 我遇到的问题是编辑MyProject / ios / info.plist时 ,成功保存了它。 But when I try to open the project to see if the changes have been applied, it is only edited back to its default form. 但是,当我尝试打开项目以查看是否已应用更改时,只会将其编辑回其默认形式。 Does anyone know why this happens and how could it be definitively edited after adding anything? 有谁知道为什么会发生这种情况,以及添加任何内容后如何对其进行最终编辑? Here you have more details with what I work: 在这里,您对我的工作有更多详细信息:

package.json: package.json:

 { "name": "user", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest" }, "dependencies": { "npm": "^5.7.1", "react": "16.3.0-alpha.2", "react-native": "0.54.2" }, "devDependencies": { "babel-jest": "23.0.0-alpha.0", "babel-preset-react-native": "4.0.0", "jest": "22.4.2", "react-test-renderer": "16.3.0-alpha.2" }, "jest": { "preset": "react-native" } } 

info.plist before editing (default): 编辑前的info.plist(默认):

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>LastAccessedDate</key> <date>2018-03-20T15:02:01Z</date> <key>WorkspacePath</key> <string>/Users/user/Documents/myproject/ios/myproject.xcodeproj</string> </dict> </plist> 

info.plist after editing: 编辑后的info.plist:

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>LastAccessedDate</key> <date>2018-03-20T15:02:01Z</date> <key>WorkspacePath</key> <string>/Users/user/Documents/myproject/ios/myproject.xcodeproj</string> </dict> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> </plist> 

I explain, when saving the changes made and recompile the application from scratch, the lines added in the info.plist disappear and only the default value remains. 我解释说,当保存所做的更改并从头开始重新编译应用程序时,info.plist中添加的行会消失,仅保留默认值。

However, if there's no solution, what can i add instead of 但是,如果没有解决方案,我可以添加些什么而不是

 <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> 

to make http requests to IOS devices, is there a different way to do it? 向IOS设备发出http请求,是否有其他方法?

There should be only one root level dictionary in the file. 文件中应该只有一个根目录字典。 So try this one instead: 因此,请尝试以下方法:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>LastAccessedDate</key>
    <date>2018-03-20T15:02:01Z</date>
    <key>WorkspacePath</key>
    <string>/Users/user/Documents/myproject/ios/myproject.xcodeproj</string>
    <key>NSAppTransportSecurity</key>
    <dict>
       <key>NSAllowsArbitraryLoads</key>
       <true/>
    </dict>
</dict>
</plist>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 react-native链接给出错误,没有这样的文件或目录info.plist - react-native link giving error no such file or directory info.plist 仪表板小部件:从Info.plist获取版本号 - Dashboard widget: getting version number from Info.plist 在 React Native 中编辑已经发布的应用程序中的代码后,如何再次发布 apk - how can i release apk again after editing code in an already release app in react native 错误:Info.plist 中必须存在 `NSLocation*UsageDescription` 键之一才能使用地理定位 - Error: One of the `NSLocation*UsageDescription` keys must be present in Info.plist to be able to use geolocation 编辑结束后如何在TextInput中添加文本React Native - How to add text in TextInput after editing ends React Native React Native 设备制造商信息 - React Native Device Manufacturer Info 在本机反应中动态编辑数组项 - editing array items dynamically in react native 在 react native 上使用 static 数据编辑文本输入 - Editing text input with static data on react native 从 React Native 编辑浮动标签和按钮 - Editing Floating Label & Button from React Native 获取设备当前位置(navigator.location.getCurrentPosition)后将信息保存到数据库,React Native - save info to database after getting device current location (navigator.location.getCurrentPosition), React Native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM