美文网首页
iOS Xcode M1 运行报错

iOS Xcode M1 运行报错

作者: Amuxiaomu | 来源:发表于2022-01-06 11:00 被阅读0次

M1 运行的报错
Library not found for -lPods-xxxx_Example
Undefined symbols for architecture x86_64:

如果你项目在M1 设备上打不开,那么你需要在项目里面设置一下
选择项目,TARGETS->当前TARGET->Build Settings->Architectures->Excluded Architectures->Debug 添加Any iOS Simulator SDK 值arm64


需要修改的内容

如果你是模块化开发.或者pod中的第三方库运行M1也报错.那么你也需要将你的pod中的第三方库也要修改为arm64
在podfile中添加下面代码

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
            config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
        end
    end
end

如果你在podfile中设置了第三方为project方式管理代码,那么你需要用下面的方式

platform :ios, '9.0'
# 设置project管理方式
install! 'cocoapods',
        :generate_multiple_pod_projects => true

post_install do |installer|
    installer.pod_target_subprojects.flat_map { |p| p.targets }.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
            config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
        end
    end
end

设置完成后pod install一下(可以先将pod库中文件先删除)

如果有提示XCTest.framework报错.可以先将其删除

相关文章

网友评论

      本文标题:iOS Xcode M1 运行报错

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