Topic: iOS build with libwebsockets

Hi,
I'm trying to build wolfSSL and libwebsockets for iOS. For that I extended IDE/XCODE/user_settings.h with

#define OPENSSL_EXTRA
#define WOLFSSL_LIBWEBSOCKETS

and adjusted build script

WORKSPACE=$(eval "pwd")
PROJ=wolfssl.xcodeproj
CONFIG=Release
SCHEME=wolfssl_ios
CONF_BUILD_DIR=${WORKSPACE}/simulator
xcodebuild clean build -project ${PROJ} -configuration ${CONFIG} \
           -scheme ${SCHEME} -destination generic/platform=iOS \
           BITCODE_GENERATION_MODE=bitcode \
           CONFIGURATION_BUILD_DIR=${CONF_BUILD_DIR}

Build was successful and I have IDE/XCODE/simulator/libwolfssl_ios.a
But this way wolfssl/options.h is not generated and cannot be found by libwebsockets. Is it the same as user_settings.h?
Or should I better use autotools? I compiled wolfSSL for Mac with these switches:

CFLAGS='-target x86_64-apple-macos10.12'
./configure --build=arm64-apple-darwin20.3.0 --target=x86_64-apple-darwin20.3.0 --host=x86_64-apple-darwin20.3.0 --prefix=${PWD}/inst --enable-opensslextra --enable-libwebsockets 

But I doubt just changing x86_64 to armv7 will give me iOS library ...

Share

Re: iOS build with libwebsockets

Hi r-type,

You should continue to use our XCODE IDE project.  To get around the options.h issue, create an options.h file which includes your settings.h file, and make sure your IDE is set to have the preprocessor define WOLFSSL_USER_SETTINGS.  Alternatively, include user_settings.h followed by settings.h in your options.h file.

Thanks,
Kareem

Share

Re: iOS build with libwebsockets

Hi Kareem,
thanks, I'll give it a try.
I built it this way (with lws), but could not test yet if it really works:

./configure --host=arm-apple-darwin --disable-shared --prefix=${PWD}/inst --enable-opensslextra --enable-libwebsockets --enable-certgen --enable-certreq --enable-certext --enable-pkcs7 --enable-cryptocb --enable-aescfb --enable-alpn
make CC="$(xcrun --sdk iphoneos -f clang) -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -arch arm64 -miphoneos-version-min=12.5"
make install

Share

Re: iOS build with libwebsockets

Hi Kareem,
could you please point me to the missing option? I have an error with unresolved "_ToTraditionalEnc" referenced from      wolfSSL_d2i_PKCS8PrivateKey_bio in libwolfssl.a(ssl.o).
I created options.h like this

#include <IDE/XCODE/user_settings.h>
#include <wolfssl/wolfcrypt/settings.h>

And put following defines at the top of user_settings.h

#define WOLFSSL_LIBWEBSOCKETS
#define HAVE_EX_DATA
#define OPENSSL_NO_EC
#define OPENSSL_ALL
#define WOLFSSL_EITHER_SIDE
#define WC_RSA_NO_PADDING
#define WC_RSA_PSS
#define WOLFSSL_PSS_LONG_SALT
#define OPENSSL_EXTRA
#define HAVE_ALPN
#define HAVE_PKCS8

I put HAVE_ALPN to fix unresolved _wolfSSL_get0_alpn_selected.
To fix unresolved ToTraditionalEnc I put HAVE_PKCS8, but it didn't help. May be it gets overridden somewhere else...

Thanks,
Roman

Share

Re: iOS build with libwebsockets

#define HAVE_PKCS8

is not needed. I fixed it with commenting out #define NO_PWDBASED

Share