问题描述
快速版本:我有一个代码库,我正在为其创建Cocoapods规格文件。它需要基于体系结构的不同编译器标志。
QUICK VERSION: I have a library of code that I'm creating a Cocoapods spec file for. It needs different compiler flags based on the architecture. Is that possible?
说明性背景:
库的文件之一包含一些ARM NEON内部函数代码。对于armv7& armv7s的标志是:
Explanatory background: One of the library's files contains some ARM NEON intrinsics code. For armv7 & armv7s the flags are:
s.compiler_flags = '-mfloat-abi=softfp', '-mfpu=neon', '-mcpu=cortex-a9'
最后一个标志在arm64上导致(完全合理的)编译错误。
The last flag causes a (totally reasonable) compile error on arm64.
Xcode在构建设置区域中支持按体系结构标记,因此直到现在需要podspec包装器时,它的构建情况都很好。
Xcode supports per-architecture flags in the Build Settings area, so this has been building fine, until now when a podspec wrapper is required.
是否可以使用每个体系结构标记配置CocoaPods规范?
Is there a way to configure a CocoaPods spec with per-architecture flags?
推荐答案
One solution, I found via Can you set architecture specific Build Settings in an .xcconfig file in Xcode 4.3?, use xcconfig:
# Common flags
s.compiler_flags = '-mfloat-abi=softfp', '-mfpu=neon'
# Per-arch flags
s.xcconfig = { 'OTHER_CFLAGS[arch=armv7]' => '$(inherited) -mcpu=cortex-a9' ,
'OTHER_CFLAGS[arch=armv7s]' => '$(inherited) -mcpu=cortex-a9'}
此处的次要CocoaPods错误,$(继承)标记加倍 Pods.xcconfig中的参数:
Minor CocoaPods bug here, the $(inherited) flag double up the parameters in the Pods.xcconfig:
OTHER_CFLAGS[arch=armv7] = $(inherited) -mcpu=cortex-a9 $(inherited) -mcpu=cortex-a9
OTHER_CFLAGS[arch=armv7s] = $(inherited) -mcpu=cortex-a9 $(inherited) -mcpu=cortex-a9
我想知道是否有更规范的方法可以通过实际的 compiler-flags
标志?
I wonder if there's a more spec-friendly way to do this via the actual compiler-flags
flag?
这篇关于每个架构标志带有CocoaPods podspec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!