“Include of non-modular header inside framework module” in C header of SSZipArchive

前提是你 提交于 2020-01-01 18:18:21

问题


I'm trying to use SSZipArchive objc library in my Swift iOS Project.

What I did:

  1. Created an Objective-C "Cocoa Touch Framework"
  2. Followed this guide to import SSZipArchive's objective C and C files into it.
  3. Changed all C headers to public as per this answer
  4. Change build settings to allow non-modular includes as per this answer

The framework compiles fine. I'd manage to use objective C libraries in Swift projects using this way before so I guess the steps are correct?

The problem right now is when I try do Import SSZip in my project and try to compile, it gives "Include of non-modular header inside framework module" errors for each of the C header files of SSZipArchive and I've tried all possible solutions I can find online with no success. Seems like the problem centers on zlib.h

Please help.. I'm stuck for more than a week now and I couldn't find any alternatives to unzip a file in swift.


回答1:


I got this to work. You need to move all the #includes that causes problem out from its .h file and put them in its .c file instead. After that clean and recompile and the error goes away and everything works.




回答2:


I have found one more solution how to leave zlib.h import inside headers files and have framework built successfully.

  1. Download the source code of zlib from the official site: http://www.zlib.net/ I have used the link: http://zlib.net/zlib-1.2.8.tar.gz

  2. Unzip it.

  3. Then add zlib.h and zconf.h headers to your Framework project as well as having libz.tbd linked too.

  4. Then set your zlib.h and zconf.h headers public (TARGETS settings -> Build Phases -> Headers)

  5. Build the project. Everything should be OK.

My Framework works fine after that and successfully unzips files in my iOS app.



来源:https://stackoverflow.com/questions/30820144/include-of-non-modular-header-inside-framework-module-in-c-header-of-ssziparch

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