查看ios应用程序数据文件_通过文件设置ios和android应用程序版本

本文介绍了如何查看iOS应用程序的数据文件,并引用了一篇来源于Medium的文章,探讨通过文件来设置iOS和Android应用的版本信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

查看ios应用程序数据文件

Whenever we want to upload a new version of our app, how many times do we have to manually do it by editing the version in build.gradle for Android or Info.plist for iOS? It’s such a daunting job!

每当我们要上传应用程序的新版本时,我们必须通过编辑build.gradle适用于Android)或Info.plist适用于iOS)中的版本来手动执行build.gradle ? 这是一项艰巨的工作!

How nice would it be if it was in a text file and we could write a script that automatically updated it (and checked that update against the repo and ran all the needed steps to release the app automatically)?

如果它在文本文件中,并且我们可以编写一个脚本来自动更新它(并根据存储库检查该更新并运行所有必要步骤以自动释放该应用程序),效果会如何?

Well, here I’ll show you how we can get the app version on the file.

好吧,这里我将向您展示如何在文件中获取应用程序版本。

在Android中 (In Android)

This is relatively straightforward. In the app’s build.gradle file, set the versionName to a function name, like getVersionName().

这是相对简单的。 在应用程序的build.gradle文件中,将versionName设置为函数名称,例如getVersionName()

defaultConfig {applicationId "com.elyeproj.fileversion"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName getVersionName()}

In the same build.gradle file, write the function to read the version from a file, as shown below.

在同一build.gradle文件中,编写函数以从文件读取版本,如下所示。

static def getVersionName() {
return new File("./app/versionName").getText().trim()
}

Then, create the file accordingly. In our case, it’d be ./app/versionName. In my example code, I wrote 10.10.

然后,相应地创建文件。 在我们的例子中,它将是./app/versionName 。 在示例代码中,我编写了10.10

在iOS中 (In iOS)

We’ll need to set up the .xconfig file to get the app version.

我们需要设置.xconfig文件以获取应用程序版本。

You could do so by creating a new config file through the new-file dialog window. Select Configuration Settings File, as shown below.

您可以通过在新文件对话框窗口中创建一个新的配置文件来做到这一点。 选择配置设置文件,如下所示。

Image for post

After the file is created, write the app version to it, using a key pointing to it — e.g., APP_VERSION = 10.10 (which is the one I wrote in my code example below).

创建文件后,使用指向该文件的键将其写入应用程序版本,例如APP_VERSION = 10.10 (这是我在下面的代码示例中编写的版本)。

After that, go to the Info.plist file, and type in the key accordinglym as shown below (in my case it’s APP_VERSION).

之后,转到Info.plist文件,并相应地键入密钥,如下所示(在我的情况下为APP_VERSION )。

Image for post

Then, go to the project’s Info setting page, and head into the Configurations section to add your configuration, as shown in diagram below. Do it for both the Release and Debug versions.

然后,转到项目的“信息”设置页面,然后进入“配置”部分以添加您的配置,如下图所示。 对发行版和调试版都执行此操作。

Image for post

Lastly, you could check the version by going to the Identify section below, and you’ll see the version updated per what’s written in your config file.

最后,您可以转到下面的“标识”部分来检查版本,然后您会看到根据配置文件中写入的内容更新了版本。

Image for post

Additional notes: In the event that your config file has many variables and you’d like to separate out the version variable, you could use #include “VersionFile.xcconfig” on top of the configuration file with many variables and create another file named VersionFile.xcconfig that contains just the version variable.

附加说明:如果您的配置文件包含许多变量,并且您想分离出版本变量,则可以在配置文件顶部使用#include “VersionFile.xcconfig” ,其中包含许多变量,并创建另一个名为VersionFile.xcconfig文件VersionFile.xcconfig仅包含版本变量。

结论 (Conclusion)

With this, your Android and iOS version-name value is now in an individual file. You could write a Bash script to automatically update it and perform the necessary updating automation and release process.

这样,您的Android和iOS版本名称值现在位于单个文件中。 您可以编写一个Bash脚本来自动更新它并执行必要的更新自动化和发布过程。

You can get the code example from:

您可以从以下位置获取代码示例:

Enjoy automating!

享受自动化!

翻译自: https://medium.com/better-programming/setting-ios-and-android-app-version-through-a-file-e95cec9573b2

查看ios应用程序数据文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值