CocoaPods podspec with per architecture flags

送分小仙女□ 提交于 2020-01-01 19:13:10

问题


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?

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'

The last flag causes a (totally reasonable) compile error on arm64.

Xcode supports per-architecture flags in the Build Settings area, so this has been building fine, until now when a podspec wrapper is required.

Is there a way to configure a CocoaPods spec with per-architecture flags?


回答1:


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'}

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

I wonder if there's a more spec-friendly way to do this via the actual compiler-flags flag?



来源:https://stackoverflow.com/questions/23943441/cocoapods-podspec-with-per-architecture-flags

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!