Using a open source C library (GRIB API) in a iOS project

812 Views Asked by At

I'm a fairly new iOS developer and am currently struggling with a problem regarding a C library that I want to include in my app. The library is called GRIB-API and can be found here: https://software.ecmwf.int/wiki/display/GRIB/Home. It's an open source library used to parse GRIB-files which is something I want to do in my app. My first attempt at including this library was to compile with the proper architectures (arm7 and so on), link it with the project and include the binary in the bundle but I couldn't get that to work. I've also tried creating a static library from the source code but not had much success there either.

So, my question is, what is the best and easiest way of using an open source C library in a iOS project?

2

There are 2 best solutions below

3
On

Add (drag-drop) the GRIB-API source tree to your iOS app's Xcode project. Adding it to your project makes sure you have all iOS build options set right all time. Of course you would need to add the GRIB-API specific compiler/linker options to your Build Settings.

You could add it to an External/ directory inside your Xcode project directory, and have an External group in your project. Or any other place of course; but it's a good idea to keep things together, because of the closer integration.

To see what options you need: Build it outside Xcode in the regular way, and see what's being done. You may need to switch on verbose mode on the build script/...; I did not look at GRIB-API so this is general guidance. Or of course, peek into the build script(s).

0
On

Please see this link:GRIB Library Link. I got luck to read GRIB file and able to run project on simulator, But same code is not running on device. May be this will help you.