工作项目从 Intel 迁移 M1 过程

2022-06-25  本文已影响0人  欧阳蓝缺

背景

公司的项目排除三方库的代码已经超过 270 万行,且项目编译时还加了些脚本。在 MacBook Pro 16-inch i7 2.6 的电脑上在不改代码的情况下 Run 一次就得两三分钟,改几行代码就是四五分钟,对工作来说非常浪费时间。公司有同事已经换成 M1,发现速度快很多,一般在 30 秒左右。于是决定换 M1 。
换用 M1 我不想开启 Rosetta,看资料说会有些性能损耗,虽然加上这部分损耗也比 Intel 快,不过我还是想用苹果标准的方案。

环境

过程

1. 安装 brew

官网 https://brew.sh/ 的安装命令 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. 安装 cocoapods

brew install cocoapods

因 macOS Monterey 12.4 Ruby 环境的不同,使用官方 sudo gem install cocoapods 能安装成功,但有些项目 pod install 时会报错,所以使用 brew 安装。

pod install 报错问题
https://github.com/CocoaPods/CocoaPods/issues/10518

3. 安装 ccache

# 将 ccache 链接到 bin 目录
sudo ln -s /opt/homebrew/bin/ccache /usr/local/bin/ccache

4. 安装 python 2

# from distribute_setup import use_setuptools
# use_setuptools()
from setuptools import setup, find_packages

opencc-python 安装失败问题
https://blog.csdn.net/a3335581/article/details/82802820

5. 工程 Run 模拟器编译失败

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
    end
  end
end

清除 Xcode、pod 缓存后 pod install,模拟器和设备上成功 Debug 起来。

Run 模拟器编译失败问题
https://juejin.cn/post/6989958874740555789

上一篇 下一篇

猜你喜欢

热点阅读