当前位置:网站首页>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 .
边栏推荐
- Store Nagios monitoring information into MySQL
- JVM Part 21 of interview with big companies Q & A
- Summary of interesting websites
- B_ QuRT_ User_ Guide(34)
- Braces on the left of latex braces in latex multiline formula
- Swift5.0 ----Swift FrameWork的创建及使用
- 远程办公期间,项目小组微信群打卡 | 社区征文
- The superficial understanding of the industrial Internet finally brought the development of the industrial Internet into the strange circle of the consumer Internet
- d编译时计数
- 有孚网络混合云,加速企业数字化转型升级
猜你喜欢

Deployment of microservices based on kubernetes platform

"More Ford, more China" saw through the clouds, and the orders of Changan Ford's flagship products exceeded 10000

latex字母头顶两个点

从PG15 XID64再次跳票说起

ESP8266 成为客户端和服务器

Domestic database disorder

dba
![[BSP video tutorial] BSP video tutorial issue 19: AES encryption practice of single chip bootloader, including all open source codes of upper and lower computers (June 26, 2022)](/img/ce/9ec74c4c26513e2479df29a1802168.png)
[BSP video tutorial] BSP video tutorial issue 19: AES encryption practice of single chip bootloader, including all open source codes of upper and lower computers (June 26, 2022)

项目管理到底管的是什么?
![Flip the linked list ii[three ways to flip the linked list +dummyhead/ head insertion / tail insertion]](/img/a8/6472e2051a295f5e42a88d64199517.png)
Flip the linked list ii[three ways to flip the linked list +dummyhead/ head insertion / tail insertion]
随机推荐
Two dots on the top of the latex letter
十个最为戳心测试/开程序员笑话,念茫茫人海,该如何寻觅?
Meet the streamnational | yangzike: what made me give up Dachang offer
Go language learning notes - Gorm usage - database configuration, table addition | web framework gin (VII)
Golang application ━ installation, configuration and use of Hugo blog system
Why does the computer speed slow down after vscode is used for a long time?
Is it difficult to get a certified equipment supervisor? What is the relationship with the supervising engineer?
腾讯3年,功能测试进阶自动化测试,送给在手工测试中迷茫的你
实现多方数据安全共享,解决普惠金融信息不对称难题
2022-06-30: what does the following golang code output? A:0; B:2; C: Running error. package main import “fmt“ func main() { ints := make
理想中的接口自动化项目
What does the software test report contain? How to obtain high quality software test reports?
HDFS集中式缓存管理(Centralized Cache Management)
PostgreSQL存储结构浅析
微信小程序中的数据双向绑定
软件确认测试的内容和流程有哪些?确认测试报告需要多少钱?
AtCoder Beginner Contest 255
[introduction to MySQL] the first conversation · first time in the "database" Mainland
Strictly minor spanning tree
KVM IO性能测试数据