简体   繁体   English

目标:TargetName和CocoaPods Podfile中的目标“TargetName”有什么区别?

[英]What's the difference between target :TargetName and target “TargetName” in CocoaPods Podfile?

Using CocoaPods, what's the difference between 使用CocoaPods,有什么区别

target :TargetName do
    # Some pods...       
end

and

target "TargetName" do
    # Some pods...       
end

The CodoaPods Podfile Syntax Reference shows the first as an example, but the pod init Terminal command creates the latter. CodoaPods Podfile语法参考以第一个为例,但pod init Terminal命令创建后者。

:TargetName denotes a Symbol while "TargetName" or 'TargetName' denotes a String . :TargetName表示符号,"TargetName"'TargetName'表示字符串

In this case, they should be pretty much equivalent. 在这种情况下,它们应该非常相同。 The value you pass to the target is probably being converted to a string internally. 传递给target值可能在内部转换为字符串。 However, the semantics of these types are very different. 但是,这些类型的语义是非常不同的。 Strings are for storing and manipulating free form text, while symbols are more like keywords, a text version of integer constants. 字符串用于存储和操作自由格式文本,而符号更像是关键字,整数常量的文本版本。

If you aren't sure which to use, you probably want a string. 如果你不确定使用哪个,你可能需要一个字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM