podfile文件解析

函数定义:

def sharedPods
    pod 'AFNetworking','3.2.0'
end

上边是用ruby定义函数的语法定义了一个sharedPods函数,里边是函数体;

源文件解析

source 'http://source.git'
platform :ios, '8.0'

target 'Demo' do
    pod 'AFNetworking'
    pod 'SDWebImage'
    pod 'Masonry'
    pod "Typeset"
    pod 'BlocksKit'
    pod 'Mantle'
    pod 'IQKeyboardManager'
    pod 'IQDropDownTextField'
end

这里的pod,plaform,pod以及target都是方法,这些方法的定义是:

def source(url)
    $hash_value['source'] = url
end

def target(target)
    targets = $hash_value['targets']
    targets = [] if targets == nil
    targets << target
    $hash_value['targets'] = targets
    yield if block_given?
end

def platform(platform, version)
end

def pod(pod)
    pods = $hash_value['pods']
    pods = [] if pods == nil
    pods << pod
    $hash_value['pods'] = pods
end

hash_value作为一个全局变量,存储podfile中的指定依赖;

你可能感兴趣的:(podfile文件解析)