ios - Phonegap CLI 5.1.1 --变量未显示在plugin.xml中

标签 ios cordova phonegap-plugins plist cordova-plugins

我正在尝试获取一个变量并在我的 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 添加它作为 parent (虽然它对其他一些字符串很好),但我的 Cordova 可能有问题。

关于ios - Phonegap CLI 5.1.1 --变量未显示在plugin.xml中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31501499/

相关文章:

android - cordova 插件条码扫描器无法打开扫描

即使使用线程池,Android Cordova 插件也会锁定 UI 线程

ios - 您如何存档 Swift 包依赖项以包含在您的 XCFramework 中以作为 Swift 包进行二进制分发?

cordova - 为什么iOS9 WebView CSS Transform会将红色元素变成蓝色元素?

android - Phonegap后台问题

ios - Ionic 3 不正确的滚动行为

android - 2015 年哪个 Android/iPhone 跨平台框架?

iOS 通用链接 : Tapping universal link inside the Application redirects me to safari instead of continuing in the application

ios - 如何在模拟器环境中使用 UIImagePickerController 的 CameraOverlayView 属性

ios - Xcode 6.0.1 Instruments iOS8 - 在设备上进行分析时应用程序表现不正常