美文网首页
Xcode 14.3版本运行项目报错

Xcode 14.3版本运行项目报错

作者: 雪精灵是我 | 来源:发表于2023-05-15 17:03 被阅读0次

    1、Xcode升级到14后,编译报错:

    Signing for "xxx" requires a development team. select a development team in the signing & capabilities editor

    该错误为Pod库中包含Test的Target,需要设置Team ID

    解决方案①:针对报错的库,手动选择签名的 Team

    解决方案②:在Podfile 中添加一下代码,dev_team的值为开发者账号的 Team ID,

    post_install do |installer|

      dev_team = “xxxxxxxxxxx"

         project = installer.aggregate_targets[0].user_project

         project.targets.each do |target|

             target.build_configurations.each do |config|

                 if dev_team.empty? and !config.build_settings['DEVELOPMENT_TEAM'].nil?

                     dev_team = config.build_settings['DEVELOPMENT_TEAM']

                 end

             end

    end

    2、

    拨错信息 ld: file not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a

    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    从报错信息看,都是在链接库的时候因为找不到静态库(libarclite_iphonesimulator.a/libarclite_iphoneos.a)而报错。利用访达的前往文件夹功能快速来到报错信息中的目录,发现连arc目录都不存在,更不用说静态库文件。

    现在可以确定的是Xcode 14.2版本肯定是正常的,那会不会是14.3版本移除了整个arc目录?找到一台还没升级到Xcode 14.3版本的电脑,在同样的路径下,果然存在arc目录,

    因为系统已经内置有ARC相关的库,所以没必要再额外链接,至少Xcode 14支持的最低部署目标iOS 11及以上版本的系统肯定是没问题的。如果应用部署目标不低于iOS 11还出现问题,那么应该是第三方库的部署目标有问题。

    现在Xcode 14.3移除arc目录的原因已经很清楚,是因为支持的最低部署版本的系统都已经内置了ARC相关的库。如果应用最低部署目标版本本身不低于iOS 11,解决这个问题很简单,只需要将第三方库部署目标的iOS版本设置成和应用最低部署目标的iOS版本一致。

    解决方案①: arc文件下载的链接: https://pan.baidu.com/s/1MI6Mr-gqOO6Yg_P9B5jpPg 密码: 6ows

    把arc的文件复制到指定目录路径:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib

    解决方案②:设置第三方库最低可运行的系统版本,在Podfile 中添加一下代码,并执行pod install 命令

    post_install do |installer|

      installer.pods_project.targets.each do |target|

        target.build_configurations.each do |config|

          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = ‘11.0'

        end

      end

    end

    3、

    报错信息PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /Users/shelly/Library/Developer/Xcode/DerivedData/Runner-hkpcetbkrwprnodvpnzwwzwyjxks/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-0CE87C2C48C36989195F6D5E.sh (in target 'Runner' from project 'Runner')

        cd /Users/shelly/Desktop/JA/qns_partner/ios

        /bin/sh -c /Users/shelly/Library/Developer/Xcode/DerivedData/Runner-hkpcetbkrwprnodvpnzwwzwyjxks/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-0CE87C2C48C36989195F6D5E.sh

    mkdir -p /Users/shelly/Library/Developer/Xcode/DerivedData/Runner-hkpcetbkrwprnodvpnzwwzwyjxks/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/Runner.app/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/AliyunOSSiOS.framework" "/Users/shelly/Library/Developer/Xcode/DerivedData/Runner-hkpcetbkrwprnodvpnzwwzwyjxks/Build/Intermediates.noindex/ArchiveIntermediates/Runner/InstallationBuildProductsLocation/Applications/Runner.app/Frameworks"

    building file list ... rsync: link_stat "/Users/shelly/Desktop/JA/qns_partner/ios/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/AliyunOSSiOS.framework" failed: No such file or directory (2)

    done

    sent 29 bytes  received 20 bytes  98.00 bytes/sec

    total size is 0  speedup is 0.00

    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

    解决方案①:手动修改,修改 /Pods/Target Support Files/Pods-{product名称}/Pods-{product名称}-frameworks.sh,搜索source="$(readlink "${source}")”  并改为     source="$(readlink -f "${source}”)"

    解决方案②:在Podfile中添加一下代码,并执行pod install 命令

    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

    针对Xcode 升级中的问题可以在Podfile中添加一下代码统一处理,dev_team 修改成自己的TeamID ,并执行pod install 命令,

    post_install do |installer|

      dev_team = “xxxxxx"

         project = installer.aggregate_targets[0].user_project

         project.targets.each do |target|

             target.build_configurations.each do |config|

                 if dev_team.empty? and !config.build_settings['DEVELOPMENT_TEAM'].nil?

                     dev_team = config.build_settings['DEVELOPMENT_TEAM']

                 end

             end

      installer.pods_project.targets.each do |target|

        if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"

            target.build_configurations.each do |config|

                config.build_settings['DEVELOPMENT_TEAM'] = dev_team

            end

          end

        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

        flutter_additional_ios_build_settings(target)

        target.build_configurations.each do |config|

          config.build_settings['ENABLE_BITCODE'] = 'NO'

          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'

          end

        end

      end

    end

    TeamID 的获取方法

    TeamID的获取网站https://developer.apple.com/account

    下图中红色框出来的区域为TeamID

    相关文章

      网友评论

          本文标题:Xcode 14.3版本运行项目报错

          本文链接:https://www.haomeiwen.com/subject/poorsdtx.html