【问题标题】:Is there a way to include a string in an iOS binary using the linker有没有办法使用链接器在 iOS 二进制文件中包含一个字符串
【发布时间】:2022-01-21 00:21:27
【问题描述】:

在 Go 中,我使用了这种使用 ldflags 的技术将 git sha 嵌入到二进制文件中。¹

有什么方法可以对 iOS swift 二进制文件做同样的事情吗?

我知道这个问题的答案涉及 Info.plist 和预编译 shell 脚本。它们很好,但它们也总是在我的工作区中留下一个修改过的 Info.plist 文件。

1:https://www.digitalocean.com/community/tutorials/using-ldflags-to-set-version-information-for-go-applications

【问题讨论】:

    标签: ios linker


    【解决方案1】:

    也许codesign(1) 的 --identifer 参数是您正在寻找的。从命令行:

    pushd $PROJECT_HOME; $( xcrun -f xcodebuild) build OTHER_CODE_SIGN_FLAGS="--identifier $( git log -1 --pretty=%H)"

    通过以下方式显示标识符: codesign -d -r- /path/to/binary

    另见: Codesigning in-depth https://developer.apple.com/library/archive/technotes/tn2206/_index.html

    【讨论】:

    • 这真的很有趣,但这并不是我所追求的。我希望能够在应用程序中设置任意变量的值。
    猜你喜欢
    • 1970-01-01
    • 2014-02-09
    • 2015-12-21
    • 2021-05-19
    • 2019-10-29
    • 1970-01-01
    • 1970-01-01
    • 2020-09-10
    • 2021-04-04
    相关资源
    最近更新 更多