Method, device, electronic device and computer-readable medium for automatically packaging pre-cached data for iOS applications
Generating binary executable files through the component library of Objective-C language solves the problem of complexity and high cost of encryption and decryption in iOS application data pre-caching, and achieves the efficiency and flexibility of automated data pre-caching.
Patent Information
- Application Number
- CN202010979063.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-17
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2040-09-17
AI Technical Summary
Existing iOS application data pre-caching technology requires analysis and implementation of encryption and decryption scripts, resulting in high cost and complexity.
Generate a binary executable file through a component library based on the Objective-C language, and use this file to obtain and encrypt pre-cache data in the iOS project, avoiding the need to separately analyze the encryption script algorithm and realizing automatic pre-caching of data.
It simplifies the data encryption and decryption process, reduces costs, and achieves the efficiency and flexibility of automatically precaching data in iOS applications.
Smart Images

Figure CN112163231B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and more specifically to a method and device for automatically packaging pre-cached data for iOS applications. Background Art
[0002] Applications on mobile phones or computers usually cache some application data, such as app configuration data, static data when the app homepage is launched, js file data, etc. In order to avoid delays caused by requesting data from the server after the user opens the page, iOS applications usually pre-cache related data into ipa files, which refer to apple program application files iphone application.
[0003] Existing data pre-caching technology generally obtains data through a script by giving a JSON data file or a database file, so as to cache the data into the ipa file during packaging.
[0004] This method requires data to be encrypted through a script, so it is also necessary to analyze the algorithm of the encryption script and implement decryption through the script, which brings additional costs for analyzing the encryption algorithm and implementing the decryption script. Summary of the invention
[0005] Technical problem that the invention aims to solve
[0006] In view of this, the present invention provides a method and device for automatically packaging pre-cached data for iOS applications, which can conveniently implement encryption and decryption of pre-cached data without the need to separately analyze the encryption script algorithm and implement decryption through the script, and the implementation cost is relatively low.
[0007] Technical solutions to the problem
[0008] In order to solve the above problem, one aspect of the present invention provides a method for automatically packaging pre-cached data for an iOS application, comprising:
[0009] A binary executable file generation step, using a component library based on the Objective-C language to generate a binary executable file; and
[0010] The step of obtaining pre-cached data is to put the binary executable file into the iOS project, obtain the pre-cached data by executing the binary executable file, and archive the pre-cached data into the ipa package.
[0011] According to this solution, a binary executable file is generated by using a component library based on the Objective-C language, so that data can be encrypted using the component library based on the Objective-C language. Since the pre-cached data is also decrypted using the component library based on the Objective-C language, encryption and decryption of the pre-cached data can be easily achieved. There is no need to separately analyze the encryption script algorithm and achieve decryption through the decryption script, and the implementation cost is low.
[0012] In the above method, preferably, the step of obtaining pre-cached data specifically includes:
[0013] Configuration parameters and passing them to the shell script; and
[0014] The parameters are transferred to the binary executable file by using a shell script, and the binary executable file obtains the pre-cached data according to the parameters.
[0015] In the above method, it is further preferred that the parameters include: version number, environment parameters and application id, and the binary executable file obtains the pre-cached data required for a specific version, environment and application id according to the parameters.
[0016] Therefore, binary executable files can be used to cache business data under specific versions, environments, and application IDs into ipa packages during the automated pre-caching of data.
[0017] In the above method, preferably, the parameters are repeatedly passed to the shell script through Jenkins, and the parameters are passed to the binary executable file through the shell script, so that the pre-cached data is repeatedly requested using the binary executable file.
[0018] Thus, the binary executable file can repeatedly request the pre-cached data, so that when the pre-cached data changes, the updated pre-cached data can be obtained in time.
[0019] In the above method, preferably, the pre-cached data includes app configuration data, static data when the app homepage is started, and js file data.
[0020] In the above method, it is further preferred that, when different types of data need to be cached, a binary executable file is regenerated, the binary executable file is placed in an iOS project, and the pre-cached data is obtained by executing the binary executable file.
[0021] Therefore, even when the types of data to be cached are changed or increased, it is possible to appropriately deal with the situation by replacing the binary executable file.
[0022] Another aspect of the present invention further provides a device for automatically packaging pre-cached data for an iOS application, comprising:
[0023] A binary executable file generation module, wherein the binary executable file generation module generates a binary executable file using a component library based on the Objective-C language; and
[0024] A pre-cache data acquisition module is provided, wherein the pre-cache data acquisition module places the binary executable file into an iOS project, acquires the pre-cache data by executing the binary executable file, and archives the pre-cache data into an ipa package.
[0025] The present invention also provides an electronic device for automatically packaging pre-cached data using an iOS application, comprising:
[0026] one or more processors; and
[0027] a storage device for storing one or more programs,
[0028] When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described above.
[0029] The present invention also provides a computer-readable medium on which a program is stored. The program is executed by a processor to implement the method as described above.
[0030] Effects of the Invention
[0031] According to this solution, a binary executable file is generated by using a component library based on the Objective-C language, so that data can be encrypted using the component library based on the Objective-C language. Since the pre-cached data is also decrypted using the component library based on the Objective-C language, encryption and decryption of the pre-cached data can be easily achieved. There is no need to separately analyze the encryption script algorithm and achieve decryption through the decryption script, and the implementation cost is low. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a flowchart showing a method for automatically packaging pre-cached data for an iOS application according to a first embodiment of the present invention.
[0033] Figure 2 FIG. 4 is a flowchart showing a method for automatically packaging pre-cached data for an iOS application according to a second embodiment of the present invention.
[0034] Figure 3 It is a diagram showing the structure of an apparatus for automatically packaging pre-cached data for iOS applications according to a third embodiment of the present invention. DETAILED DESCRIPTION
[0035] Hereinafter, the method and device for automatically packaging pre-cached data for iOS applications according to the embodiments of the present invention will be described in detail with reference to the accompanying drawings. It should be noted that the present invention is not limited to the embodiments. In addition, the constituent elements in the following embodiments include elements that can be easily thought of by a person skilled in the art or substantially the same elements.
[0036] Figure 1 It is a flowchart showing a method for automatically packaging pre-cached data for an iOS application according to a first embodiment of the present invention. Figure 2 FIG. 4 is a flowchart showing a method for automatically packaging pre-cached data for an iOS application according to a second embodiment of the present invention. Figure 3 A diagram showing the structure of an apparatus for automatically packaging pre-cached data for iOS applications according to a third embodiment of the present invention.
[0037] First combine Figure 1 The method for automatically packaging pre-cached data for iOS applications according to the first embodiment of the present invention is described.
[0038] like Figure 1 As shown, a preferred embodiment of the present invention provides a method for automatically packaging pre-cached data for iOS applications. Different from the previous method for packaging pre-cached data, the method uses a component library based on the Objective-C language to implement encryption of pre-cached data. Specifically, the method includes: a binary executable file generation step S11, using a component library based on the Objective-C language to generate a binary executable file; and a step S12 of obtaining pre-cached data, placing the binary executable file generated in step S11 into an iOS project, obtaining pre-cached data by executing the binary executable file, and archiving the pre-cached data into an ipa package.
[0039] As mentioned above, in the existing technology, data is obtained through scripts, and the data is cached in ipa files when packaged. At this time, the data needs to be encrypted through a script, and in order to decrypt, it is necessary to analyze the algorithm of the encryption script and implement decryption through the decryption script, which brings additional costs for analyzing the encryption algorithm and implementing the decryption algorithm. According to the above scheme of the present invention, a component library based on the Objective-C language is used to obtain and encrypt pre-cached data. Since the encryption of pre-cached data and the decryption of pre-cached data by the iOS project are both based on the Objective-C language component library, there is no need to pay attention to the specific encryption and decryption algorithms, saving costs.
[0040] It should be noted that in the prior art, since the script language does not support embedding into the iOS system, the component library based on the Objective-C language cannot be directly called, which results in the inability to use the component library based on the Objective-C language to implement data caching. In the present invention, this defect is solved by generating a binary executable file.
[0041] The following is a detailed description of each step of the above method. Regarding the binary executable file generation step S11, specifically, first create a project (command line project) based on the macOS system through Xcode, create a podfile in the project to introduce the iOS component library (component library based on the Objective-C language), and execute the pod install command to obtain the iOS component library. Then, compile the project file to generate a binary executable file.
[0042] The binary executable file can be used to solve the defect in the prior art that the component library based on the Objective-C language cannot be directly called because the script does not support embedding into the iOS system, resulting in the inability to use the component library based on the Objective-C language to implement data encryption caching. The component library based on the Objective-C language can be used to achieve the acquisition and storage of related data. This avoids the problem in the prior art that a separate script is needed to implement encryption, and the algorithm of the encrypted script needs to be analyzed for decryption, and the implementation cost is low.
[0043] Regarding the steps of obtaining pre-cached data, specifically, first, put the binary executable file obtained by compilation into the specified directory of the iOS project, which is the project that generates the ipa package. The binary executable file initiates a network request to request server data and writes the data into the iOS project directory. Thus, the pre-cached data is obtained using the binary executable file and archived into the ipa package.
[0044] Refer to the following Figure 2 The method for automatically packaging pre-cached data for an iOS application according to the second embodiment of the present invention is described.
[0045] The method for automatically packaging pre-cached data for iOS applications in the second embodiment of the present invention repeatedly passes parameters to a shell script through Jenkins, and passes the parameters to a binary executable file through the shell script, thereby repeatedly requesting pre-cached data using the binary executable file.
[0046] It should be noted that the parameter indicates a specific version, environment, and application ID. By passing the parameter to the binary executable file, the business data corresponding to the specific version, environment, and application ID is generated into a data file and written into the iOS project directory.
[0047] Specifically, the steps of the method for automatically packaging pre-cached data using an iOS application in the second embodiment include, for example:
[0048] S21, generating a binary executable file using a component library based on the Objective-C language;
[0049] S22, putting the binary executable file into the iOS project;
[0050] S23, Jenkins configures parameters according to page operations and passes the parameters to the shell script;
[0051] S24, the shell script passes the parameters to the binary executable file and executes the binary executable file;
[0052] S25, the binary executable file requests the server for pre-cached data according to the parameters passed by the shell script;
[0053] S26, archiving the pre-cached data obtained in step S25 into the ipa package.
[0054] Among them, the iOS project directory introduces the data file generated by the pre-cached data into the project's configuration file by adding file, establishes the connection between the data file and the project, and archives the generated data file into the ipa package. The generated ipa package contains the pre-cached data obtained through the above process.
[0055] Therefore, the business data is cached in the ipa package using a component library based on the Objective-C language. Since the encryption and decryption processes use the same set of component libraries, there is no need to pay attention to the specific encryption and decryption algorithms, thus saving costs.
[0056] In the method for implementing automatic packaging of pre-cached data for iOS applications of the present invention, the binary executable file reads the service configuration file, converts the data into objects after reading the configuration data, and then traverses the data to synchronously execute different services to ensure the configurability of the services and the extensibility of the functions. If an exception is encountered during the synchronous execution, an exception will be thrown so that the user can clearly know which step and why an error occurred.
[0057] Compared with the first embodiment of the present invention, in the second embodiment, jenkins can repeatedly pass parameters to the shell script, and the shell script passes the parameters to the binary executable file, so that the binary executable file can repeatedly request pre-cached data, so that when the pre-cached data changes, the updated pre-cached data can be obtained in time.
[0058] However, when the same pre-cache data is configured for all apps, it is also possible not to pass parameters to the binary executable file, and the binary executable file can obtain the pre-cache data according to the default settings.
[0059] In addition, the shell script may be used to pass parameters to the binary executable file only once. When the pre-cached data needs to be updated, the operator reconfigures the parameters and uses the shell script to pass the parameters again.
[0060] The present invention is described below in conjunction with the implementation process in the project. In the following description, the page configuration of cache weex is taken as an example to specifically describe its implementation steps.
[0061] The present invention is mainly divided into two parts, one part is to generate a binary executable file, and the other part is to place the binary executable file in an iOS project to obtain pre-cached data. These steps are mainly performed on an RD (developer) development machine.
[0062] The following first describes the steps to generate a binary executable file.
[0063] Step S31, create a MMKVCommon Line project based on the mac system through Xcode, create a podfile file in the root directory of the project, edit the podfile file, introduce the Objective-C-based component library "MMKV" (pod'MMKV','1.0.15'), execute pod install in the terminal, obtain the component library and configure the project.
[0064] Step S32: in the above-mentioned MMKVCommon Line project, create a new business processing class YMTDefaultWeexConfigBusiness.
[0065] Pre-cached data includes, for example, app configuration data, static data when the app homepage is started, js file data, etc. When different types of pre-cached data need to be cached, different service processing classes need to be set. Therefore, in the present invention, when different types of pre-cached data need to be obtained, different binary executable files are replaced, and the binary executable files have different data processing classes, so as to cope with the situation where different types of pre-cached data need to be cached.
[0066] Step S33, executing the Xcode run instruction to compile the MMKVcommon project and generate a binary executable file.
[0067] Through the above steps, a binary executable file for obtaining pre-cached data is generated, and the binary executable file is generated based on the Objective-C component library. When obtaining pre-cached data, the Objective-C component library is used to encrypt the data, and when the app is started, the data is also decrypted based on the Objective-C component library, thus avoiding the problem of requiring a separate script to implement encryption in the prior art, and also needing to analyze the algorithm of the encrypted script for decryption, and the implementation cost is low.
[0068] When using the binary file to obtain pre-cached data, Jenkins passes the version, environment parameters, application ID and other parameters to the shell script, and the shell script passes it to the binary executable file. In the MMKVCommonLine project of step S11, the main(int argc, const char*argv[]) method is used to obtain the version, environment parameters, and application ID through the formal parameter argv[] array and store them in the singleton. Then, in YMTDefaultWeexConfigBusiness, the logic of obtaining weex-related configuration data and storing data is developed, and the link of the network request is configured according to the version, environment parameters, and application ID.
[0069] The above describes the steps of generating a binary executable file used in the method for implementing the automatic packaging of pre-cached data for iOS applications of the present invention. The following describes the steps of obtaining pre-cached data using the binary executable file.
[0070] For iOS projects, configure the business configuration MMKVBusinessConfig in the iOS project, add a user tag pre-cache data service, configure the business id as default weex config id, and the secret key as cryptKey.
[0071] Therefore, the id and secret key of the above-mentioned user tag pre-cache data service are obtained in the main method in the MMKVcommonLine project. Specifically, the MMKVCommonLine project reads the business configuration file MMKVBusinessConfig in the iOS project through a relative path, obtains the json data, and after parsing, obtains the user tag pre-cache data service id of default_weex_config and its corresponding secret key of cryptKey. According to the configuration data obtained in this step, the main method will map the id to the business processing class YMTDefaultWeexConfigBusiness created in step S32 to specifically process the relevant logic. This realizes the association between the binary executable file and the iOS project.
[0072] When actually obtaining the pre-cached data, as in the process of steps S21 to S26 above, a data file is generated and an ipa package is generated, thereby realizing automatic packaging of the pre-cached data.
[0073] The following is combined with Figure 3 The device for automatically packaging pre-cached data for iOS applications according to the third embodiment of the present invention includes:
[0074] A binary executable file generation module 100, which generates a binary executable file using a component library based on the Objective-C language; and a pre-cache data acquisition module 200, which puts the binary executable file into an iOS project, acquires pre-cache data by executing the binary executable file, and archives the pre-cache data into an ipa package.
[0075] Therefore, the business data is cached in the ipa package using a component library based on the Objective-C language. Since the encryption and decryption processes use the same set of component libraries, there is no need to pay attention to the specific encryption and decryption algorithms, thus saving costs.
[0076] The present invention also provides an electronic device for automatically packaging pre-cached data for iOS applications, comprising: one or more processors; and a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the method as described above.
[0077] The present invention also provides a computer-readable medium on which a program is stored. The program is executed by a processor to implement the method as described above.
[0078] The above is a detailed description of the method and device for automatically packaging pre-cached data for iOS applications provided by the present invention. Any changes made by those skilled in the art to the elements of the implementation scheme within the scope of the essential content of the present invention shall fall within the protection scope of the present invention.
Claims
1. A method for automatically packaging pre-cached data for an iOS application, characterized in that: include: A binary executable file generation step, using a component library based on the Objective-C language to generate a binary executable file; as well as The step of obtaining pre-cached data is to put the binary executable file into the iOS project, obtain the pre-cached data by executing the binary executable file, and archive the pre-cached data into the ipa package. When different types of data need to be cached, a binary executable file is regenerated, the binary executable file is placed in an iOS project, and the pre-cached data is acquired by executing the binary executable file.
2. The method according to claim 1, characterized in that The step of obtaining pre-cached data specifically includes: Configuration parameters and passing them to the shell script; and The parameters are transferred to the binary executable file by using a shell script, and the binary executable file obtains the pre-cached data according to the parameters.
3. The method according to claim 2, characterized in that in, The parameters include: version number, environment parameters and application ID, and the binary executable file obtains the pre-cached data required for a specific version, environment and application ID according to the parameters.
4. The method according to claim 2 or 3, characterized in that in, The parameters are repeatedly passed to the shell script through Jenkins, and the parameters are passed to the binary executable file through the shell script, so that the pre-cached data is repeatedly requested using the binary executable file.
5. The method according to claim 2 or 3, characterized in that: in, The pre-cached data includes app configuration data, static data when the app homepage is started, or js file data.
6. The method according to claim 4, characterized in that in, The pre-cached data includes app configuration data, static data when the app homepage is started, or js file data.
7. A device for automatically packaging pre-cached data for iOS applications, characterized in that: include: A binary executable file generation module, wherein the binary executable file generation module generates a binary executable file using a component library based on the Objective-C language; as well as A pre-cached data acquisition module is provided, wherein the pre-cached data acquisition module places the binary executable file into the iOS project, acquires the pre-cached data by executing the binary executable file, and archives the pre-cached data into an ipa package. When different types of data need to be cached, the binary executable file generation module regenerates the binary executable file, and the pre-cached data acquisition module puts the binary executable file into the iOS project, and acquires the pre-cached data by executing the binary executable file.
8. An electronic device for automatically packaging pre-cached data using an iOS application, characterized in that: include: one or more processors; as well as a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
9. A computer-readable medium having a program stored thereon, characterized in that: The program is executed by a processor to implement the method according to any one of claims 1 to 6.
