iOS 应用程序中的构建信息(构建应用程序的日期/时间)
我正在寻找一种在 iOS 应用程序的构建过程中动态添加有关应用程序的信息的方法。
在测试过程中,如果能够知道我在设备上安装的应用程序是何时构建的,以及是谁构建的,那么也很高兴知道。
我设想 settings.app 中的一个部分将提供用于调试目的的基本构建信息。我不想在每次构建之前手动更新构建信息文件 - 数据应该动态生成。
I'm looking for a way to dynamically add in information about the application during the build process of an iOS application.
During testing, it would be great to know when the application I have installed on my device was built and possibly who built it would be a good to know as well.
I'm envisioning a section in settings.app that would give basic build information for debugging purposes. I don't want to have to manually update a build information file before each build - the data should be generated dynamically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以使用标准宏
__DATE__
,它会生成类似“Jun 25 1980”的字符串,当然还有正确的当前构建日期。You can also use standard macro
__DATE__
which will result string like "Jun 25 1980" of course with proper current date of build.您可以在 Xcode 中编写一个 shell 脚本构建阶段,该阶段在构建过程结束时运行。在此阶段,您可以使用
defaults
命令将数据写入任意文件。我已使用此技术写入 Info.plist 文件,但您可以写入任何您想要的文件[1]。下面是一个将当前 git 版本写入 Info.plist 的示例脚本:
您应该能够调整它以指向您想要的文件(例如您的设置包)并写入您想要的信息。
[1] 如果您写入 Info.plist,请小心,Xcode 存在一些错误,这些错误可能会阻止它在构建期间识别 Info.plist 的更改,这可能会在执行设备构建时破坏配置。
You can write a shell script build phase in Xcode that runs at the end of your build process. In this phase you can use the
defaults
command to write data to an arbitrary file. I've used this technique to write to the Info.plist file, but you can write to any file you want[1].Here's a sample script to write the current git version to Info.plist:
You should be able to adapt this to point to the file you want (e.g. your Settings bundle) and write the info you want.
[1] Be careful if you write to Info.plist, Xcode has bugs that can prevent it from realizing Info.plist changed during the build, which can break the provisioning when doing a device build.