xcode info.plist 构建变量 ${PRODUCT_NAME:rfc1034identifier} 似乎完全没有记录?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5173472/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:21:53  来源:igfitidea点击:

xcode info.plist build variable ${PRODUCT_NAME:rfc1034identifier} seems completely undocumented?

iosxcodeplistrfc1034identifier

提问by Hack Saw

I'm trying to find documentation that describe the syntax and possibilities suggested by the construction ${PRODUCT_NAME:rfc1034identifier}. Obviously this turns into some version of the product name, but where is the documentation that describes how? I just grepped the entire /Developer directory, and got nothing useful.

我试图找到描述结构建议的语法和可能性的文档${PRODUCT_NAME:rfc1034identifier}。显然,这变成了产品名称的某个版本,但是描述如何使用的文档在哪里?我只是搜索了整个 /Developer 目录,但没有任何用处。

I'm not looking for the narrow definition of what happens to this particular variable, I want to know about all such modifierslike rfc1034identifier.

我不是在寻找这个特定变量会发生什么的狭义定义,我想知道所有这样的修饰符,比如rfc1034identifier.

采纳答案by Hack Saw

At long last, Apple produced some documentation on this. This is in the "Text Macros" section of the Xcode manual, as of this date.

最后,Apple 制作了一些关于此的文档。截至目前,这是在 Xcode 手册的“文本宏”部分。

Text macro format reference

文本宏格式参考

A text macro can contain any valid unicode text. It can also contain other text macros.

文本宏可以包含任何有效的 unicode 文本。它还可以包含其他文本宏。

Including other text macrosTo include another text macro, add three underscore (_) characters before and after the macro name:

包含其他文本宏要包含另一个文本宏,请在宏名称前后添加三个下划线 (_) 字符:

___<MacroName>___

Modifying text macro expansionYou can modify the final expansion of the text macro by adding one or more modifiers. Add a modifier to a text macro by placing a colon (:) at the end of the macro followed by the modifier. Add multiple modifiers by separating each one with a comma (,).

修改文本宏扩展您可以通过添加一个或多个修饰符来修改文本宏的最终扩展。通过在宏的末尾放置一个冒号 (:) 后跟修饰符来向文本宏添加修饰符。通过用逗号 (,) 分隔每个修饰符来添加多个修饰符。

<MACRO>:<modifier>[,<modifier>]…

For example, the following macro will remove the path extension from the FILENAME macro:

例如,以下宏将从 FILENAME 宏中删除路径扩展名:

FILENAME:deletingPathExtension

To turn the modified macro above into a valid C identifier, add the identifier macro:

要将上述修改后的宏转换为有效的 C 标识符,请添加标识符宏:

FILENAME:deletingPathExtension,identifier

Modifiers

修饰符

bundleIdentifier: Replaces any non-bundle identifier characters with a hyphen (-).

bundleIdentifier:用连字符 (-) 替换任何非捆绑标识符字符。

deletingLastPathComponent: Removes the last path component from the expansion string.

deleteLastPathComponent:从扩展字符串中删除最后一个路径组件。

deletingPathExtension: Removes any path extension from the expansion string.

DeletePathExtension:从扩展字符串中删除任何路径扩展。

deletingTrailingDot: Removes any trailing dots (.).

deleteTrailingDot:删除任何尾随点 (.)。

identifier: Replaces any non-C identifier characters with an underscore (_).

identifier:用下划线 (_) 替换任何非 C 标识符字符。

lastPathComponent: Returns just the last path component of the expansion string.

lastPathComponent:仅返回扩展字符串的最后一个路径组件。

pathExtension: Returns the path extension of the expansion string.

pathExtension:返回扩展字符串的路径扩展。

rfc1034Identifier: Replaces any non-rfc1034 identifier characters with a hyphen (-).

rfc1034Identifier:用连字符 (-) 替换任何非 rfc1034 标识符字符。

