M1开发iOS问题集锦

1、Xcode启动RN报错 fsevents unavailable

安装文件监听

#清除本地原有的watchman
npm r -g watchman 
#英特尔MAC 安装
brew install watchman 
#M1芯片 安装
arch -arm64 brew install watchman  

如果失败还可以使用如下命令
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

安装时错误:
错误1:

Error: Failure while executing; `tar --extract --no-same-owner --file /Users/xxxx/Library/Caches/Homebrew/downloads/f839b337f0ac1b367e2bdd72123940432a73834db77556858cefb671c2471aba--brotli-1.0.9.big_sur.bottle.tar.gz --directory /private/tmp/d20210623-7058-5w61ky` exited with 1. Here's the output:
tar: Error opening archive: Failed to open '/Users/xxxx/Library/Caches/Homebrew/downloads/f839b337f0ac1b367e2bdd72123940432a73834db77556858cefb671c2471aba--brotli-1.0.9.big_sur.bottle.tar.gz'

替换替换homebrew-bottles

如果使用的bash终端
vim ~/.bash_profile
添加配置
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
source ~/.bash_profile

#如果使用的是zsh
vim ~/.zshrc
#添加配置
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
source ~/.zshrc
#配置完重新执行 brew install watchman

错误2:clone Homebrew失败
还有一种情况brew install watchman是clone Homebrew那个可以打开GitHub的https://github.com/Homebrew手动进入目录clone相关依赖包

#找到自己本地相关的目录地址 进入
cd /usr/local/Homebrew/Library/Taps/homebrew
#clone一下两个依赖包即可
git clone https://github.com/Homebrew/homebrew-cask
git clone https://github.com/Homebrew/homebrew-core.git

全局安装fsevents

yarn global add fsevents

brew link报错

An unexpected error occurred during the brew link step The formula built, but is not symlinked into /usr/local Permission denied @ dir_s_mkdir - /usr/local/Frameworks

### 变更文件权限
sudo chown -R $(whoami):admin /usr/local/*

2、M1 电脑 cocoapods build 报错 Undefined symbol: OBJC_CLASS$_xxx错误的解决方法:

  • 问题描述:
    M1的电脑运行时,所有pod的文件都报错,无法找到相应文件
  • 原因分析:
    是因为当前编译版本无法匹配模拟器,需要更改pod的运行的build设置才可以,一般Xcode报错 Undefined symbol: OBJC_CLASS$_xxx 时,都是找不到相应文件的路径导致,所以常规的解决办法,就是去build setting 中的文件引用Compile Sources中 重新引用文件,再次运行即可
  • 解决方案:
    1、Project -> buildSettings ->Excluded Architectures 为 arm64
    2、在 Podfile 中添加:
post_install do |installer|
    installer.pods_project.build_configurations.each do |config|
    config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
    config.build_settings['VALID_ARCHS'] = 'arm64 arm64e armv7 armv7s x86_64 i386'
    config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
    end
end

再次pod install

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容