search
HomeWeb Front-enduni-appLet's talk about how the uniAPP native plug-in on iOS is packaged? (Packaging process sharing)

How is the uniAPP native plug-in packaged on iOS? The following article will talk to you about the uniAPP native plug-in packaging process on iOS. I hope it will be helpful to you!

Let's talk about how the uniAPP native plug-in on iOS is packaged? (Packaging process sharing)

The beginning of nonsense: uniAPP is packaged using cloud compilation, that is to say, app NextiOS The native part of the code needs to be submitted to the background of uni for compilation. It can be understood that there is a Xcode running environment on the uni server. Of course, the cloud should be completed using the Xcode command. When HBuilderX performs cloud compilation, all local native libraries will be compressed and packaged to the cloud. Finally, the compiled ipa Download the package locally so it can be installed.

1. Static library settings

You can simply familiarize yourself with the project structure based on the Demo downloaded from the uni official website.

Lets talk about how the uniAPP native plug-in on iOS is packaged? (Packaging process sharing)

1. HBuilder-uniPlugin main project

It can actually be roughly understood as the cloud compilation time All compilation environments of Xcode, why do you say that? You can take a look at all the dependencies of this project.

Lets talk about how the uniAPP native plug-in on iOS is packaged? (Packaging process sharing)

The number of purely local dependencies is as many as 120, because uni considers the cost of cloud compilation. If all Libraries are uploaded by developers, so the compilation resources will be heavily occupied, so the remote third-party library reserve method is adopted, which can also be learned from the uni background.

The version description of the third-party library that iOS depends on

https://nativesupport.dcloud.net.cn/AppDocs/usemodule/iOSModuleConfig/dependentLibrary

Lets talk about how the uniAPP native plug-in on iOS is packaged? (Packaging process sharing)

Therefore, when developing uni native plug-ins, you can first refer to whether there is a supported third party on the remote end to avoid compilation symbol conflicts caused by repeated imports. .

Example: For example, the plug-in requires the IJKMediaFramework library of site B (about 160M, which is really large). Then, first check whether the cloud compilation has this library,

Lets talk about how the uniAPP native plug-in on iOS is packaged? (Packaging process sharing)

It is found that it already exists. Then, at this time, there is no need to submit the local IJKMediaFramework library. You only need to submit the manifest.json of HBuilderX Just check VideoPlayer under configuration.

Lets talk about how the uniAPP native plug-in on iOS is packaged? (Packaging process sharing)

In this way, the configuration of manifest.json of HBuilderX will tell the cloud compiler to add IJKMediaFramework Come to the project.

2. DCTestUniPlugin static library project

When making a static library, you need to set up support for the static library architecture.

Set under Build Setting -> Architectures

Lets talk about how the uniAPP native plug-in on iOS is packaged? (Packaging process sharing)

## and pay attention to when compiling, Select

Any iOS Device

Lets talk about how the uniAPP native plug-in on iOS is packaged? (Packaging process sharing)

What should I do if the static library requires a third-party library?

During development, you will definitely encounter situations that require third-party library support, such as:

AFNetWorking, here first check uni Far Whether the client supports it and it is found that the corresponding static library has not been improved, then it needs to be uploaded locally.

Because the self-made static library will eventually be loaded into the environment of

APP, so the strategy for self-made static libraries to rely on third parties is to add the third-party library .a file Add it to the HBuilder-uniPlugin main project, because the self-made static library needs to import the header file, then add it to Heard Search Paths under the DCTestUniPlugin static library project. Introduction of header files.

HBuilder-uniPlugin Main project

Lets talk about how the uniAPP native plug-in on iOS is packaged? (Packaging process sharing)

##DCTestUniPlugin

Static library projectHeard Search Paths

Lets talk about how the uniAPP native plug-in on iOS is packaged? (Packaging process sharing)

2. Configure iOS native plug-inpackage.json

All functions have been developed, the next step islocal plug-in package Configuration

For specific packaging steps, please refer to the link above. The final file directory structure is as follows:

Lets talk about how the uniAPP native plug-in on iOS is packaged? (Packaging process sharing)

1, WSLUniPlugin is the overall file, which can contain android and ios (it is marked ios instead of iOS on the official website)

2. The ios file contains all required third-party libraries and self-made static libraries.

3 and package.json are related configurations. The internal information of package.json will tell the remote compilation which libraries to load and the folder locations of the libraries. Of course It also includes some configurations, such as which dynamic libraries need to be signed (although you can make your own dynamic libraries, they need to be signed).

3. package.json directory

