当前位置:网站首页>Swift 5.0 - creation and use of swift framework
Swift 5.0 - creation and use of swift framework
2022-06-30 22:33:00 【Alex. Ling】
Swift5.0 ----Swift FrameWork The creation and use of
Let me share with you how to create FrameWork
1、 open Xcode Click on File >> New >> Project
choice iOS Create a platform , And then in Framework & Library choice Framework Create .

Here it is , My demo created Demo Engineering for SwiftFramework, After successful creation, the structure directory is shown in the following figure :

Here's what's interesting : The directory contains a .h file , Think back to what we usually use OC&Swift Bridging files are also .h file . therefore , We are porting code to SwiftFramework when , You can no longer set the bridge file path , And not in Project name -Bridging-Header.h In the document #import Each one needs to be exposed .h The file , We delete the previous bridge file directly . And then in SwiftFramework.h In this document, you can directly refer to the prompt , Add one by one and expose it Of .h File can , As shown in the figure below :

And then when we're done , Let's go again. Headers >>Public Under the catalogue NetWorkState.h Add files to , As the name suggests, it should be set as a public part to be exposed to everyone , To take effect .
When this step is completed, it is almost done , If necessary SwiftFramework Set static library or dynamic library , Go here and set it :
The above is to share with you the creation of Swift Framework The process of .
Real machine compilation
Next, I would like to share with you how to use real machine compilation ( Simulator compilation everyone should be able to , So skip ). If you use the real machine to compile and debug , We need to be able to IOS Set the compiled version according to the hosting environment of the device , This project IOS The running version is set to 10.0 Of , Convenient model compatibility . The picture below is SwiftFramework Set the real machine compilation mode , Compiled in this way SwiftFramework It can be directly called by other projects and debugged on the real machine .
Using the new version of Xcode when , establish Framework It's not Products Of this folder , We can add a dependency library at will , Then you can generate Products The file .SwiftFramework It also imports the dependent Library , Quickly generate Products file , The import method can refer to this :https://blog.csdn.net/weixin_44587801/article/details/118107780?spm=1001.2014.3001.5502
SwiftFramework After successful compilation , We can do it in Products See this file in the directory SwiftFramework, Last , We chose it , Click on the right , Click again Show in Finder

Now? , We can put this SwiftFramework.framework Add files to other swift The project used , Add here to SwiftDemo Inside , Operation as shown below :
Pay attention to is
It has to be set to Enbed & Sign,
Only in this way can we quote successfully and identify SwiftFramework.framework
Calling project , We just need to use SwiftFramework.framework Just import the header file of the page 
We're going to use SwiftFramework.framework Related classes and methods inside , We remember to start with SwiftFramework In the project, the related class files are set to Open, Related method or attribute definitions plus Public, And then to SwiftFramework Compile , Call... After the compilation is successful .
Length is longer than the , In order to share some details with you , You are welcome to pay attention to .
边栏推荐
- What is the experience of pairing with AI? Pilot vs alphacode, Codex, gpt-3
- Classic case of multithreading
- KVM IO性能测试数据
- Alibaba Kube eventer MySQL sink simple usage record
- B_ QuRT_ User_ Guide(32)
- 后疫情时代,云计算如何为在线教育保驾护航
- AtCoder Beginner Contest 257
- 总结的一些内存问题
- Two dots on the top of the latex letter
- [450. delete nodes in binary search tree]
猜你喜欢

As the public cloud market enters the deep water, can the calm Amazon cloud still sit still?

ESP8266 成为客户端和服务器

Domestic database disorder

PostgreSQL存储结构浅析

牛逼|珍藏多年的工具让我实现了带薪摸鱼自由

Deployment of microservices based on kubernetes platform

latex中 & 号什么含义?

Web APIs comprehensive case -tab column switching - dark horse programmer

Jmeter跨线程参数关联无需脚本

Using Obsidian with Hugo, markdown's local editing software is seamlessly connected with online
随机推荐
手机上怎么开股票账户?另外,手机开户安全么?
Analysis of PostgreSQL storage structure
[Android, kotlin, tflite] mobile device integration deep learning light model tflite (object detection)
Where can I find the computer device manager
【Android,Kotlin,TFLite】移动设备集成深度学习轻模型TFlite(物体检测篇)
Nansen double disk encryption giant self rescue: how to prevent the collapse of billions of dominoes
MIT博士论文 | 优化理论与机器学习实践
AtCoder Beginner Contest 257
「团队训练赛」ShanDong Multi-University Training #3
[introduction to MySQL] the first conversation · first time in the "database" Mainland
B_ QuRT_ User_ Guide(35)
Is the stock account opened in qiniu safe? How to apply for a low commission stock account?
Store Nagios monitoring information into MySQL
理想中的接口自动化项目
Coredns modifying upstream
在线客服聊天系统源码_美观强大golang内核开发_二进制运行傻瓜式安装_附搭建教程...
Femas: cloud native multi runtime microservice framework
有孚网络混合云,加速企业数字化转型升级
Domestic database disorder
How to upload binary pictures in uniapp