您当前的位置: 首页 > 技术文章 > 移动开发

M1芯片电脑打包framework过程及问题pod package

作者: 时间:2023-12-02阅读数:人阅读

使用M1电脑的pod package打包framework会出现各种各样问题,将踩到的坑记录如下:

pod 打包framework
先安装sudo gem install cocoapods-packager

报错

xcode-select: error: tool ‘xcodebuild’ requires Xcode, but active
developer directory ‘/Library/Developer/CommandLineTools’ is a command
line tools instance

如果本次确实已安装LineTool需要关联路径。
执行下面命令

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/

打包framework命令:

pod package 你的项目.podspec --force —embedded --no-mangle --exclude-deps

再次打包有以下报错问题不支持arm7架构打包:

/var/folders/j5/wglq81t90xs_vcwywb93c7pr0000gn/T/cocoapods-7w8f4l0n/Pods/Pods.xcodeproj:
warning: The iOS deployment target ‘IPHONEOS_DEPLOYMENT_TARGET’ is set
to 9.0, but the range of supported deployment target versions is 11.0
to 16.2.99. (in target ‘Pods-packager’ from project ‘Pods’)
error: The armv7 architecture is deprecated. You should update your ARCHS build setting to remove the armv7 architecture. (in target
‘Pods-packager’ from project ‘Pods’)
error: The armv7s architecture is deprecated. You should update your ARCHS build setting to remove the armv7s architecture. (in target
‘Pods-packager’ from project ‘Pods’)
/var/folders/j5/wglq81t90xs_vcwywb93c7pr0000gn/T/cocoapods-7w8f4l0n/Pods/Pods.xcodeproj:
warning: The iOS deployment target ‘IPHONEOS_DEPLOYMENT_TARGET’ is set
to 9.0, but the range of supported deployment target versions is 11.0
to 16.2.99. (in target ‘JDTGateway’ from project ‘Pods’)
error: The armv7 architecture is deprecated. You should update your ARCHS build setting to remove the armv7 architecture. (in target
‘JDTGateway’ from project ‘Pods’)
error: The armv7s architecture is deprecated. You should update your ARCHS build setting to remove the armv7s architecture. (in target
‘JDTGateway’ from project ‘Pods’)

问题2模拟器包cpu架构与真机架构相同:

fatal error:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo:
Pods/build/package.a and Pods/build-sim/package.a have the same
architectures (arm64) and can’t be in the same fat output file

问题3没找到模拟器编译后的包:

Usage:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
-static [-] file […] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT] [-no_warning_for_no_symbols] Usage:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
-dynamic [-] file […] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #]
[-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#]
[-segs_read_write_addr 0x#] [-seg_addr_table ]
[-seg_addr_table_filename <file_system_path>] [-all_load]
[-noall_load] fatal error:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo:
can’t open input file: Pods/build-sim/package.a (No such file or
directory)

以上解决方案:
修改podspec文件,添加以下配置,真机、模拟器编译时候排除arm7等架构。

s.pod_target_xcconfig = {
    # 'VALID_ARCHS' => 'arm64',
    'EXCLUDED_ARCHS[sdk=iphoneos*]' => 'armv7 armv7s',
    'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'armv7 armv7s arm64'
  }
  s.user_target_xcconfig = {
    # 'VALID_ARCHS' => 'arm64',
    'EXCLUDED_ARCHS[sdk=iphoneos*]' => 'armv7 armv7s',
    'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => "armv7 armv7s arm64"
  }

本站所有文章、数据、图片均来自互联网,一切版权均归源网站或源作者所有。

如果侵犯了你的权益请来信告知我们删除。邮箱:licqi@yunshuaiweb.com

标签: xcode ios swift
加载中~