Xcode 14.3 cocoapod 1.12.0 打包报错解决

news/2024/7/20 21:41:52 标签: xcode, macos, ide, cocoapods, ios

前言

前几天升级Xcode到14.3版本,运行项目报错,于是记录下来。

开发环境

macOS: 13.3.1
Xcode: 14.3
CocoaPods: 1.12.0

问题描述

[Xcode菜单栏] -> [Product] -> [Archive],进行打包操作。执行到 Run custom shell script '[CP] Embed Pods Frameworks'时报错,报错相关日志如下:

Symlinked...

rsync --delete -av --filter P .*.?????? --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/xxx.framework" "/Users/xxx/Library/Developer/Xcode/DerivedData/app-dukdzczlzijlklamofogqicmtktj/Build/Intermediates.noindex/ArchiveIntermediates/app/InstallationBuildProductsLocation/Applications/app.app/Frameworks"

building file list ... rsync: link_stat "xxx/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/xxx.framework" failed: No such file or directory(2)

rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/97f6331a-ba75-11ed-a4bc-863efbbaf80d/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]

Command PhaseScriptExecution failed with a nonzero exit code

如图:
报错截图
在网上搜索找到一种解决办法:说这是一个 cocoapods 问题:https://developer.apple.com/forums/thread/727525 和 https://github.com/CocoaPods/CocoaPods/pull/11828#issuecomment-1497329930
需要修改的是,进入pod文件的 “Pods-APPNAME-frameworks.sh” 文件:

原码:

if [ -L "${source}" ]; then
    echo "Symlinked..."
    source="$(readlink "${source}")"
  fi

改成:

 if [ -L "${source}" ]; then
    echo "Symlinked..."
    source="$(readlink -f "${source}")"
  fi

这个确实管用,但是每次执行完pod install命令后,Pods-app-frameworks.sh的文件内容又恢复原状了。



解决方案

方案一:升级CocoaPods版本

个人比较推荐的方法,但是可能暂时还无法使用。问题将在1.12.1版本修复,如果你遇到这个问题时,CocoaPods版本已经发布到1.12.1或更高版本,推荐通过升级到最新版本解决该问题。

方案二:修改Podfile文件

加上这段代码:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    shell_script_path = "Pods/Target Support Files/#{target.name}/#{target.name}-frameworks.sh"
    if File::exists?(shell_script_path)
      shell_script_input_lines = File.readlines(shell_script_path)
      shell_script_output_lines = shell_script_input_lines.map { |line| line.sub("source=\"$(readlink \"${source}\")\"", "source=\"$(readlink -f \"${source}\")\"") }
      File.open(shell_script_path, 'w') do |f|
        shell_script_output_lines.each do |line|
          f.write line
        end
      end
    end
  end
end

重新执行pod install命令解决问题。

方案三:修改embed_frameworks_script.rb文件

文件位于CocoaPods包下的lib/cocoapods/generator/embed_frameworks_script.rb路径,将文件中的source="$(readlink "${source}")"替换为source="$(readlink -f "${source}")",重新执行pod install命令解决问题。


http://www.niftyadmin.cn/n/231601.html

相关文章

策划一个活动,活动要求:本科毕业论文致谢部分撰写,仅本校学生可参加,报名人数500,参数作品800-1500字,文体不限的活动

#策划一个活动,活动要求:本科毕业论文致谢部分撰写,仅本校学生可参加,报名人数500,参数作品800-1500字,文体不限的活动 活动名称: 感恩之言——本科毕业论文致谢部分撰写大赛 活动背景&#x…

主从模式、哨兵模式、集群模式(cluster)

主从模式、哨兵模式、集群模式(cluster) redis 实现高可用的方式分为 主从模式、哨兵模式、集群模式(cluster) 1. 主从模式(又称为主从复制) 表现为1个主节点,多个从节点,主节点负…

软件测试实验:静态测试

目录 前言 一、实验目的 二、实验内容 三、实验步骤 四、实验过程 1、学生宿舍管理系统代码 2、汇总表 3、C语言编码规范 总结 前言 软件测试是软件开发过程中不可或缺的一个环节,它可以保证软件的质量和功能,提高用户的满意度和信任度。软件测…

证明电压电流相位差的余弦值和功率因数相等

证明:“电压电流相位差的余弦值”和“功率因数”相等。 电压电流相位差的余弦值和功率因数相等,这在《电路分析》中给出过结论,但没有给出详细的证明过程。其次,在电气工程师考试中,也会经常遇到。 电压电流相位差&am…

一款适合程序员的 Markdown 简历模版,拒绝花里胡哨

一款适合 IT 行业的 Markdown 简约简历模版,拒绝花里胡哨 开始使用 (1)安装 Markdown 编辑软件,推荐使用 Typora 编辑器(免费版 Typora 百度网盘下载点此下载)。 (2)下载本项目&am…

音视频技术开发周刊 | 289

每周一期,纵览音视频技术领域的干货。新闻投稿:contributelivevideostack.com。王小川入局大模型创业,称追上GPT-4需要3年左右搜狗创始人王小川正式对外宣布开启人工智能大模型领域创业。王小川与前搜狗COO茹立云联合成立人工智能公司百川智能…

精彩回顾|SOFA 五周年,Live Long and Prosper!

2023 年 4 月 15 日,SOFAStack 社区在北京市朝阳区 C work 举办了自己的第五个生日。在“Live Long and Prosper”的活动主题贯彻下,活动现场的开源技术探索氛围变得尤其浓厚。SOFA 开源集市在 SOFA 五周年的开源集市中,汇聚了 SOFAStack 的 …

P4655 [CEOI2017] Building Bridges

P4655 [CEOI2017] Building Bridges 题意: 有 nnn 根柱子,每根柱子有高度 hih_ihi​,在柱子 iii 和柱子 jjj 之间建桥的代价为 (hi−hj)2(h_i-h_j)^2(hi​−hj​)2。每根没建桥的柱子需要花费 wiw_iwi​ 的代价拆除。询问使第 111 根柱子和…