Phonegap CLI 5.1.1 --变量未显示在 plugin.xml
Phonegap CLI 5.1.1 --variable doesn't show up in plugin.xml
我正在尝试获取一个变量并在我的 plugin.xml 中使用它来构建 URL 类型。每次构建时,我都会检查我的 .plist 文件。它吐出 $URL_SCHEME 而不是实际值。这是我的代码,
<config-file target="*-Info.plist" parent="CFBundleURLTypes">
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>MY_SCHEME</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$MY_SCHEME</string>
</array>
</dict>
</array>
</config-file>
我添加了我的插件,
cordova plugin add ../myplugin/ --variable MY_SCHEME=myScheme
知道为什么 "myScheme" 没有出现在我的 .plist 文件中,而是显示“$MY_SCHEME”吗?
2015 年 7 月 27 日编辑:
这是我的 plugin.xml - http://pastebin.com/YH7LzTjf
您需要添加 <preference/>
才能使 --variable
正常工作。试试这个:
<preference name='MY_SCHEME'/>
<config-file target="*-Info.plist" parent="CFBundleURLTypes">
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>MY_SCHEME</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$MY_SCHEME</string>
</array>
</dict>
</array>
</config-file>
我不知道 - 由于某种原因,我无法将它添加为 CFBundleURLTypes
作为父项(尽管它对某些其他字符串没问题),但我的 Cordova 可能有问题。
我正在尝试获取一个变量并在我的 plugin.xml 中使用它来构建 URL 类型。每次构建时,我都会检查我的 .plist 文件。它吐出 $URL_SCHEME 而不是实际值。这是我的代码,
<config-file target="*-Info.plist" parent="CFBundleURLTypes">
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>MY_SCHEME</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$MY_SCHEME</string>
</array>
</dict>
</array>
</config-file>
我添加了我的插件,
cordova plugin add ../myplugin/ --variable MY_SCHEME=myScheme
知道为什么 "myScheme" 没有出现在我的 .plist 文件中,而是显示“$MY_SCHEME”吗?
2015 年 7 月 27 日编辑: 这是我的 plugin.xml - http://pastebin.com/YH7LzTjf
您需要添加 <preference/>
才能使 --variable
正常工作。试试这个:
<preference name='MY_SCHEME'/>
<config-file target="*-Info.plist" parent="CFBundleURLTypes">
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>MY_SCHEME</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$MY_SCHEME</string>
</array>
</dict>
</array>
</config-file>
我不知道 - 由于某种原因,我无法将它添加为 CFBundleURLTypes
作为父项(尽管它对某些其他字符串没问题),但我的 Cordova 可能有问题。