Swift Progress Bar Framework
This is the code example from my blog article: Wrapping a C Library in a Swift Framework. To see the creation of this project from the beginning to end, feel free to read the post!
If you like this, feel free to check out my site!
Bridging Headers are the recommended way of including C, C++, and Objective-C code in your Swift projects. However, the compiler does not allow you do this for Framework targets, which is a problem if you wish to create a Framework that wraps a C library.
This repository is an example of how to create a Swift framework that is able to call out to a C library without using Bridging Headers. Instead, it uses Clang Module Mapping.
Progressbar framework is exported by this example project. It includes one class:
Progressbar class has one initializer that takes two required parameters:
max, the text to display and the maximum value of the progress bar.
Progressbar instance responds to two methods:
increment bumps up (and animates) the progress bar by one unit.
finish completes the bar and finishes drawing.
Example Framework Usage
The Xcode project contains an Xcode Playground demonstrating usage of the module. You should see a progress bar animating over the course of 30 seconds once you open this file. If you don't see it, press ⌘-Shift-Y to ensure that the Console window is showing.