Methods and plugins for automatically detecting unimplemented functions based on the Xcode protocol.
By parsing the configuration files of the Xcode project, it automatically detects unimplemented protocol functions, solving the problem of low efficiency in protocol function detection in iOS development and improving development efficiency and accuracy.
Patent Information
- Application Number
- CN202111620818.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2041-12-28
AI Technical Summary
In iOS application development, as the number of protocols increases, it becomes difficult to efficiently identify and detect unimplemented protocol functions, leading to low development efficiency and a high risk of errors.
Automated detection is achieved by obtaining the configuration file of the Xcode project, parsing the class and protocol data, calculating the array of unimplemented protocol functions, and outputting it in JSON format.
It enables efficient and accurate detection of unimplemented protocol functions, reduces human error, lowers maintenance difficulty and cost, and improves code readability.
Smart Images

Figure CN114398024B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer software technology, and in particular to a method and plugin for automatically detecting unimplemented functions based on the Xcode protocol. Background Technology
[0002] In iOS application development, protocol-oriented development is widely favored by developers due to its characteristics of loose coupling, high readability, and easy extensibility. It occupies an important position in component-based team development.
[0003] However, with each version iteration of the app, the number of protocols keeps increasing. Some of these protocols are mandatory, while others are optional. When the number of protocols balloons to a certain level, even the original code author may not know which protocols are implemented and which are not. This is even more difficult for other team members who need to integrate these protocols. Furthermore, when multiple products need to integrate different versions, it becomes even more overwhelming, causing significant development difficulties. In summary, the main pain points are as follows:
[0004] 1. When multiple projects are interfacing with different versions of protocols, it is impossible to efficiently obtain the protocol that needs to be implemented.
[0005] 2. It is not possible to intuitively obtain the required and optional protocols;
[0006] 3. Developers can also obtain unimplemented protocols by comparing documentation and code, but this is time-consuming and prone to errors. Summary of the Invention
[0007] (a) Technical problems to be solved
[0008] To address the aforementioned problems in the prior art, this invention provides a method and plugin for automatically detecting unimplemented protocol functions based on Xcode. This method is highly efficient, saves time and development costs, and offers high accuracy and good code readability.
[0009] (II) Technical Solution
[0010] To achieve the above objectives, the present invention adopts the following technical solution:
[0011] The method based on Xcode's automated detection protocol for unimplemented functions includes the following steps:
[0012] S1. Retrieve the configuration file of the Xcode project currently in the foreground;
[0013] S2. Parse the configuration file to obtain all class and protocol data for the project;
[0014] S3. Calculate the array of unimplemented protocol functions based on all class and protocol data, and output it in JSON format.
[0015] To achieve the above objectives, another technical solution adopted by the present invention is as follows:
[0016] A plugin that automatically detects unimplemented functions in the Xcode automation protocol performs the following steps:
[0017] S1. Retrieve the configuration file of the Xcode project currently in the foreground;
[0018] S2. Parse the configuration file to obtain all class and protocol data for the project;
[0019] S3. Calculate the array of unimplemented protocol functions based on all class and protocol data, and output it in JSON format.
[0020] (III) Beneficial Effects
[0021] The beneficial effects of this invention are as follows: By obtaining the configuration file of the Xcode project currently in the foreground; parsing the configuration file to obtain all the class and protocol data of the project; calculating an array of unimplemented protocol functions based on all the class and protocol data, and outputting it in JSON format, this invention achieves automated detection of unimplemented protocol functions. It is highly efficient and time-saving, reduces development costs, minimizes functions missed due to human error, reduces trial and error and maintenance costs, has high accuracy, and stores the code uniformly in a designated area for easy viewing and modification, reducing maintenance difficulty and time, and providing good code readability. Attached Figure Description
[0022] Figure 1 This is a flowchart of a method for detecting unimplemented functions based on the Xcode automated detection protocol, according to an embodiment of the present invention. Detailed Implementation
[0023] To better explain and facilitate understanding of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0024] Example 1
[0025] Please refer to Figure 1 A method for automatically detecting unimplemented functions based on the Xcode protocol, including the following steps:
[0026] S1. Retrieve the configuration file of the Xcode project currently in the foreground;
[0027] Step S1 is as follows:
[0028] Retrieves the configuration file of the currently foreground Xcode project using an AppleScript.
[0029] The configuration file can be used to directly specify a list of protocol names to be detected, specify the directories to be detected, or recursively traverse all protocols in all subdirectories.
[0030] S2. Parse the configuration file to obtain all class and protocol data for the project;
[0031] Step S2 is as follows:
[0032] S21. Receive the directory of binary files to be compiled and output, specified by the user according to the configuration file;
[0033] S22. Parse the binary file according to the binary file directory to obtain all the class and protocol data of the project.
[0034] S3. Calculate the array of unimplemented protocol functions based on all class and protocol data, and output it in JSON format.
[0035] Step S3 is as follows:
[0036] S31. Filter out all classes that conform to the target protocol array and obtain a list of functions that have been implemented in the class;
[0037] S32. After taking the intersection of all functions in the protocol data with the list of implemented functions in the class, and then taking the difference, the array of unimplemented functions is obtained.
[0038] S33. After beautifying the array of unimplemented functions using JSON format, output it to a newly created folder and automatically open the file.
[0039] Example 2
[0040] The difference between this embodiment and Embodiment 1 is that this embodiment will further explain how the above-mentioned method for detecting unimplemented functions in the Xcode automated detection protocol is implemented in conjunction with a specific application scenario:
[0041] Preliminary preparations:
[0042] 1. Download and install the plugin on your Mac system, and then check the plugin in Settings - Extensions to authorize its use;
[0043] 2. Set a custom keyboard shortcut for the plugin in the Xcode compiler for quick plugin launch;
[0044] 3. Add a configuration file to the project. The configuration file can directly specify the list of protocol names to be detected, specify the directory to be detected, or recursively traverse all protocols in all subdirectories.
[0045] Specific implementation:
[0046] 1. Actively trigger the plugin via keyboard shortcuts or buttons;
[0047] 2. This plugin retrieves the configuration file of the currently foreground Xcode project using AppleScript.
[0048] 3. The plugin will pop up a configuration file selection box for developers to choose from;
[0049] 4. Receive the directory of binary files to be compiled and output, as specified by the developer according to the configuration file;
[0050] 5. Parse the binary files according to the binary file directory to obtain all the class and protocol data of the project;
[0051] 6. Filter out all classes that conform to the target protocol array, and obtain a list of functions that have been implemented in the class;
[0052] 7. Calculate the array of unimplemented functions by taking the intersection of each function in the protocol data with the list of implemented functions in the class, and then taking the difference.
[0053] 8. After formatting the array of unimplemented functions into JSON format, output it to a newly created folder and automatically open the file to facilitate developers' viewing and modification of the code, reducing maintenance difficulty and time.
[0054] Example 3
[0055] This plugin is based on the Xcode automation detection protocol and does not implement functions. It implements the steps in Example 1.
[0056] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A method for detecting non-implemented functions based on Xcode automation protocol, characterized in that, The method comprises the steps of: S1, obtaining a configuration file of an Xcode project currently in the foreground; S2, parsing the configuration file to obtain all class and protocol data of the project; S3, calculating an array of unimplemented protocol functions based on all the class and protocol data, and outputting the array in JSON format; Step S3 is specifically: S31, screening all classes that follow the target protocol array to obtain a list of implemented functions in the classes; S32, taking the intersection of all functions in the protocol data with the list of implemented functions in the classes, and then taking the difference set to calculate an array of unimplemented functions; S33, beautifying the array of unimplemented functions in JSON format, and outputting the array to a newly created folder and automatically opening the file.
2. The method for detecting non-implemented functions based on Xcode automation protocol according to claim 1, wherein, Step S1 is specifically: Obtaining the configuration file of the Xcode project currently in the foreground through an AppleScript script.
3. The method for detecting non-implemented functions based on Xcode automation protocol of claim 1, wherein, The configuration file is a list of protocol names that need to be detected, a directory that needs to be detected, or all protocols that will recursively traverse all subdirectories.
4. The method for detecting non-implemented functions based on Xcode automation protocol according to claim 1, wherein, Step S2 is specifically: S21, receiving a binary file directory to be compiled and output specified by the user according to the configuration file; S22, parsing the binary file based on the binary file directory to obtain all class and protocol data of the project.
5. A plug-in for Xcode automated detection protocol based on unimplemented functions, characterized in that, The plug-in implements the following steps: S1, obtaining a configuration file of an Xcode project currently in the foreground; S2, parsing the configuration file to obtain all class and protocol data of the project; S3, calculating an array of unimplemented protocol functions based on all the class and protocol data, and outputting the array in JSON format; Step S3 is specifically: S31, screening all classes that follow the target protocol array to obtain a list of implemented functions in the classes; S32, taking the intersection of all functions in the protocol data with the list of implemented functions in the classes, and then taking the difference set to calculate an array of unimplemented functions; S33, beautifying the array of unimplemented functions in JSON format, and outputting the array to a newly created folder and automatically opening the file.
6. The Xcode automation detection protocol unimplemented function based plug-in of claim 5, wherein, Step S1 is specifically: Obtaining the configuration file of the Xcode project currently in the foreground through an AppleScript script.
7. The plug-in for Xcode automation detection protocol unimplemented function based on claim 5, characterized in that, The configuration file is a list of protocol names that need to be detected, a directory that needs to be detected, or all protocols that will recursively traverse all subdirectories.
8. The plug-in for detecting non-implemented functions based on Xcode automation protocol according to claim 5, wherein, Step S2 is specifically: S21, receiving a binary file directory to be compiled and output specified by the user according to the configuration file; S22, parsing the binary file based on the binary file directory to obtain all class and protocol data of the project.