Home > Web Front-end > uni-app > body text

How to set the app version number in uniapp

PHPz
Release: 2023-04-18 14:20:32
Original
3715 people have browsed it

With the popularity of mobile devices, more and more companies are choosing to develop their own mobile applications. For developing mobile applications, version management is particularly important. A successful application must go through multiple versions of iterations to achieve final perfection. In uniapp, setting the application version number is crucial. Let us discuss how to set the app version number.

1. What is a version number

First, let us understand the concept of a version number. Version Number (Version Number) is the number named for the software version. It is used to identify different software versions. In different software, the version number may contain different information, but it generally contains the following basic information:

  1. Major Version Number: Generally indicates a major version update of the software, such as from V1.0 is upgraded to V2.0.
  2. Minor Version Number: Generally represents small updates and improvements, including the addition of new features, bug fixes, performance improvements, etc., such as upgrading from V1.1 to V1.2.
  3. Revision Version Number: Indicates the revision in the minor version number, usually small functional changes and bug fixes, such as upgrading from V1.1.1 to V1.1.2.
  4. Build Number: Generally used to identify the built version, including coding, testing and release, etc., for debugging or backtracking.

Therefore, the setting of version number is very important for software update and management.

2. How to set the app version number

In uniapp, setting the application version number is also very simple. Below we will introduce two commonly used setting methods.

1. Use the manifest.json file to set up

Taking generating the H5 version as an example, uniapp provides a manifest.json file, which stores the application configuration items, such as application name, Version number, icon, startup screen and other information. Therefore, the application version number can be set by modifying the version attribute in the manifest.json file.

"manifest": {

"name": "uni-app",
"short_name": "uni-app",
"description": "uni-app",
"start_url": "/",
"display": "standalone",
"orientation": "portrait",
"background_color": "#ffffff",
"theme_color": "#007aff",
"version": "1.0.0", // 设置应用版本号
"icons": [{
        "src": "/static/logo.png",
        "type": "image/png",
        "sizes": "192x192"
    },
    {
        "src": "/static/logo.png",
        "type": "image/png",
        "sizes": "512x512"
    }
],
"splash_pages": null
Copy after login

}

In the above code, the version attribute is the application version number and can be modified as needed. In the actual development process, every time the version is updated, the version number should be increased for better version management.

2. Use the build.xml file for settings

In addition to using the manifest.json file for settings, uniapp also provides a build.xml file, which can be set by modifying the configuration file. Version number setting. The specific operations are as follows:

  1. Open the build.xml file and copy the following code:

<echo message="update version..."/>
<property file="manifest.json"/>
<echo message="version: ${version}"/>
<input
    message="请输入升级后的版本号(格式:x.y.z):"
    addproperty="newVersion"
    defaultvalue="${version}"
    validargs="\d+\.\d+\.\d+"
    />
<echo message="new version:${newVersion}"/>
<replace file="manifest.json" token="\"version\":\s*\"(\d+\.\d+\.\d+)\"" value="\"version\":\"${newVersion}\""/>
<echo message="update success."/>
Copy after login

< ;/target>

  1. Call the updateVersion task at the appropriate location in the build.xml file.

...
<target name="mytask">...<target>
...
<target name="updateVersion" depends="mytask"/> // 调用updateVersion任务
...
Copy after login

  1. Execute the command to set the version number. For Windows systems, please execute the command in CMD. For MacOS and Linux systems, please execute the command in the terminal.

Windows system example:
$ gradlew.bat updateVersion

MacOS and Linux system example:
$ ./gradlew updateVersion

Among them, gradlew Is a script file used to execute gradle commands.

After executing the command, the following prompt will appear:

Configure project:
update version...
version: 1.0.0
Please enter the upgraded version number (Format: x.y.z): 1.0.1
new version: 1.0.1
update success.

Here, we can enter the version number that needs to be upgraded, and then execute the build.xml file The updateVersion task can complete the setting of the version number.

3. The meaning of the version number

When setting the version number, you need to pay attention to the specific meaning of the version number. Usually, the version number can be divided into three parts, namely the major version number, the minor version number and the revision number. The changes in each part reflect different update contents, as follows:

  1. Main Version number: Indicates major version changes of the software, usually numbers such as 1, 2, 3, etc.
  2. Minor version number: Indicates small functional changes or bug fixes, usually numbers such as 0, 1, 2, etc.
  3. Revision number: Indicates very small changes, such as bug fixes, document changes, etc., usually numbers such as 0, 1, 2, etc.

According to the above rules, we can combine version numbers, for example:

1.0.0: initial version.

2.0.0: Many new features have been added, big changes.

2.1.0: Based on the main version, many small function updates have been added.

2.1.1: Make minor revisions based on version 2.1.0.

Therefore, when setting the version number, it is necessary to combine the version number according to the actual application situation in order to better carry out version management and iteration.

Summary:

In mobile application development, version management is particularly important. uniapp provides multiple ways to set the version number. We can flexibly choose and set according to the actual situation. At the same time, we also need to understand the specific meaning of the version number in order to better carry out version management and iteration.

The above is the detailed content of How to set the app version number in uniapp. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!