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

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

青灯夜游
Release: 2022-04-06 15:29:32
forward
5350 people have browsed it

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:uniAPPis packaged using cloud compilation, that is to say,appNextiOSThe native part of the code needs to be submitted to the background ofunifor compilation. It can be understood that there is aXcoderunning environment on theuniserver. Of course, the cloud should be completed using theXcodecommand. WhenHBuilderXperforms cloud compilation, all local native libraries will be compressed and packaged to the cloud. Finally, the compiledipaDownload the package locally so it can be installed.

1. Static library settings

You can simply familiarize yourself with the project structure based on theDemodownloaded from theuniofficial 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 ofXcode, 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 as120, becauseuniconsiders 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 theunibackground.

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 developinguninative 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 theIJKMediaFrameworklibrary 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 localIJKMediaFrameworklibrary. You only need to submit themanifest.json ofHBuilderXJust checkVideoPlayerunder configuration.

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

In this way, the configuration ofmanifest.jsonofHBuilderXwill tell the cloud compiler to addIJKMediaFrameworkCome 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 underBuild 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 checkuniFar 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.afile Add it to theHBuilder-uniPluginmain project, because the self-made static library needs to import the header file, then add it toHeard Search Pathsunder theDCTestUniPluginstatic library project. Introduction of header files.

HBuilder-uniPluginMain 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,WSLUniPluginis the overall file, which can containandroidandios(it is markediosinstead ofiOSon the official website)

2. Theiosfile contains all required third-party libraries and self-made static libraries.

3 andpackage.jsonare related configurations. The internal information ofpackage.jsonwill 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 文件里,所以直接写。 ] } } }
Copy after login

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!

Related labels:
source:juejin.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
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!