Embed OpenSSL module in Swift framework so its not needed when importing into application [duplicate] - ios

I have installed OpenSSL in xcode for receipt validation, but it doesn't work.
I download openssl.xcodeproj and openssl-1.0.1f. I extract openssl-1.0.1f and add openssl.xcodeproj to my project.
I edit the Header Search Path to :
/Users/marko/Documents/Razvoj/BIView\ Mobile\ New\ Version/openssl/include/openssl
I added libcrypto.a in Target Dependencies under Build Phases
and added libcrypto.a in Link Binary With Libraries
as was described in http://atastypixel.com/blog/easy-inclusion-of-openssl-into-iphone-app-projects/.
But when I build project it stops with error :
clang: error: no such file or directory: '/Users/ .... -bmgslnakszsfovecplbzoslykrxo/Build/Products/Debug-iphoneos/libcrypto.a'
Why ?

OK, how to build and install it....
It might be easier to use a pre-built version of OpenSSL for iOS. You can find one at this Github account. The OpenSSL from that Github are multi-arch. They have ARMv7, ARMv7s, ARM64, and i386. That means they work with devices and simulators.
Download either OpenSSL 1.0.1e or 1.0.1f. Install it in a location like /usr/local/ssl/ios.
Then, add the headers to your Xcode project. They are located in /usr/local/ssl/ios/include:
Finally, add the multi-arch libs (libcrypto.a and libssl.a) to your Xcode project. They are located in /usr/local/ssl/ios/lib:

You need to add the library as a Framework. See this question: how to add an existing framework in Xcode 5.
Its OK to add the OpenSSL libraries under Frameworks. Its how things are done under Apple/Xcode.
I use the Absolute Path like in the image below because Crypto++, OpenSSL, etc are installed in /usr/local. The image below is a screen capture I have handy of Crypto++, and not OpenSSL's libcrypto.a or libssl.a. But the same applies to all libraries.

Related

pjsua2 on ios Library not found for -lssl

Getting pjsip user agent sample project working
I have compiled the libraries for pjsip here:
pjsip ios
I have gotten android to work and I am trying to get the xcode project running for the user agent. I have compiled it against openssl. I added the user agent library and the openssl libraries to the library folder. Once done, I have one error left that I cannot seem to solve:
Showing All Errors Only
Library not found for -lssl
I am getting this even when I do not use or build against the openssl options
my openssl libs are: libcrypto.a and libssl.a once those are added, my error count goes from 111 to one. This is my first ios project so I was wondering if I missed a step adding the references.
has nothing to do with whether ssl is enabled. Some of the libraries use openssl so the project needed header and library paths. Copied the OpenSSL output I already had to the project, and it built fine
Found the answer here: Wai Ha Lee answered it.
add open ssl

Xcode9 beta - Error adding openssl & library not found for -lcrypto

I am trying to add open SSL universal via cocoapods, it's installing it but on terminal, I am getting this message
The CustomerApp [Debug] target overrides the LIBRARY_SEARCH_PATHS
build setting defined in Pods/Target Support
Files/Pods-CustomerApp/Pods-CustomerApp.debug.xcconfig. This can lead
to problems with the CocoaPods installation
- Use the $(inherited) flag, or
- Remove the build settings from the target
another problem is in XCode (9 beta) build failed with this error
library not found for -lcrypto..
I am really dying because of this, have tried everything possible but no success I tried manually adding OpenSSL by downloading from site and setting the path in build settings by doing that it doesn't show error but in my swift file when import OpenSSL it says no such module.
please help me!
I think it is looking for libcrypto.a library, can you search through your project see if it exists. When you download the OpenSSL library, it should have the library along with a bundle of header files.

how to build DLIB for iOS