{
    "name": "WSLUniPlugin",//插件名称
    "id": "WSLUniPlugin",//插件ID
    "version": "1.0",
    "description": "功能描述",//功能描述这里进行功能描述,添加后会在HBuilder下展示
    "_dp_type":"nativeplugin",//原生组件类型
    "_dp_nativeplugin":{
        "ios": {
            "plugins": [
                {
                    "type": "component",//插件类型,是功能组件(module)还是视图组件(component)
                    "name": "wsl-component",//在nvue文件内的标签tag
                    "class": "WSLComponent" //iOS 原生对象class,继承自 DCUniComponent
                },
            ],
            "integrateType": "framework",//自制库类型
            "hooksClass": "",这里声明 app 生命周期勾子对象,它会同时响应appDelegate 事件
            "frameworks": [
				"libAFNetworking.a",//uni远端非储备库,需要标注声明
				"Masonry.framework",//Masonry 为uni远端储备库,ios 文件夹里不需要再添加,否则编译出现符号重复错误
            ],
            "embedFrameworks": [
                "IDLFaceSDK.framework",//动态库
            ],
            "capabilities": {
                "entitlements": {
                },
                "plists": {
                }
            },
            "plists": {
            },
            "assets": [
                 "WSLUniPlugin.xcassets"//图片资源文件,这里填写的是与 ios 文件夹的相对路径,因为 WSLUniPlugin.xcassets 就在 ios 文件里,所以直接写。
            ],
            "privacies": [
            ],
            "embedSwift": false,
            "deploymentTarget": "8.0",//支持iOS版本
            "validArchitectures": [
                 "arm64"//架构
            ],
            "parameters": {
            },
            "resources": [
                "WSLUniPlugin.bundle",//这里是一些资源文件,比如 bundle,这里填写的是与 ios 文件夹的相对路径,因为 WSLUniPlugin.bundle 就在 ios 文件里,所以直接写。
            ]
        }
    }
}

The above is the basic configuration settings. Because the number of uni cloud compilations per day is limited (about 10 times), and the package size must be less than 40M, the excess number is 2 yuan per time, and the excess volume is 10 yuan per 100M. Is there a little pitfall? In this way, the cost of daily trial and error is extremely high, so I will record it here.

Recommended: "uniapp tutorial"

The above is the detailed content of Let's talk about how the uniAPP native plug-in on iOS is packaged? (Packaging process sharing). For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:掘金社区. If there is any infringement, please contact admin@php.cn delete
How do you debug issues on different platforms (e.g., mobile, web)?How do you debug issues on different platforms (e.g., mobile, web)?Mar 27, 2025 pm 05:07 PM

The article discusses debugging strategies for mobile and web platforms, highlighting tools like Android Studio, Xcode, and Chrome DevTools, and techniques for consistent results across OS and performance optimization.

What debugging tools are available for UniApp development?What debugging tools are available for UniApp development?Mar 27, 2025 pm 05:05 PM

The article discusses debugging tools and best practices for UniApp development, focusing on tools like HBuilderX, WeChat Developer Tools, and Chrome DevTools.

How do you perform end-to-end testing for UniApp applications?How do you perform end-to-end testing for UniApp applications?Mar 27, 2025 pm 05:04 PM

The article discusses end-to-end testing for UniApp applications across multiple platforms. It covers defining test scenarios, choosing tools like Appium and Cypress, setting up environments, writing and running tests, analyzing results, and integrat

What are the different types of testing that you can perform in a UniApp application?What are the different types of testing that you can perform in a UniApp application?Mar 27, 2025 pm 04:59 PM

The article discusses various testing types for UniApp applications, including unit, integration, functional, UI/UX, performance, cross-platform, and security testing. It also covers ensuring cross-platform compatibility and recommends tools like Jes

What are some common performance anti-patterns in UniApp?What are some common performance anti-patterns in UniApp?Mar 27, 2025 pm 04:58 PM

The article discusses common performance anti-patterns in UniApp development, such as excessive global data use and inefficient data binding, and offers strategies to identify and mitigate these issues for better app performance.

How can you use profiling tools to identify performance bottlenecks in UniApp?How can you use profiling tools to identify performance bottlenecks in UniApp?Mar 27, 2025 pm 04:57 PM

The article discusses using profiling tools to identify and resolve performance bottlenecks in UniApp, focusing on setup, data analysis, and optimization.

How can you optimize network requests in UniApp?How can you optimize network requests in UniApp?Mar 27, 2025 pm 04:52 PM

The article discusses strategies for optimizing network requests in UniApp, focusing on reducing latency, implementing caching, and using monitoring tools to enhance application performance.

How can you optimize images for web performance in UniApp?How can you optimize images for web performance in UniApp?Mar 27, 2025 pm 04:50 PM

The article discusses optimizing images in UniApp for better web performance through compression, responsive design, lazy loading, caching, and using WebP format.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor