Build a static library for iOS - specifically spatialite

拜拜、爱过 提交于 2020-01-03 17:03:05

问题


First, please forgive and point out if I am to use some other protocol for referencing another thread/post.

There was a previous thread how to compile spatialite for iOS where the top answer partly described building spatialite as a static library for iOS. The answer included the text:

"Once you've drag n drop the .a (both are required to work in the simulator AND on the real hardware), you can initialize spatialite by just invoking spatialite_init(1)."

I am guessing this is translated to some version of the following?

Xcode 4

  1. File->New->New Target->iOS->Framework & Library->Cocoa Touch Static Library

  2. Name the library - libSpatialite_TedS

  3. Drag the header files to libSpatialite_TedS -> Copy Headers (question here ... there is a spatialite.h file in the 'headers' directory of the 'spatialite2.3.1.zip' download. Then in the subdirectory 'spatialite' there is another spatialite.h that is not an identical file and is obviously needed. Do we just drag the header files from 'headers' directory, then drag the directory 'spatialite' as a directory into 'Copy Headers' area of our Xcode static library 'myNewLibrary'?)

  4. Drag the '.a files' libSPATIALITE2.3.1_arm.a & libSPATIALITE2.3.1_x86.a

  5. Shouldn't we have some '.m' files to go with these headers in the 'Compile Sources' field?

Now, without referencing the libSpatialite_TedS in my project, when I 'Command-B' to build, the project build succeeds. However, when I look for the compiled product in

/Users/Admin/Library/Developer/Xcode/DerivedData/MyProject-gutnkbwqqonzgxbcmfzzzkadqhid/Build/Products/Release-iphonesimulator

I see build's products, but they do not include libSpatialite_TedS.

Is this because the compiler is 'smart' and recognizes that none of the header/.a files are referenced in the project so it does not bother compiling them?

And, is this the correct way to go about achieving the objective of the original poster how to compile spatialite for iOS?

Many thanks, Ted S


回答1:


I was running into linker errors with the original poster too, but solved it by including libsqlite3.dylib, libstc++.dylib, and libiconv.dylib in the target.

Hope this helps!




回答2:


Ted, I believe that the .a (static library) files and headers are meant to be used in a project right away, rather than in another static library as you've described. They are the result of a project's output. I think you can find the project that built them, here:

http://lionel.gueganton.free.fr/spatialite/

And a little more on static library files:

What is a .a (as libcrypto.a) file?

EDITED

Here's another link that you might find helpful. It s a summary of the Static Library build process in iOS: http://www.icodeblog.com/2011/04/07/creating-static-libraries-for-ios/



来源:https://stackoverflow.com/questions/8360673/build-a-static-library-for-ios-specifically-spatialite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!