You need to enable JavaScript to run this app. 更新MacBook与Xcode后iOS项目Stripe SDK编译报错无法运行求解决
优惠活动
大模型
产品
解决方案
定价
更多

更新MacBook与Xcode后iOS项目Stripe SDK编译报错无法运行求解决

问题场景

更新MacBook系统与Xcode版本后,打开原有iOS项目触发编译流程,出现Stripe SDK相关编译报错,项目无法正常构建运行,具体报错信息如下:

/Users/ralucaraluca/Downloads/tariffo/tariffo/ios/Pods/Stripe/Stripe/STPPinManagementService.m:51:81:
    error: 'new' is unavailable: You cannot directly instantiate an STPIssuingCardPin
                                                    deserializer:[STPIssuingCardPin new]
                                                                                    ^
    In file included from
    /Users/ralucaraluca/Downloads/tariffo/tariffo/ios/Pods/Stripe/Stripe/STPPinManagementService.m:11:
    /Users/ralucaraluca/Downloads/tariffo/tariffo/ios/Pods/Stripe/Stripe/PublicHeaders/STPIssuingCardPin.h:22:
    1: note: 'init' has been explicitly marked unavailable here
    - (instancetype)init __attribute__((unavailable("You cannot directly instantiate an STPIssuingCardPin")));
    ^
    /Users/ralucaraluca/Downloads/tariffo/tariffo/ios/Pods/Stripe/Stripe/STPPinManagementService.m:101:81:
    error: 'new' is unavailable: You cannot directly instantiate an STPIssuingCardPin
                                                    deserializer:[STPIssuingCardPin new]
                                                                                    ^
    In file included from
    /Users/ralucaraluca/Downloads/tariffo/tariffo/ios/Pods/Stripe/Stripe/STPPinManagementService.m:11:
    /Users/ralucaraluca/Downloads/tariffo/tariffo/ios/Pods/Stripe/Stripe/PublicHeaders/STPIssuingCardPin.h:22:
    1: note: 'init' has been explicitly marked unavailable here
    - (instancetype)init __attribute__((unavailable("You cannot directly instantiate an STPIssuingCardPin")));
    ^
问题根因

该报错并非Xcode升级直接引发的逻辑错误,本质是项目锁定的旧版本Stripe SDK存在内部实现不一致的缺陷:SDK在公开头文件中明确将STPIssuingCardPin类的init方法标记为禁止直接调用,但其自身的服务类代码却仍在直接调用new方法实例化该类。旧版本Xcode的编译校验规则较宽松,未拦截这类违规调用;升级到新版本Xcode后,严格的编译检查会直接拦截这类调用,最终触发编译失败。

解决步骤
  • 优先升级Stripe SDK至兼容最新编译环境的稳定版本
    打开项目iOS目录下的Podfile,将Stripe依赖的版本号调整为已修复该类内部调用缺陷的稳定版本,在终端执行pod install --repo-update重新拉取SDK依赖包,替换本地旧版本SDK。
  • 临时修复(暂无法升级SDK时使用)
    如果因为项目依赖版本锁定暂时无法升级Stripe SDK,可以手动修改报错的源码文件:定位到Pods/Stripe/Stripe/STPPinManagementService.m路径下的第51行、第101行,将违规的[STPIssuingCardPin new]调用替换为该模型类提供的、符合初始化约束的反序列化方法。由于Pods目录下的文件会在执行pod install时被系统重新拉取覆盖,需要在Podfile的post_install配置段添加自动替换脚本,避免每次重新安装依赖都需要手动修改文件。
  • 清理残留构建缓存
    调整完依赖配置后,在Xcode顶部菜单栏选择Product > Clean Build Folder清空本地编译缓存,再删除项目对应的DerivedData缓存目录,重新打开项目启动构建流程,避免旧的编译缓存残留导致报错复现。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.23 03:36:07