While it is super easy to build a swift framework and set up the dependency. It is also quite easy to build a swift static library.
This is what you will achieve after this tutorial:
Let’s get started!
In Xcode, go to File ▸ New ▸ Project ▸ iOS ▸ StaticLibrary ▸ Next, give ColorToken as Product name and choose Swift as Language then Next ▸ Create.
Build and Run.
Add the following code to ColorToken.
Build and Run.
with Objective-C and Swift Code…
Creating a Swift framework is easy, creating a hybrid framework with both Objective-C and Swift is just fun. So let’s get started and this is what you will build.
The section includes the following parts:
Open Xcode, Create a New Xcode Project ▸ iOS ▸ Framework▸ Next, give Components as Product name and choose Swift…
Using C, C++ and Objective-C frameworks in Swift apps
I did a talk in try!Swift Tokyo this year about using C, C++ and Objective-C frameworks in Swift apps. The presentation was quite concise, so I decided to write down the content in details to provide more information.
The structure of this article will be divided into:
C is 47 years old, and Swift is a new powerful open source language that has support for C. Even though it can not…
I was watching a comedy the other day and realized that this is still a thing: Some people do not know that in general Chinese and Japanese people do not understand each other if they speak their own native languages.
A lot of people may already know that the Japanese writing system consists of kanji(Chinese characters) and kana(Hiragana, Katakana). The kana was simplified from kanji, which might give the impression that Chinese and Japanese languages are very close, but actually Japanese as a language does not have a genetic relationship with Chinese. This means that Japanese is NOT descended from…
is not tricky if we know the tricks.
TL;DR Swift can not read C++ code directly, but if we wrap the C++ library into an Objective-C module using Objective C++, it will do the trick.
Xcode ->New->Project->Cocoa touch framework -> Language:Objective-C -> Next. I named my project CppDependencyTutorial.
I have a static C framework called ExampleC++Library. Drag the ExampleC++Library.xcodeproj into CppDependencyTutorial project.
Choose target CppDependencyTutorial -> general -> Linked frameworks and libraries -> Add libExampleC++Library.a.
Option 2: using module maps
TL;DR Part 1 describes how to use public header to setup C library dependencies in Swift projects. A even neater way to set up C library dependencies is to use module maps.
Xcode ->New->Project->Cocoa touch framework -> Language:Swift -> Next. I named my project CDependencyTutorial2.
I have a static C framework called ExampleCLibrary. Drag the ExampleCLibrary.xcodeproj into CDependencyTutorial2 project.
Choose target CDependencyTutorial2 -> general -> Linked frameworks and libraries -> Add libExampleCLibrary.a.
can be pretty simple.
TL;DR one simple way to set up C library dependencies is to use public header when setting up a swift project in Xcode.
Xcode ->New->Project->Cocoa touch framework -> Language:Swift -> Next. I named my project CDependencyTutorial.
I have a static C framework called ExampleCLibrary. Drag the ExampleCLibrary.xcodeproj into CDependencyTutorial project.
Choose target CDependencyTutorial -> general -> Linked frameworks and libraries -> Add libExampleCLibrary.a.
That is why sharing is caring 😀
TL;DR If you are looking for various places to stay in Japan between 2 weeks and 1 year, this might be interesting for you.
As some of you may heard from different sources, finding a place to stay for a medium to long term in Japan is not easy and it is still true today. This is mainly because of the language barriers but also because there is a lot of other requirements. …