madordie / CommonCryptoForPodspec

CommonCrypto在podspec中的使用

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CommonCryptoForPodspec

CommonCryptopodspec中的使用。其实CommonCrypto是一个常用的,其他的这样的C库同样可以采用这种方式使用。

需要的配置

.podspec中增加:

s.pod_target_xcconfig = { 'SWIFT_INCLUDE_PATHS' => '$(PODS_ROOT)/CommonCrypto/' }
s.prepare_command = <<-EOF
    if [ ! -d ./Pods/CommonCrypto ]; then
        mkdir -p ./Pods/CommonCrypto
        cat <<-EOF > ./Pods/CommonCrypto/module.modulemap
        module CommonCrypto [system] {
            header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/CommonCrypto/CommonCrypto.h"
            export *
        }
        \EOF
    fi
EOF

在需要的.swift

import CommonCrypto

需要注意

  • 有的机器/usr/include/CommonCrypto/CommonCrypto.h是不存在的😂,好坑,于是用这个"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/CommonCrypto/CommonCrypto.h目录吧。
  • 这个prepare_command的执行和.podspec有关系。也就是说只有podspec在安装的时候这个脚本才会执行,这个不变色这个脚本就不会执行。

About

CommonCrypto在podspec中的使用


Languages

Language:Swift 69.7%Language:Ruby 19.4%Language:Objective-C 10.9%