I want to use my webrtc .a static library in swift. Can you help please? I read you can´t use static libraries in swift, is that true?
A SWIFT file is a source code file written in Swift, a programming language introduced by Apple with iOS 8 and OS X Yosemite. It is designed for writing and compiling apps and can be used with Xcode beginning with Xcode 6.
Link Static Library to your AppRight-click on your libStaticLibrary. a choose Show in Finder, copy files and put them to a created new folder which the name “lib” in the root folder of your project. Create new single view application or open your project where you want to use your library.
A static library is a collection of compiled object files combined into a single library file, that may be linked into an app or framework target just like single object files are linked.
Have you fixed this problem you asked? I meet this problem on today too, and I've fixed it just a moment. If you don't have fixed this problem, you can try the below steps:
p.s.: the 2 projects are in the same workspace (the static lib project and the App project), the static lib project is build before the app project. The workspace structure as the pic shows:
- In the static lib project, all the .h files are need add to "Build Phases/Copy Files":
- Drag the static lib product file (the .a file) to the app project, see the pic:
(path: "app project/Build Phases/Link Binary With Libraries")
*if you care about the red color mark for the .a file, you just need choose the "generic iOS device" as the build device to re-build the static lib project, and re-drag the .a to the app project(the red one can be delete)
- Set the "Library Search Path" in you app project:
this is the .a file path which the project built in: $(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/StockApp-fkjqyvsniiauxogkivalcduqeotj/Build/Products/Debug-iphoneos
- Create Bridging-Header file for your app project, and import the static lib in it, in my case I include "StaticLib/StaticLib.h" and "CommonFoundation/CommonFoundation.h":
- Add the Bridging-Header file path to "Objective-C Bridging Header" of you app project:
Then all done, you can use the functions of the static libraries now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With