Method and system for merging xcframework into framework
By merging XCFRAMEWORK into a Framework, it solves the problem of time -consuming and labor -intensive problems when developers handle multiple XCFRAMEWORK, and achieve the effect of rapid merger and improve work efficiency.
Patent Information
- Application Number
- CN202411398631.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-01-28
Smart Images

Figure CN119376814A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer communication, and in particular to a method and system for merging xcframewrok into a framewrok. Background Art
[0002] Xcode is an integrated development environment (IDE) launched by Apple for developing macOS, iOS, iPadOS, watchOS and tvOS applications. It is one of the main tools for developing software on Apple devices. In XCode, RunScript is part of a Build Phase, which allows you to add custom scripts during the project build process. This script can be a Shell script, Python script, Ruby script, etc., which is used to perform some additional operations during the build process. iOS is a mobile operating system developed by Apple.
[0003] Simulator Architecture: refers to the iOS simulator running in Xcode. It simulates the behavior of an iOS device, but actually runs on macOS. The simulator usually uses the x86_64 or arm64 (for AppleSilicon) architecture. It does not support certain hardware features, such as cameras, sensors, etc.
[0004] Device Architecture: refers to applications running on actual iOS devices (such as iPhone and iPad). The architecture used by iOS devices is mainly ARM (such as arm64). These devices support full hardware functions and provide a real user experience.
[0005] xcFramework is a framework packaging format used in iOS and macOS development, which allows developers to combine frameworks for multiple platforms (including different architectures and operating system versions) into a single file. xcFramework was introduced to solve some common problems when sharing and distributing frameworks on multiple platforms.
[0006] The .framework file in iOS is a static library file, usually called a static link library (Static Library). It is a compiled binary file that contains a set of compiled object files (Object File) and some additional metadata information.
[0007] When developers receive xcframeworks provided by third parties, they may only be able to merge and use the frameworks of the corresponding internal architecture due to reasons such as long paths and version control. If there are multiple xcframeworks, they need to be processed repeatedly, which is time-consuming, labor-intensive and troublesome. Summary of the invention
[0008] In order to overcome the problem that when developers receive multiple xcframeworks provided by third parties, they need to repeatedly process them, which is time-consuming and labor-intensive, the purpose of the present invention is to provide a method and system for merging xcframewroks into one framewrok, which can convert the specified .xcframework library into the corresponding .framework file, so that the accessing party can easily and quickly access the provided static library content when accessing, thereby improving work efficiency.
[0009] The present invention is implemented by the following scheme:
[0010] A method for merging xcframewrok into a framewrok, the method steps are as follows:
[0011] Step 1: Prepare several .xcframework libraries that need to be processed and put them in the same directory. The xcframework libraries are set in the simulator architecture or the real machine architecture;
[0012] Step 2: Traverse all .xcframework libraries in the directory;
[0013] Step 3: Remove the arm64 architecture from the simulator architecture;
[0014] Step 4: Merge the simulator architecture with the real machine architecture;
[0015] Step 5: Output the merged architecture to the specified directory, and generate all corresponding .framework libraries in the specified directory.
[0016] Furthermore, in step 2, the corresponding input directory and output directory are specified through parameters before traversing the directory.
[0017] Furthermore, step 3 is specifically: use the lipo-remove command to remove the arm64 architecture in the simulator architecture.
[0018] Furthermore, step 4 is specifically as follows: using the lipo-create command to merge the real machine architecture and the simulator architecture into a complete architecture.
[0019] A system for merging xcframewrok into a framewrok, the system comprising: an xcframework library preparation module, a directory traversal module, a redundant architecture removal module, an architecture merging module and a framewrok output module;
[0020] The xcframework library preparation module is used to prepare several .xcframework libraries that need to be processed and put them in the same directory. The xcframework libraries are set in the simulator architecture or the real machine architecture;
[0021] The directory traversal module is used to traverse all .xcframework libraries in a directory;
[0022] The redundant architecture removal module is used to remove the arm64 architecture in the simulator architecture;
[0023] The architecture merging module is used to merge the simulator architecture with the real machine architecture;
[0024] The framewrok output module is used to output the merged architecture to a specified directory, and generate all corresponding .framework libraries in the specified directory.
[0025] Furthermore, in the directory traversal module, the corresponding input directory and output directory are specified through parameters before traversing the directory.
[0026] Furthermore, the redundant architecture removal module is specifically: use the lipo-remove command to remove the arm64 architecture in the simulator architecture.
[0027] Furthermore, the architecture merging module specifically uses the lipo-create command to merge the real machine architecture and the simulator architecture into a complete architecture.
[0028] The beneficial effects of the present invention are:
[0029] The present invention provides a method and system for merging xcframewrok into a framewrok. After the corresponding .xcframework library is obtained, the .xcframework library can be directly converted into a .framewrok file, which is convenient for the access party to access and improves work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 is a flow chart of the method of the present invention;
[0031] Figure 2 It is a structural block diagram of the system of the present invention. DETAILED DESCRIPTION
[0032] The present invention will be further described below in conjunction with the accompanying drawings.
[0033] See also Figure 1 , a method for merging xcframewrok into a framewrok, the method steps are as follows:
[0034] Step 1: Prepare several .xcframework libraries that need to be processed and put them in the same directory. The xcframework libraries are set in the simulator architecture or the real machine architecture;
[0035] Step 2: Traverse all .xcframework libraries in the directory;
[0036] Step 3: Remove the arm64 architecture from the simulator architecture;
[0037] Step 4: Merge the simulator architecture with the real machine architecture;
[0038] Step 5: Output the merged architecture to the specified directory, and generate all corresponding .framework libraries in the specified directory.
[0039] In the present invention, the simulator architecture refers to the x86_64+arm64 (Apple Silicon) architecture, and the real machine architecture refers to the arm64 architecture.
[0040] The present invention will be further described below in conjunction with a specific embodiment:
[0041] A method for merging xcframewrok into a framewrok, the method comprising the following steps:
[0042] Step S1, prepare multiple .xcframework libraries that need to be processed in advance and put them in the same directory;
[0043] After the third party provides the .xcframework library, determine which xcframeworks are needed and create a new directory to store them.
[0044] For example: create a new directory needHandleXCDir and store all .xcframework libraries in the needHandleXCDir directory, where the xcframework libraries are test1.xcframework and test2.xcframework
[0045] The libraries included in test1.xcframework and test2.xcframework are ios-arm64_x86_64-simulator and ios-arm64;
[0046] ios-arm64_x86_64-simulator refers to the simulator version of the library, the architecture is arm64+x86_64, ios-arm64 refers to the real machine version of the library, the architecture is arm64.
[0047] Step S2: At this time, it is necessary to support passing in the corresponding input directory and traversing all .xcframework libraries in the directory;
[0048] #! / bin / sh
[0049] folder_path=$1
[0050] xcframework_folders=($(find"$folder_path"-type d-name"*.xcframework"))
[0051] for folder in "${xcframework_folders[@]}"; do
[0052] echo$floder
[0053] Done
[0054] Step S3, use the lipo-remove command to remove the arm64 architecture in the simulator architecture to prevent merging problems caused by the same architecture during subsequent merging;
[0055] Corresponding part of the script
[0056] #! / bin / sh
[0057] xcframework_path=$1
[0058] framework_name=$(basename"$xcframework_path".xcframework)
[0059]
[0060] Step S4, use the lipo-create command to merge the real machine architecture and the simulator architecture into a complete architecture. The corresponding script is:
[0061]
[0062] Step S5: Store the merged architecture in the specified output directory; the complete script is as follows:
[0063]
[0064] xcframework_folders=($(find"$folder_path"-type d-name"*.xcframework"))
[0065] for folder in "${xcframework_folders[@]}"; do
[0066] comnomeXCSimAndReal$folder
[0067] Done
[0068] See also Figure 2 , a system for merging xcframewrok into a framewrok, the system comprising: an xcframework library preparation module, a directory traversal module, a redundant architecture removal module, an architecture merging module and a framewrok output module;
[0069] The xcframework library preparation module is used to prepare several .xcframework libraries that need to be processed and put them in the same directory. The xcframework libraries are set in the simulator architecture or the real machine architecture;
[0070] The directory traversal module is used to traverse all .xcframework libraries in a directory;
[0071] The redundant architecture removal module is used to remove the arm64 architecture in the simulator architecture;
[0072] The architecture merging module is used to merge the simulator architecture with the real machine architecture;
[0073] The framewrok output module is used to output the merged architecture to a specified directory, and generate all corresponding .framework libraries in the specified directory.
[0074] In one embodiment of the present invention, in the directory traversal module, the corresponding input directory and output directory are specified by parameters before traversing the directory.
[0075] In one embodiment of the present invention, the redundant architecture removal module specifically uses the lipo-remove command to remove the arm64 architecture in the simulator architecture.
[0076] In one embodiment of the present invention, the architecture merging module specifically uses the lipo-create command to merge the real machine architecture and the simulator architecture into a complete architecture.
[0077] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.
Claims
1. A method for merging xcframewrok into a framewrok, characterized in that: The method steps are as follows: Step 1: Prepare several .xcframework libraries that need to be processed and put them in the same directory. The xcframework libraries are set in the simulator architecture or the real machine architecture; Step 2: Traverse all .xcframework libraries in the directory; Step 3: Remove the arm64 architecture from the simulator architecture; Step 4: Merge the simulator architecture with the real machine architecture; Step 5: Output the merged architecture to the specified directory, and generate all corresponding .framework libraries in the specified directory.
2. A method for merging xcframewrok into a framewrok according to claim 1, characterized in that: In step 2, specify the corresponding input directory and output directory through parameters before traversing the directory.
3. A method for merging xcframewrok into a framewrok according to claim 1, characterized in that: Step 3 is as follows: Use the lipo-remove command to remove the arm64 architecture in the simulator architecture.
4. A method for merging xcframewrok into a framewrok according to claim 1, characterized in that: Step 4 is as follows: Use the lipo-create command to merge the real machine architecture and the simulator architecture into a complete architecture.
5. A system for merging xcframewrok into a framewrok, characterized in that: The system includes: an xcframework library preparation module, a directory traversal module, a redundant architecture removal module, an architecture merging module and a framewrok output module; The xcframework library preparation module is used to prepare several .xcframework libraries that need to be processed and put them in the same directory. The xcframework libraries are set in the simulator architecture or the real machine architecture; The directory traversal module is used to traverse all .xcframework libraries in a directory; The redundant architecture removal module is used to remove the arm64 architecture in the simulator architecture; The architecture merging module is used to merge the simulator architecture with the real machine architecture; The framewrok output module is used to output the merged architecture to a specified directory, and generate all corresponding .framework libraries in the specified directory.
6. A system for merging xcframewrok into a framewrok according to claim 5, characterized in that: In the directory traversal module, the corresponding input directory and output directory are specified through parameters before traversing the directory.
7. A system for merging xcframewrok into a framewrok according to claim 5, characterized in that: The redundant architecture removal module is as follows: Use the lipo-remove command to remove the arm64 architecture in the simulator architecture.
8. A system for merging xcframewrok into a framewrok according to claim 5, characterized in that: The architecture merging module is as follows: Use the lipo-create command to merge the real machine architecture and the simulator architecture into a complete architecture.