Chilkat iOS Swift Compile and Linking Notes

1) Add an Objective-C Bridging Header to your project.

Add a .h header file to your project named YourProject-Bridging-Header.h, and insert the following:

#import <Foundation/NSObject.h>

#import "chilkat-9.5.0-macosx-objc/include/CkoJsonObject.h"
#import "chilkat-9.5.0-macosx-objc/include/CkoXml.h"
#import "chilkat-9.5.0-macosx-objc/include/CkoZip.h"

// The import path to each Cko*.h header depends on where you downloaded/extracted the Chilkat lib.
// Import the Chilkat "Cko" classes used by your application...

2) Set the Swift Bridging Header in your Project's Build Settings.

For example:

3) Link with the Chilkat Static Library

  • libChilkatCocoa.a for MacOSX
  • libChilkatIos.a for iOS
  • libChilkatWatchOS.a for watchOS
  • libChilkatTvOS.a for tvOS

Go to your project's Build Phases (the tab located just to the right of Build Settings) and add the libChilkatCocoa.a (for MacOSX) or libChilkatIos.a (for iOS) or libChilkatWatchOS.a for watchOS, or libChilkatTvOS.a for tvOS. Do this by expanding the Link Binary with Libraries section, then click on "+" to add items, then click on the Add Other button. Navigate to the directory where the Chilkat static lib (.a) located and add it.

4) Link with -lresolv, -lpthread, and -lstdc++

In Build Settings, Add -lresolv -lpthread -lstdc++ to Other Linker Flags.

5) Note about libChilkatIos.a

The libChilkatIos.a is a Universal Static Library that contains individual static libs, one for each architecture, such as arm64, armv7s, x86_64, etc. Chilkat provides a shell script for creating the universal lib. You'll need to run this script to create the libChilkatIos.a. You may edit the to remove those architectures that are unneeded. See Building an iOS Universal Chilkat Static Library

Back to Chilkat iOS Library Downloads