美文网首页iOS备忘录
Mac M1芯片导致pod库找不到的问题

Mac M1芯片导致pod库找不到的问题

作者: 独孤流 | 来源:发表于2022-02-06 00:13 被阅读0次

    前言

    因为使用需要,更换了一台M1芯片的mac电脑,在安装好各种pod、git、xcode环境后,其他项目在两台mac上都能运行模拟器,而另一个项目在intel芯片的mac电脑能正常在模拟器上运行,而在M1芯片上就会报错ld: library not found for -lPod-xxx, 查找了很多文章都没解决,然后使用真机运行就能完整运行,再查找文章发现就是M1芯片导致,需要在podfile里更新一下配置

    发现某些pod会导致这个问题,比如:pod 'Firebase/Analytics', '~>6.7.0'

    步骤一,在podfile文件里配置如下
    post_install do |installer|
      installer.pods_project.build_configurations.each do |config|
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
      end
    end
    
    步骤二,注释掉podfile里的use_frameworks!

    完整多targe的demo如下:

    platform :ios, '12.0'
    
    post_install do |installer|
      installer.pods_project.build_configurations.each do |config|
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
      end
    end
    
    
    targetsArray = ['aaa', 'bbb', 'ccc']
    targetsArray.each do |t|
      target t do
        
        pod 'AFNetworking'
        pod 'SDWebImage'
       pod 'Firebase/Analytics', '~>6.7.0'
       ....
      end
    end
    

    完整单targe的demo如下:

    platform :ios, '12.0'
    
    post_install do |installer|
      installer.pods_project.build_configurations.each do |config|
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
      end
    end
    
    
    target 'Hello' do
     # use_frameworks!
    
      # Pods for Hello
      pod 'AFNetworking'
      pod 'Firebase/Analytics', '~>6.7.0'
    
      target 'HelloTests' do
        inherit! :search_paths
        # Pods for testing
      end
    
      target 'HelloUITests' do
        # Pods for testing
      end
    
    end
    
    步骤三,Build Settings->Architectures->Excluded Architectures -> Debug->Any SDK->arm64

    如下图


    截屏2022-02-05 下午11.40.01.png

    参考:https://narlei.com/development/apple-m1-xcode-error-when-build-in-simulator/

    相关文章

      网友评论

        本文标题:Mac M1芯片导致pod库找不到的问题

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