From 0dbedf9ff2e58a2a680c8dffb53f462240b9cfca Mon Sep 17 00:00:00 2001 From: Andreas Unterhuber Date: Mon, 17 May 2021 09:55:25 +0200 Subject: [PATCH 1/3] Update Readme how to build for iOS --- INSTALL_IOS.md | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/INSTALL_IOS.md b/INSTALL_IOS.md index 881b2085..13d9607c 100644 --- a/INSTALL_IOS.md +++ b/INSTALL_IOS.md @@ -1,33 +1,15 @@ ## iOS -### Option 1: Cocoapods +### Option 1: Create your static library or download precompiled version -``` -pod 'SocketIO-Client-CPP' -``` - -### Option 2: Create a static library - -1. Create a static library -1. Copy the header files into xcode - -Use the static libraries generated by the example project [iOS example project](examples/iOS) +Follow the recent tutorial under https://github.com/kim-company/socket.io-client-cpp-ios-static to build from scrattch or download precompiled versions. -Create one for -- release iphoneos -- release simulator -- debug iphoneos -- debug simulator - -Join the debug libraries and the release libraries with e.g. +### Option 2: Cocoapods +__Note__: this is the outdated version 1.6.1. ``` -libtool -static -o libUniversalRelease.a Release-iphoneos/libsioclient.a Release-iphonesimulator/libsioclient.a -libtool -static -o libUniversalDebug.a Debug-iphoneos/libsioclient.a Debug-iphonesimulator/libsioclient.a +pod 'SocketIO-Client-CPP' ``` - -### Option 3: Manual integration - -Use this [shell](https://gist.github.com/melode11/a90114a2abf009ca22ea) to download and build boost completely automattically. It installs boost to `/prefix`. - -See the [iOS example project](examples/iOS) for how to integrate the rest. +### Notes +* See the [iOS example project](examples/iOS) for how to integrate the rest. +* Since commit https://github.com/socketio/socket.io-client-cpp/commit/af68bf3067ab45dc6a53261284e0da9afd21b636 the boost library is not needed anymore. From 11424bf1c7de08d357ce3a556fb0c6828da2723f Mon Sep 17 00:00:00 2001 From: Andreas Unterhuber Date: Mon, 17 May 2021 10:07:33 +0200 Subject: [PATCH 2/3] Update example readme --- examples/iOS/README.md | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/examples/iOS/README.md b/examples/iOS/README.md index 21efc10f..1d86644d 100644 --- a/examples/iOS/README.md +++ b/examples/iOS/README.md @@ -1,6 +1,6 @@ -#SIOClient iOS chat room demo +# SIOClient iOS chat room demo ## What is this -This is a iOS project run on xcode 6, you can use this single view application chatting in the official [chat room demo](https://github.com/Automattic/socket.io/tree/master/examples/chat). +This is a iOS project run on Xcode, you can use this single view application chatting in the official [chat room demo](https://github.com/Automattic/socket.io/tree/master/examples/chat). ## How to setup Suppose you're using your Mac's shell, under your workspace folder, run @@ -11,12 +11,8 @@ Step in the demo folder ```shell cd ./socket.io-client-cpp/examples/iOS/SioChatDemo ``` -you will see a shell script named `boost.sh` under folder `boost`,Run -```shell -cd ./boost -bash ./boost.sh -``` -Please stand by with patient, this step will take about one or two hours depends on your network. +Follow [Build&Download for iOS](https://github.com/socketio/socket.io-client-cpp/blob/master/INSTALL_IOS.md) how to get the compiled version of socket.io-client-cpp for iOS. + When done, open `SioChatDemo.xcodeproj` file in the parent folder with xcode. Just compile and run the `SioChatDemo` target. Now, if you have your chat room server run on your local machine, you can chat with device to device or device to web. @@ -24,8 +20,3 @@ Now, if you have your chat room server run on your local machine, you can chat w ## Use sioclient as static lib on iOS There's a target named `sioclient` in the Demo project, That is the exactly right config for buiding the `sioclient` as a static library on iOS. With the static library file `libsioclient.a` and two exported headers `sio_client.h` and `sio_message.h`, you won't need to config anything again and again in your integrating projects. - -## About the `boost.sh` -The `boost.sh` is copied from [boostmake_ios](https://github.com/alist/boostmake_ios),it is worked on my machine for boost 1.55.0 -there're lot's versions of boost build shells, you can choose what you like. - From 89df9544ae0b4e1fd510d007cd9ef83de39ee244 Mon Sep 17 00:00:00 2001 From: Andreas Unterhuber Date: Mon, 17 May 2021 10:07:55 +0200 Subject: [PATCH 3/3] Remove not necessary script --- examples/iOS/SioChatDemo/boost/.gitignore | 4 - examples/iOS/SioChatDemo/boost/boost.sh | 378 ---------------------- 2 files changed, 382 deletions(-) delete mode 100644 examples/iOS/SioChatDemo/boost/.gitignore delete mode 100644 examples/iOS/SioChatDemo/boost/boost.sh diff --git a/examples/iOS/SioChatDemo/boost/.gitignore b/examples/iOS/SioChatDemo/boost/.gitignore deleted file mode 100644 index 5cf83bfb..00000000 --- a/examples/iOS/SioChatDemo/boost/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -ios/* -osx/* -src/* -boost_* diff --git a/examples/iOS/SioChatDemo/boost/boost.sh b/examples/iOS/SioChatDemo/boost/boost.sh deleted file mode 100644 index 808430f2..00000000 --- a/examples/iOS/SioChatDemo/boost/boost.sh +++ /dev/null @@ -1,378 +0,0 @@ -#=============================================================================== -# Filename: boost.sh -# Author: Pete Goodliffe -# Copyright: (c) Copyright 2009 Pete Goodliffe -# Licence: Please feel free to use this, with attribution -# Modified version -#=============================================================================== -# -# Builds a Boost framework for the iPhone. -# Creates a set of universal libraries that can be used on an iPhone and in the -# iPhone simulator. Then creates a pseudo-framework to make using boost in Xcode -# less painful. -# -# To configure the script, define: -# BOOST_LIBS: which libraries to build -# IPHONE_SDKVERSION: iPhone SDK version (e.g. 5.1) -# -# Then go get the source tar.bz of the boost you want to build, shove it in the -# same directory as this script, and run "./boost.sh". Grab a cuppa. And voila. -#=============================================================================== - -: ${BOOST_LIBS:="random regex graph random chrono thread signals filesystem system date_time"} -: ${IPHONE_SDKVERSION:=`xcodebuild -showsdks | grep iphoneos | egrep "[[:digit:]]+\.[[:digit:]]+" -o | tail -1`} -: ${OSX_SDKVERSION:=10.8} -: ${XCODE_ROOT:=`xcode-select -print-path`} -: ${EXTRA_CPPFLAGS:="-DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS -std=c++11 -stdlib=libc++"} - -# The EXTRA_CPPFLAGS definition works around a thread race issue in -# shared_ptr. I encountered this historically and have not verified that -# the fix is no longer required. Without using the posix thread primitives -# an invalid compare-and-swap ARM instruction (non-thread-safe) was used for the -# shared_ptr use count causing nasty and subtle bugs. -# -# Should perhaps also consider/use instead: -BOOST_SP_USE_PTHREADS - -: ${TARBALLDIR:=`pwd`} -: ${SRCDIR:=`pwd`/src} -: ${IOSBUILDDIR:=`pwd`/ios/build} -: ${OSXBUILDDIR:=`pwd`/osx/build} -: ${PREFIXDIR:=`pwd`/ios/prefix} -: ${IOSFRAMEWORKDIR:=`pwd`/ios/framework} -: ${OSXFRAMEWORKDIR:=`pwd`/osx/framework} -: ${COMPILER:="clang++"} - -: ${BOOST_VERSION:=1.55.0} -: ${BOOST_VERSION2:=1_55_0} - -BOOST_TARBALL=$TARBALLDIR/boost_$BOOST_VERSION2.tar.bz2 -BOOST_SRC=$SRCDIR/boost_${BOOST_VERSION2} - -#=============================================================================== -ARM_DEV_CMD="xcrun --sdk iphoneos" -SIM_DEV_CMD="xcrun --sdk iphonesimulator" -OSX_DEV_CMD="xcrun --sdk macosx" - -ARM_COMBINED_LIB=$IOSBUILDDIR/lib_boost_arm.a -SIM_COMBINED_LIB=$IOSBUILDDIR/lib_boost_x86.a - -#=============================================================================== - - -#=============================================================================== -# Functions -#=============================================================================== - -abort() -{ - echo - echo "Aborted: $@" - exit 1 -} - -doneSection() -{ - echo - echo "=================================================================" - echo "Done" - echo -} - -#=============================================================================== - -cleanEverythingReadyToStart() -{ - echo Cleaning everything before we start to build... - - rm -rf iphone-build iphonesim-build osx-build - rm -rf $IOSBUILDDIR - rm -rf $OSXBUILDDIR - rm -rf $PREFIXDIR - rm -rf $IOSFRAMEWORKDIR/$FRAMEWORK_NAME.framework - rm -rf $OSXFRAMEWORKDIR/$FRAMEWORK_NAME.framework - - doneSection -} - -#=============================================================================== - -downloadBoost() -{ - if [ ! -s $TARBALLDIR/boost_${BOOST_VERSION2}.tar.bz2 ]; then - echo "Downloading boost ${BOOST_VERSION}" - curl -L -o $TARBALLDIR/boost_${BOOST_VERSION2}.tar.bz2 http://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/boost_${BOOST_VERSION2}.tar.bz2/download - fi - - doneSection -} - -#=============================================================================== - -unpackBoost() -{ - [ -f "$BOOST_TARBALL" ] || abort "Source tarball missing." - - echo Unpacking boost into $SRCDIR... - - [ -d $SRCDIR ] || mkdir -p $SRCDIR - [ -d $BOOST_SRC ] || ( cd $SRCDIR; tar xfj $BOOST_TARBALL ) - [ -d $BOOST_SRC ] && echo " ...unpacked as $BOOST_SRC" - - doneSection -} - -#=============================================================================== - -restoreBoost() -{ - cp $BOOST_SRC/tools/build/v2/user-config.jam-bk $BOOST_SRC/tools/build/v2/user-config.jam -} - -#=============================================================================== - -updateBoost() -{ - echo Updating boost into $BOOST_SRC... - - cp $BOOST_SRC/tools/build/v2/user-config.jam $BOOST_SRC/tools/build/v2/user-config.jam-bk - - cat >> $BOOST_SRC/tools/build/v2/user-config.jam < $XCODE_ROOT/Platforms/iPhoneOS.platform/Developer -: arm iphone -; -using darwin : ${IPHONE_SDKVERSION}~iphonesim -: $XCODE_ROOT/Toolchains/XcodeDefault.xctoolchain/usr/bin/$COMPILER -arch i386 -arch x86_64 -fvisibility=hidden -fvisibility-inlines-hidden $EXTRA_CPPFLAGS -: $XCODE_ROOT/Platforms/iPhoneSimulator.platform/Developer -: x86 iphone -; -EOF - - doneSection -} - -#=============================================================================== - -inventMissingHeaders() -{ - # These files are missing in the ARM iPhoneOS SDK, but they are in the simulator. - # They are supported on the device, so we copy them from x86 SDK to a staging area - # to use them on ARM, too. - echo Invent missing headers - - cp $XCODE_ROOT/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${IPHONE_SDKVERSION}.sdk/usr/include/{crt_externs,bzlib}.h $BOOST_SRC -} - -#=============================================================================== - -bootstrapBoost() -{ - cd $BOOST_SRC - - BOOST_LIBS_COMMA=$(echo $BOOST_LIBS | sed -e "s/ /,/g") - echo "Bootstrapping (with libs $BOOST_LIBS_COMMA)" - ./bootstrap.sh --with-libraries=$BOOST_LIBS_COMMA - - doneSection -} - -#=============================================================================== - -buildBoostForIPhoneOS() -{ - cd $BOOST_SRC - - # Install this one so we can copy the includes for the frameworks... - ./bjam -j16 --build-dir=iphone-build --stagedir=iphone-build/stage --prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-${IPHONE_SDKVERSION} define=_LITTLE_ENDIAN link=static stage - ./bjam -j16 --build-dir=iphone-build --stagedir=iphone-build/stage --prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-${IPHONE_SDKVERSION} define=_LITTLE_ENDIAN link=static install - doneSection - - ./bjam -j16 --build-dir=iphonesim-build --stagedir=iphonesim-build/stage --toolset=darwin-${IPHONE_SDKVERSION}~iphonesim architecture=x86 target-os=iphone macosx-version=iphonesim-${IPHONE_SDKVERSION} link=static stage - doneSection - - # ./b2 -j16 --build-dir=osx-build --stagedir=osx-build/stage toolset=clang cxxflags="-std=c++11 -stdlib=libc++ -arch i386 -arch x86_64" linkflags="-stdlib=libc++" link=static threading=multi stage - doneSection -} - -#=============================================================================== - -scrunchAllLibsTogetherInOneLibPerPlatform() -{ - cd $BOOST_SRC - - mkdir -p $IOSBUILDDIR/armv6/obj - mkdir -p $IOSBUILDDIR/armv7/obj - mkdir -p $IOSBUILDDIR/armv7s/obj - mkdir -p $IOSBUILDDIR/arm64/obj - mkdir -p $IOSBUILDDIR/i386/obj - mkdir -p $IOSBUILDDIR/x86_64/obj - - mkdir -p $OSXBUILDDIR/i386/obj - mkdir -p $OSXBUILDDIR/x86_64/obj - - ALL_LIBS="" - - echo Splitting all existing fat binaries... - - for NAME in $BOOST_LIBS; do - ALL_LIBS="$ALL_LIBS libboost_$NAME.a" - - $ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" -thin armv6 -o $IOSBUILDDIR/armv6/libboost_$NAME.a - $ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" -thin armv7 -o $IOSBUILDDIR/armv7/libboost_$NAME.a - $ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" -thin armv7s -o $IOSBUILDDIR/armv7s/libboost_$NAME.a - $ARM_DEV_CMD lipo "iphone-build/stage/lib/libboost_$NAME.a" -thin arm64 -o $IOSBUILDDIR/arm64/libboost_$NAME.a - - $ARM_DEV_CMD lipo "iphonesim-build/stage/lib/libboost_$NAME.a" -thin i386 -o $IOSBUILDDIR/i386/libboost_$NAME.a - $ARM_DEV_CMD lipo "iphonesim-build/stage/lib/libboost_$NAME.a" -thin x86_64 -o $IOSBUILDDIR/x86_64/libboost_$NAME.a - - $ARM_DEV_CMD lipo "osx-build/stage/lib/libboost_$NAME.a" -thin i386 -o $OSXBUILDDIR/i386/libboost_$NAME.a - $ARM_DEV_CMD lipo "osx-build/stage/lib/libboost_$NAME.a" -thin x86_64 -o $OSXBUILDDIR/x86_64/libboost_$NAME.a - done - - echo "Decomposing each architecture's .a files" - - for NAME in $ALL_LIBS; do - echo Decomposing $NAME... - (cd $IOSBUILDDIR/armv6/obj; ar -x ../$NAME ); - (cd $IOSBUILDDIR/armv7/obj; ar -x ../$NAME ); - (cd $IOSBUILDDIR/armv7s/obj; ar -x ../$NAME ); - (cd $IOSBUILDDIR/arm64/obj; ar -x ../$NAME ); - (cd $IOSBUILDDIR/i386/obj; ar -x ../$NAME ); - (cd $IOSBUILDDIR/x86_64/obj; ar -x ../$NAME ); - - (cd $OSXBUILDDIR/i386/obj; ar -x ../$NAME ); - (cd $OSXBUILDDIR/x86_64/obj; ar -x ../$NAME ); - done - - echo "Linking each architecture into an uberlib ($ALL_LIBS => libboost.a )" - - rm $IOSBUILDDIR/*/libboost.a - - echo ...armv6 - (cd $IOSBUILDDIR/armv6; $ARM_DEV_CMD ar crus libboost.a obj/*.o; ) - echo ...armv7 - (cd $IOSBUILDDIR/armv7; $ARM_DEV_CMD ar crus libboost.a obj/*.o; ) - echo ...armv7s - (cd $IOSBUILDDIR/armv7s; $ARM_DEV_CMD ar crus libboost.a obj/*.o; ) - echo ...arm64 - (cd $IOSBUILDDIR/arm64; $ARM_DEV_CMD ar crus libboost.a obj/*.o; ) - echo ...i386 - (cd $IOSBUILDDIR/i386; $SIM_DEV_CMD ar crus libboost.a obj/*.o; ) - echo ...x86_64 - (cd $IOSBUILDDIR/x86_64; $SIM_DEV_CMD ar crus libboost.a obj/*.o; ) - - rm $OSXBUILDDIR/*/libboost.a - echo ...osx-i386 - (cd $OSXBUILDDIR/i386; $SIM_DEV_CMD ar crus libboost.a obj/*.o; ) - - echo ...x86_64 - (cd $OSXBUILDDIR/x86_64; $SIM_DEV_CMD ar crus libboost.a obj/*.o; ) -} - -#=============================================================================== -buildFramework() -{ - : ${1:?} - FRAMEWORKDIR=$1 - BUILDDIR=$2 - - VERSION_TYPE=Alpha - FRAMEWORK_NAME=boost - FRAMEWORK_VERSION=A - - FRAMEWORK_CURRENT_VERSION=$BOOST_VERSION - FRAMEWORK_COMPATIBILITY_VERSION=$BOOST_VERSION - - FRAMEWORK_BUNDLE=$FRAMEWORKDIR/$FRAMEWORK_NAME.framework - echo "Framework: Building $FRAMEWORK_BUNDLE from $BUILDDIR..." - - rm -rf $FRAMEWORK_BUNDLE - - echo "Framework: Setting up directories..." - mkdir -p $FRAMEWORK_BUNDLE - mkdir -p $FRAMEWORK_BUNDLE/Versions - mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION - mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Resources - mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Headers - mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Documentation - - echo "Framework: Creating symlinks..." - ln -s $FRAMEWORK_VERSION $FRAMEWORK_BUNDLE/Versions/Current - ln -s Versions/Current/Headers $FRAMEWORK_BUNDLE/Headers - ln -s Versions/Current/Resources $FRAMEWORK_BUNDLE/Resources - ln -s Versions/Current/Documentation $FRAMEWORK_BUNDLE/Documentation - ln -s Versions/Current/$FRAMEWORK_NAME $FRAMEWORK_BUNDLE/$FRAMEWORK_NAME - - FRAMEWORK_INSTALL_NAME=$FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/$FRAMEWORK_NAME - - echo "Lipoing library into $FRAMEWORK_INSTALL_NAME..." - $ARM_DEV_CMD lipo -create $BUILDDIR/*/libboost.a -o "$FRAMEWORK_INSTALL_NAME" || abort "Lipo $1 failed" - - echo "Framework: Copying includes..." - cp -r $PREFIXDIR/include/boost/* $FRAMEWORK_BUNDLE/Headers/ - - echo "Framework: Creating plist..." - cat > $FRAMEWORK_BUNDLE/Resources/Info.plist < - - - -CFBundleDevelopmentRegion -English -CFBundleExecutable -${FRAMEWORK_NAME} -CFBundleIdentifier -org.boost -CFBundleInfoDictionaryVersion -6.0 -CFBundlePackageType -FMWK -CFBundleSignature -???? -CFBundleVersion -${FRAMEWORK_CURRENT_VERSION} - - -EOF - - doneSection -} - -#=============================================================================== -# Execution starts here -#=============================================================================== - -mkdir -p $IOSBUILDDIR - -cleanEverythingReadyToStart #may want to comment if repeatedly running during dev -restoreBoost - -echo "BOOST_VERSION: $BOOST_VERSION" -echo "BOOST_LIBS: $BOOST_LIBS" -echo "BOOST_SRC: $BOOST_SRC" -echo "IOSBUILDDIR: $IOSBUILDDIR" -echo "OSXBUILDDIR: $OSXBUILDDIR" -echo "PREFIXDIR: $PREFIXDIR" -echo "IOSFRAMEWORKDIR: $IOSFRAMEWORKDIR" -echo "OSXFRAMEWORKDIR: $OSXFRAMEWORKDIR" -echo "IPHONE_SDKVERSION: $IPHONE_SDKVERSION" -echo "XCODE_ROOT: $XCODE_ROOT" -echo "COMPILER: $COMPILER" -echo - -downloadBoost -unpackBoost -inventMissingHeaders -bootstrapBoost -updateBoost -buildBoostForIPhoneOS -scrunchAllLibsTogetherInOneLibPerPlatform -buildFramework $IOSFRAMEWORKDIR $IOSBUILDDIR -buildFramework $OSXFRAMEWORKDIR $OSXBUILDDIR - -restoreBoost - -echo "Completed successfully" - -#===============================================================================