Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header not found when adding Themis as dependency in a new development cocoapod #411

Closed
popaaaandrei opened this issue Mar 5, 2019 · 4 comments
Assignees
Labels
O-iOS 📱 Operating system: iOS

Comments

@popaaaandrei
Copy link

Issue description

I am adding Themis as a dependency in a new development cocoapod like this:
s.dependency 'themis', '0.10.3' (also tried with s.dependency 'themis/themis-openssl', '0.10.3')

I have 2 errors when trying to build the project:

  • 'soter/soter_error.h' file not found inside themis/themis_error.h line 31 (#include <soter/soter_error.h>)
  • and obviously Could not build Objective-C module 'themis' where I am importing themis

Environment info

OS: iOS 10
Cocoapods 1.5.3
Themis version: 0.10.0/2/3

Installation way: via package manager
Crypto provider: OpenSSL I think

@vixentael vixentael self-assigned this Mar 5, 2019
@vixentael vixentael added the O-iOS 📱 Operating system: iOS label Mar 5, 2019
@vixentael
Copy link
Contributor

Seems that this gonna be a long journey :)

  1. There are existing pods that use Themis as dependency pod:

https://github.com/cossacklabs/acra/blob/master/acrawriter.podspec

But note two things:

  • this is a cocoapod made from objc code
  • it sets up 'HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/themis/src" "${PODS_ROOT}/themis/src/wrappers/themis/Obj-C"' to fix header-searching issue.

So, first issue is fixed just to setting up correct HEADER_SEARCH_PATHS so Themis could find all its files.

  1. However, if you do that, you will experience next problem. If you try to create Swift framework, Xcode will try to build Swift module from objective-c files. And this is the place where rabbit hole starts.

  2. I've played a bit myself with our Swift example project in vxtl/ios-header branch. Original example is written in Swift and uses Bridging header to import Themis file. Bridging header contains very simple #import <objcthemis/objcthemis.h> that imports all needed headers, and everything is working fine.

  3. Unfortunately, when building Swift frameworks (or CocoaPod) that uses ObjC code, you can't use Bridging headers (because Apple said so), but should use modular frameworks instead.

  4. You can simulate this behavior taking above mentioned example project and write import themis inside Swift code. This makes Xcode to build Swift modular framework, and fail.

First, you see typical Xcode error message like
screen shot 2019-03-06 at 2 06 16 am

because of include non-modular header inside framework error:
screen shot 2019-03-06 at 2 01 00 am

People say, that it's a typical error, when private headers are exposed into .h files. For example, AFNetworking solved similar issue just by moving some headers into .m files.

In Themis we can't hide all headers (although this was the first thing I tried to do in objc wrapper, results can be found in vxtl/ios-header branch), but internal structure of Themis (themis, soter, openssl) has exposed headers and it's rather complicated to change it.

  1. iOS gurus suggest to build modular framework, exposing required headers in custom module.modulemap (I found good blogposts about modular frameworks, challenges in building them, more challenges and more advice and even more).

So now I'm trying to add all required headers to the modulemap.

Issue I face right now is how to support complex multi-level folder structure in modulemap, because it looks like only "flat" files are supported:

screen shot 2019-03-06 at 2 03 42 am

@vixentael
Copy link
Contributor

In Themis we can't hide all headers (although this was the first thing I tried to do in objc wrapper, results can be found in vxtl/ios-header branch)

it actually worked 😱

See updated Themis iOS wrapper code in #415, see new temporary Themis.podspec 0.10.4 in #416.

Upon confirmation, successful testing and merging, I'll push podspec officially.

@popaaaandrei
Copy link
Author

Confirm that works for me. Thank you!

@vixentael
Copy link
Contributor

@popaaaandrei themis 0.10.4 is public now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-iOS 📱 Operating system: iOS
Projects
None yet
Development

No branches or pull requests

3 participants