Convert library.a for macOSX to library.a for iOS

Viewed 110

Is there a way to convert a library that is built for macOS to a library that I can use in my iOS project. I'm getting an error in my app that follows:

/Users/edwardpizzurro/Desktop/LibreriasAlternativas/LibreriasAlternativas.xcodeproj Building for iOS, but the linked library 'libsndfile.a' was built for macOS.
1 Answers

In general, it's not possible and you have to rebuild your library specifying iOS architecture.

To get more info about your library, run

lipo -info libsndfile.a

It'll give you architectures like armv7 armv7s i386 x86_64 arm64. A default architecture for iOS is arm64, while for MacOS it's x86_64 (we are not speaking of new M1 hardware). So most probably for your libsndfile.a you'll get only x86_64.

This will mean you need to build libsndfile by yourself.

Here are releases of this lib, there's no arm64 here: https://github.com/libsndfile/libsndfile/releases

So you have to donwload the repo: https://github.com/libsndfile/libsndfile And use smth like Autotools to build it for your desired architecture.

A rough example of what you'll have to do it here: Can't cross compile C library for arm (iOS)

While it's quite specific for each library.

Related