iOS Xcode M1 运行报错

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报错.可以先将其删除

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容