d options parameter
target = target[:deployment_target] if target.is_a?(Hash)
current_target_definition.set_platform!(name, target)
end
def project(path, build_configurations = {})
current_target_definition.user_project_path = path
current_target_definition.build_configurations = build_configurations
end
def xcodeproj(*args)
CoreUI.warn '`xcodeproj` was renamed to `project`. Please update your Podfile accordingly.'
project(*args)
end
.......
end
end
看完 DSL的定义实现
是不是有种熟悉的味道,对于使用Cocoapods
的使用者而言,在没有接触Ruby
的情况下,依旧能够通过对Podfile
的简单配置来实现三方库的管理依赖,不仅使用的学习成本低,而且能够很容易的上手,之所以能够这么便捷,就体现出了DSL
的魅力所在。
对于**领域型语言**
的方案选用在很多不同的业务领域中都有了相关的应用,它对特定的**业务领域场景**
能够提供**高效简洁**
的实现方案,对使用者友好的同时,也能提供高质量的领域能力。**cocoapods**
就是借助Ruby强大的面向对象的脚本能力完成**Cocoa库**
管理的实现,有种偷梁换柱的感觉,为使用者提供了领域性语言,让其更简单更高效,尤其是使用者并没有感知到其本质是**Ruby**
。记得一开始使用Cocoapods
的时候,曾经一度以为它是一种新的语言,现在看来都是Cocoapods的DSL
所给我们的错觉,毕竟使用起来实在是太香了。
作者:京东零售 李臣臣
来源:京东云开发者社区 转载请注明来源