静态页面启用swiper_在启用了位码的Swift静态库中使用C并将其集成到Swift项目中...

静态页面启用swiper

Summary

摘要

  • Create a Static Library with C and Swift in Xcode

    在Xcode中使用C和Swift创建静态库
  • Enable Bitcode on the Static Library create

    在创建静态库时启用位码
  • Distributing compiled iOS Swift static libraries

    分发已编译的iOS Swift静态库
  • Integrate the Static Library into a iOS swift application

    将静态库集成到iOS swift应用程序中

Create a Static Library with C and Swift in Xcode

在Xcode中使用C和Swift创建静态库

Open Xcode and create a new project

打开Xcode并创建一个新项目

Image for post
Static Library and Tap on Next Static Library and Tap on Next
Image for post
Enter your project details and Tap on Next
输入您的项目详细信息,然后点击下一步

Now add your C code to the project or write the C code. When you create a new C file Xcode will ask to create bridging header file, Tap on Create Bridging Header.

现在,将C代码添加到项目中或编写C代码。 当您创建一个新的C文件时,Xcode将要求创建桥接头文件,点击Create Bridging Header

Image for post

If the bridging header is not create then create a new .h file and add the file path to Objective-C Bridging header in the Target → Build Settings

如果没有创建桥接头,则创建一个新的.h文件,并将文件路径添加到Target→Build Settings中的Objective-C Bridging header中。

Image for post
Linking Bridging Header
链接桥接标题

Add all the required C header files in the bridging header which needs to be accessed in swift.

将所有必需的C头文件添加到需要快速访问的桥接头中。

Image for post

Enable Bitcode on the Static Library create

在创建静态库时启用位码

Note: Just setting Enable Bitcodeto YESin the Build Settings will not allow the application to archive

注意:仅在“构建设置”中将YES Enable Bitcode YES设置为YES ”,将不允许应用程序存档

Step 1:

第1步:

Goto Project Settings → Build Settings → Other C flags and set debug with —fembed-bitcode-marker and release with —fembed-bitcode

转到项目设置→构建设置→其他C 标志,并使用—fembed-bitcode-marker设置调试,并使用—fembed-bitcode释放

Image for post

Step 2:

第2步:

Goto Project Settings → Build Settings, click on the + sign at the top to Add User-Defined Setting

转到项目设置→构建设置,单击顶部的+号以添加用户定义的设置

Image for post

Add a new setting by nameBITCODE_GENERATION_MODE and set debug with marker and release with bitcode

通过名称BITCODE_GENERATION_MODE添加新设置 并使用marker设置调试并使用位bitcode释放

Image for post

Distributing compiled iOS Swift static libraries

分发已编译的iOS Swift静态库

Set the active scheme to Generic iOS Device and Tap on build

将活动方案设置为Generic iOS Device并点击构建

Image for post

Once the build is successful, expand Products folder, open the .a file in finder and copy both .a file and .swiftmodule folder and this can used in other project as static library

构建成功后,展开Products文件夹,在finder中打开.a文件,然后复制.a文件和.swiftmodule文件夹,这可以在其他项目中用作静态库。

Note: both .a file and .swiftmodule folder are required

注意:.a文件和.swiftmodule文件夹都是必需的

Image for post

Integrate the Static Library into a iOS swift application

将静态库集成到iOS swift应用程序中

Open an iOS application create a lib folder and add both .a file and .swiftmodule folder into the lib folder and check if the .a file is listed in Frameworks, Libraries, and Embedded Content if not add the file.

打开一个iOS应用程序,创建一个lib文件夹,并将.a文件和.swiftmodule文件夹都添加到lib文件夹中,并检查.a文件是否在Frameworks, Libraries, and Embedded Content列出,如果未添加该文件。

Image for post

Goto Target → Build Settings and check if lib folder is added to Library Search Paths and Import Paths if not add it.

转到目标→构建设置,并检查是否将lib文件夹添加到Library Search Paths ,如果未添加,则Import Paths

Image for post

Hurry!!!!!!

匆忙!!!!!!

Now you are good to go and use the Static Library inside a iOS project.

现在您可以在iOS项目中使用静态库了。

翻译自: https://medium.com/@kishorep92/consume-c-in-swift-static-library-with-bitcode-enabled-and-integrate-it-in-a-swift-project-14ddc71974df

静态页面启用swiper

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值