sinofool / build-openssl-ios

Build openssl for iOS development, include armv7 armv7s arm64 i386 and x86_64 support.
http://sinofool.net/blog/archives/172
MIT License
124 stars 57 forks source link

Export sources to compile manually for iOS and Android #2

Closed fnc12 closed 6 years ago

fnc12 commented 7 years ago

Hi. I create crossplatform apps with C++ for iOS and Android. I have code written in C++ that is compiled with Xcode for iOS and ndk-build for android. Is there a way to add pure sources for this lib and curl? I need this because this is a way package managers work - they bring sources to project not binaries. Could you please create an additional script for this or assist me with it. I tried it by myself by had no luck. Thanks

sinofool commented 7 years ago

For iOS There is a few xcode projects I found before, just search "OpenSSL xcode" Cocospod is better if you already have it in the project. For Android, I tried ndkbuild but I failed. So I end up with this solution

I was creating a cross platform app too. I want to use the same code base for both iOS and Android core logic. After a few investigation, I choosed to compile my code and link with openssl and libcurl, which gives me a fat archive. iOS and Android both support native library, not C++ code. If given iOS app mainly created in Swift, it also need additional steps before using like Android's JNI. So I choose this solution. If you want to use different build system to build openssl/curl, you generally translating build rules from autotools/Makefile to Xcode and ndkbuild. It should be nothing blocking, just be patient.

I also wrote a lot code generators to keep business logic consistent on two platforms. More insane thing is my shared logic is about API calls to REST services. So my workflow becomes, Java Server code => C++ Client code => Java JNI Header => Java Client code. I still remember how I hated doing that.

My app finally shipped and works well. If I have to do it again, I will use swagger codegen to generate ObjC/Java for API calls, pure native. I am also trying Xamarin in my current project, which is in iOS review process. Stability is my only concerns.

sinofool commented 6 years ago

Let me know if you want more discuss about this topic.