xml: Replaces special xml characters with the corresponding escape string. For example, less-than (<) is replaced with &lt;

xml:用相应的转义字符串替换特殊的 xml 字符。例如,小于 (<) 被替换为&lt;

TEXT MACROS

文本宏

Text macros reference

文本宏参考

COPYRIGHTA copyright string that uses the company name of the team for the project. If there is no company name, the string is blank.

COPYRIGHT使用项目团队的公司名称的版权字符串。如果没有公司名称,则字符串为空。

The example shows a copyright string when the company is set to “Apple”.

该示例显示了当公司设置为“Apple”时的版权字符串。

Copyright ? 2018 Apple. All rights reserved.

版权?2018 年苹果。版权所有。

DATEThe current date.

日期当前日期。

DEFAULTTOOLCHAINSWIFTVERSIONThe version of Swift used for the default toolchain.

DEFAULTTOOLCHAINSWIFTVERSION用于默认工具链的 Swift 版本。

FILEBASENAMEThe name of the current file without any extension.

FILEBASENAME当前文件的名称,没有任何扩展名。

FILEBASENAMEASIDENTIFIERThe name of the current file encoded as a C identifier.

FILEBASENAMEASIDENTIFIER编码为 C 标识符的当前文件的名称。

FILEHEADERThe text placed at the top of every new text file.

FILEHEADER放置在每个新文本文件顶部的文本。

FILENAMEThe full name of the current file.

FILENAME当前文件的全名。

FULLUSERNAMEThe full name of the current macOS user.

FULLUSERNAME当前 macOS 用户的全名。

NSHUMANREADABLECOPYRIGHTPLISTThe entry for the human readable copyright string in the Info.plist file of a macOS app target. The value of the macro must include the XML delimiters for the plist. For example, a valid value is:

NSHUMANREADABLECOPYRIGHTPLISTmacOS 应用程序目标的 Info.plist 文件中人类可读版权字符串的条目。宏的值必须包含 plist 的 XML 分隔符。例如,有效值为:

'''
    <key>NSHumanReadableCopyright</key>

    <string>Copyright ? 2018 Apple, Inc. All rights reserved.</string>


'''

Notice that the value includes a newline.

请注意,该值包含换行符。

ORGANIZATIONNAMEThe name for your organization that appears in boilerplate text throughout your project folder. The organization name in your project isn't the same as the organization name that you enter in App Store Connect.

ORGANIZATIONNAME在整个项目文件夹中出现在样板文本中的组织名称。您项目中的组织名称与您在 App Store Connect 中输入的组织名称不同。

PACKAGENAMEThe name of the package built by the current scheme.

PACKAGENAME当前方案构建的包的名称。

PACKAGENAMEASIDENTIFIERA C-identifier encoded version of the package name built by the current scheme.

PACKAGENAMEASIDENTIFIER当前方案构建的包名称的 C 标识符编码版本。

PRODUCTNAMEThe app name of the product built by the current scheme.

PRODUCTNAME当前方案构建的产品的应用名称。

PROJECTNAMEThe name of the current project.

PROJECTNAME当前项目的名称。

RUNNINGMACOSVERSIONThe version of macOS that is running Xcode.

RUNNINGMACOSVERSION运行 Xcode 的 macOS 版本。

TARGETNAMEThe name of the current target.

TARGETNAME当前目标的名称。

TIMEThe current time.

TIME当前时间。

USERNAMEThe login name for the current macOS user.

USERNAME当前 macOS 用户的登录名。

UUIDReturns a unique ID. The first time this macro is used, it generates the ID before returning it. You can use this macro to create multiple unique IDs by using a modifier. Each modifier returns an ID that is unique for that modifier. For example, the first time the UUID:firstPurpose modifier is used, the macro generates and returns a unique ID for that macro and modifier combination. Subsequent uses of the UUID:firstPurpose modifier return the same ID. Adding the UUID:secondPurpose modifier generates and returns a different ID that will be unique to UUID:secondPurpose, and different from the ID for UUID:firstPurpose.

