You need to enable JavaScript to run this app. 开发iOS端Cordova插件时如何通过plugin.xml设置最低iOS版本
优惠活动
大模型
产品
解决方案
定价
更多

开发iOS端Cordova插件时如何通过plugin.xml设置最低iOS版本

Cordova插件指定Pod最低iOS版本的配置方法

核心配置(自动匹配生成的Podfile版本)

Cordova iOS的podspec配置原生支持通过属性声明Podfile的最低iOS部署版本,无需手动修改模板生成逻辑,直接在现有plugin.xml的<config>节点添加ios-deployment-target属性即可:

<!-- 修改后的完整podspec配置 -->
<podspec>
    <!-- 新增ios-deployment-target属性,值为依赖要求的13.0 -->
    <config ios-deployment-target="13.0">
        <source url="https://cdn.cocoapods.org/"/>
    </config>
    <pods use-frameworks="true">                
        <pod name="ArcGIS-Runtime-SDK-iOS" spec="100.10" />
    </pods>
</podspec>

配置生效后,自动生成的Podfile会将原本固定的platform :ios, '10.0'替换为platform :ios, '13.0',完全匹配ArcGIS SDK的版本要求。

注:你提供的自动生成Podfile示例里的prod为输入笔误,实际生成的代码会正确使用pod指令引入依赖,不影响配置效果。

兼容兜底配置(避免版本冲突)

仅修改Podfile的平台版本还可能出现宿主Xcode工程本身的最低部署版本为10.0,和Pod要求的13.0冲突的编译报错,需要在ios平台配置块中添加强制版本对齐规则:

<platform name="ios">
    <!-- 新增:覆盖Debug、Release配置下的iOS最低部署版本为13.0 -->
    <edit-config 
        target="IPHONEOS_DEPLOYMENT_TARGET" 
        file="*-Debug.xcconfig" 
        mode="overwrite">
        <value>13.0</value>
    </edit-config>
    <edit-config 
        target="IPHONEOS_DEPLOYMENT_TARGET" 
        file="*-Release.xcconfig" 
        mode="overwrite">
        <value>13.0</value>
    </edit-config>

    <!-- 原有podspec配置 -->
    <podspec>
        <config ios-deployment-target="13.0">
            <source url="https://cdn.cocoapods.org/"/>
        </config>
        <pods use-frameworks="true">                
            <pod name="ArcGIS-Runtime-SDK-iOS" spec="100.10" />
        </pods>
    </podspec>
</platform>

低版本cordova-ios兼容方案

如果需要兼容cordova-ios <6.1.0的版本(该版本才正式支持ios-deployment-target属性),可以在podspec块中添加CocoaPods的post-install钩子,强制覆盖所有Pods工程的部署版本:

<podspec>
    <config>
        <source url="https://cdn.cocoapods.org/"/>
    </config>
    <pods use-frameworks="true">                
        <pod name="ArcGIS-Runtime-SDK-iOS" spec="100.10" />
    </pods>
    <!-- 新增post-install强制对齐版本 -->
    <post-install>
        installer.pods_project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
            end
        end
    </post-install>
</podspec>

该方案不受cordova-ios版本限制,会在Pod安装的最后阶段覆盖所有Pod target的最低部署版本,保证和ArcGIS SDK的要求匹配。


内容的提问来源于stack exchange,提问作者Jay Bowman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.30 08:27:06