I'm trying to build DLIB for an iOS project. Running the cmake results in a libdlib.a and a load of .o files.
When I add the library to an Xcode project I get warning that the library hasn't been built for arm64.
My question is two-part:
How can I build DLIB for iOS (I tried cmake **path_to_source** -DCMAKE_OSX_ARCHITECTURE="arm64" but it caused loads of errors e.g. unknown type name '__uint32_t'; did you mean '__uint128_t')?
What is the purpose of all the .o files that get built when you run cmake? Do I need to include them in an Xcode project?
I finally figured out how to do this:
Requirements
X11 (on a mac you can just open the X11 app and if X11 isn't installed it'll take you to the download).
Xcode
cmake (you can use home-brew for that)
Steps
In terminal make the lib-xx.xx/examples your root
Run:
mkdir build
cd build
cmake -G Xcode ..
cmake --build . --config Release
This will create a folder called dlib_build in which you can find an Xcode project that compiles the library. In the build settings of that Xcode project you can set the build architecture and SDK for any Xcode supported OS you like!
EDIT:
You have to include a lot of custom compiler flags and 3rd party libraries to get dlib to work in a project. Check out the examples.xcproject build settings.
To compliment RASS's answer, I am attaching screenshots showing how to change this to and from an iOS and OSX lib
After opening the project,
Select the project file from the project navigator
Select the dlib target all the way down the bottom
Select 'Build Settings'
Expand 'Base SDK' drop down
Select either iOS or macOS (OSX)
I hope this helps some people out! gl
Rob Sanders and mylogon already show how to build dlib for ios, here is how to use it:
add libdlib.a to project, and add path to library search paths
add all source to include directory(do not add to project), and add path to header search paths.
add accelerate framework, which contains blas symbols.
add preprocessor macros, from building settings, "custom compiler flag"/"other c flags". these macros make sure the header files match the lib.
-DDLIB_JPEG_SUPPORT
-DDLIB_NO_GUI_SUPPORT
-DNDEBUG
-DDLIB_USE_BLAS
-DDLIB_USE_LAPACK

Installing OpenSSL library for Xcode

I have installed OpenSSL in xcode for receipt validation, but it doesn't work.
I download openssl.xcodeproj and openssl-1.0.1f. I extract openssl-1.0.1f and add openssl.xcodeproj to my project.
I edit the Header Search Path to :
/Users/marko/Documents/Razvoj/BIView\ Mobile\ New\ Version/openssl/include/openssl
I added libcrypto.a in Target Dependencies under Build Phases
and added libcrypto.a in Link Binary With Libraries
as was described in http://atastypixel.com/blog/easy-inclusion-of-openssl-into-iphone-app-projects/.
But when I build project it stops with error :
clang: error: no such file or directory: '/Users/ .... -bmgslnakszsfovecplbzoslykrxo/Build/Products/Debug-iphoneos/libcrypto.a'
Why ?
OK, how to build and install it....
It might be easier to use a pre-built version of OpenSSL for iOS. You can find one at this Github account. The OpenSSL from that Github are multi-arch. They have ARMv7, ARMv7s, ARM64, and i386. That means they work with devices and simulators.
Download either OpenSSL 1.0.1e or 1.0.1f. Install it in a location like /usr/local/ssl/ios.
Then, add the headers to your Xcode project. They are located in /usr/local/ssl/ios/include:
Finally, add the multi-arch libs (libcrypto.a and libssl.a) to your Xcode project. They are located in /usr/local/ssl/ios/lib:
You need to add the library as a Framework. See this question: how to add an existing framework in Xcode 5.
Its OK to add the OpenSSL libraries under Frameworks. Its how things are done under Apple/Xcode.
I use the Absolute Path like in the image below because Crypto++, OpenSSL, etc are installed in /usr/local. The image below is a screen capture I have handy of Crypto++, and not OpenSSL's libcrypto.a or libssl.a. But the same applies to all libraries.

How to generate PKCS7 format signature using IOS iphone SDK?

I could Generate PKCS1 formatted raw signature.. and was able to verify it even.
But could not find the resource to generate PCKS7 Formatted Signature using IPHONE IOS SDK.
I need to sign a simple text message.
Which library I have to use?
Can we use openssl for this? if yes? then how to include it in the XCODE library framework?
Pls help out.
Yes you can use openssl for this, however you will need to compile it yourself and link your App against the static library. If you want to run it in both the iPhone Simulator and a real iPhone Device (you do), you'll need to create a 'fat' library containing both armv7 and i386 architecture code. If you want to support iPhone 3 instead then you'll need to include armv6 architecture code. It's best therefore to build the library with all 3 architectures.
Here's a couple of resources that describe how to build openssl for iOS:
http://atastypixel.com/blog/easy-inclusion-of-openssl-into-iphone-app-projects/
https://github.com/st3fan/ios-openssl
EDIT: I actually modified st3fan's build script, which I have pasted here:
setenv.sh and build_openssl.sh
Download these scripts and keep them somewhere like ~/bin (review them and then chmod them 0755 once you are sure they are not malicious).
Next edit setenv.sh as it assumes there is a directory where you will install your 3rd-party libraries. By default this is /opt/local/ioslibs so make sure that exists and is owned by you else the final bit will fail. It's been configured for Xcode 4.2/iOS SDK 5 using the default locations so that might need correcting too.
build_openssl.sh is configured to build a specific version of openssl (1.0.0e) and will download the source tarball if it's not in the current directory (you need wget for that, but if you cannot be bothered to install wget then manually download it using the link within the script). When you run it, it will build the library in armv6, armv7 and i386 arch's and copy the correct files to the installation directory.

Resources