UUID返回唯一 ID。第一次使用这个宏时,它会在返回之前生成 ID。您可以使用此宏通过使用修饰符来创建多个唯一 ID。每个修饰符返回一个对该修饰符唯一的 ID。例如,第一次使用 UUID:firstPurpose 修饰符时,宏生成并返回该宏和修饰符组合的唯一 ID。UUID:firstPurpose 修饰符的后续使用返回相同的 ID。添加 UUID:secondPurpose 修饰符会生成并返回一个不同的 ID,该 ID 对于 UUID:secondPurpose 是唯一的,并且不同于 UUID:firstPurpose 的 ID。

WORKSPACENAMEThe name of the current workspace. If there is only one project open, then the name of the current project.

WORKSPACENAME当前工作空间的名称。如果只有一个项目打开,则为当前项目的名称。

YEARThe current year as a four-digit number.

YEAR当前年份,为四位数。

回答by Ivan Vu?ica

By using stringsI also dug out the following things that look like they're related to :rfc1034identifier:

通过使用,strings我还挖掘了以下看起来与它们相关的东西:rfc1034identifier

  • :quote- adds backslashes before whitespaces (and more), for use in shell scripts
  • :identifier- replaces whitespace, slashes (and more) with underscores
  • :rfc1034identifier- replaces whitespace, slashes (and more) with dashes
  • :dir- don't know, observed replace with ./in some cases
  • :abs- don't know
  • :quote- 在空格(和更多)之前添加反斜杠,用于 shell 脚本
  • :identifier- 用下划线替换空格、斜线(以及更多)
  • :rfc1034identifier- 用破折号替换空格、斜线(以及更多)
  • :dir- 不知道,./在某些情况下观察到替换
  • :abs- 不知道

Exact command:

确切命令:

strings /Developer/Library/PrivateFrameworks/DevToolsCore.framework/Versions/A/DevToolsCore|grep '^:'

There are more things that look like interesting modifiers (for example, :char-range=%@), but I couldn't get these to work. There's only one example of :char-rangeon the net, and it's from a crash log for Xcode.

还有更多看起来很有趣的修饰符(例如,:char-range=%@),但我无法使它们起作用。:char-range网上只有一个例子,它来自 Xcode 的崩溃日志。

Someone asked how do we know it's a modifier specification. Well, we know because it works on multiple variables in build settings. Plist preprocessor probably uses the same mechanisms to resolve build variables as does the build system.

有人问我们怎么知道这是一个修饰符规范。嗯,我们知道,因为它适用于构建设置中的多个变量。Plist 预处理器可能使用与构建系统相同的机制来解析构建变量。

Hack Saw, if you get a response via that bug report, don't forget to keep us informed :-)

Hack Saw,如果您通过该错误报告得到回复,请不要忘记通知我们:-)

回答by Ben Lachman

Looks like you can stack these as well. The useful case floating around outthere is

看起来你也可以堆叠这些。漂浮在那里的有用案例是

com.yourcompany.${PRODUCT_NAME:rfc1034identifier:lower}

such that a product name of "Your App" becomes com.yourcompany.your-app.

这样“您的应用程序”的产品名称变为com.yourcompany.your-app.

回答by Kazuki Sakamoto

$ strings /Developer/Library/PrivateFrameworks/DevToolsCore.framework/Versions/A/DevToolsCore

PRODUCTNAME
PRODUCTNAMEASIDENTIFIER
PRODUCTNAMEASRFC1034IDENTIFIER
PRODUCTNAMEASXML

It seems that there are :identifier, :rfc1034identifier and :xml modifiers. But I have no clue except this.

似乎有 :identifier, :rfc1034identifier 和 :xml 修饰符。但除此之外我一无所知。