Code Monkey home page Code Monkey logo

Comments (15)

TimOliver avatar TimOliver commented on August 18, 2024

Assuming it's alright to spruik my own libraries here. Sorry in advance if it's not! ;D

I'm maintaining an Objective-C wrapper library for libdsm as well as a statically cross-compiled version of the libdsm library for all of the necessary iOS (And the Simulator) architectures. It's available here: https://github.com/TimOliver/TOSMBClient

If all you need is the libdsm static library itself, you can download it from the repo here.

In regards to how to actually build it for iOS, I'm still perfecting my build script so it's completely automatic in terms of downloading and setting up all of the necessary dependencies, but here's what I have so far:

#!/bin/bash

# Global build settings
export SDKPATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
export SIMSDKPATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
export MIN_IOS_VERSION=7.0
export HOST=arm-apple-darwin
export LDFLAGS_NATIVE="-isysroot $SDKPATH"
export LDFLAGS_SIMULATOR="-isysroot $SIMSDKPATH"
export TASN1_CFLAGS="-Ilibtasn1/include"
export TASN1_LIBS="-Llibtasn1 -ltasn1"
export ARCHES=(armv7 armv7s arm64 i386 x86_64)

# libtasn1 defines
export TASN1_URL="http://ftp.gnu.org/gnu/libtasn1/libtasn1-4.7.tar.gz"
export TASN1_DIR_NAME="libtasn1-4.7"

# libdsm defines
export DSM_URL="https://github.com/videolabs/libdsm/archive/v0.1.0.zip"
export DSM_DIR_NAME="libdsm-0.1.0"

######################################################################

echo "Checking libtasn1..."

# Download the latest libtasn1 library
if [ ! -d $TASN1_DIR_NAME ]; then
    echo "Downloading libtasn1..."
    curl -o $TASN1_DIR_NAME.tar.gz $TASN1_URL
    gunzip -c $TASN1_DIR_NAME.tar.gz | tar xopf -
fi
echo "... Done"

echo "Checking libdsm..."

# Download the latest version of libdsm
if [ ! -d $DSM_DIR_NAME ]; then
    echo "Downloading libdsm..."
    curl -L -J -O $DSM_URL
    unzip $DSM_DIR_NAME.zip -d $PWD
fi

echo "...Done"

######################################################################
#Build tasn1

#Remove the previous build of libtasn1 from libdsm
rm -rf $DSM_DIR_NAME/libtasn1

cd $TASN1_DIR_NAME
rm -rf build

#Build libtasn1 for each architecture
for i in "${ARCHES[@]}"
do
    build_files="$build_files build/$i/lib/libtasn1.a"
    export ARCH=$i
    if [[ $i == *"arm"* ]]
    then
        export LDFLAGS=$LDFLAGS_NATIVE
    else
        export LDFLAGS=$LDFLAGS_SIMULATOR
    fi
    export CFLAGS="-arch $ARCH $LDFLAGS -miphoneos-version-min=$MIN_IOS_VERSION"
    ./configure --host=$HOST --prefix=$PWD/build/$ARCH && make && make install
    make clean
done

echo $build_files

#Merge the compiled binaries into a single universal one
mkdir -p build/universal
lipo -create $build_files -output build/universal/libtasn1.a

#Copy headers across
mkdir build/universal/include
cp -R build/armv7/include build/universal/

cd ../

#Copy binary to libdsm folder for its build process
cp -R $TASN1_DIR_NAME/build/universal $DSM_DIR_NAME/libtasn1

######################################################################
#Build libdsm

cd $DSM_DIR_NAME
rm -rf build

build_files=""
for i in "${ARCHES[@]}"
do
    build_files="$build_files build/$i/lib/libdsm.a"
    export ARCH=$i
    if [[ $i == *"arm"* ]]
    then
        export LDFLAGS=$LDFLAGS_NATIVE
    else
        export LDFLAGS=$LDFLAGS_SIMULATOR
    fi
    export CFLAGS="-arch $ARCH $LDFLAGS -miphoneos-version-min=$MIN_IOS_VERSION"
    ./bootstrap
    ./configure --host=$HOST --prefix=$PWD/build/$ARCH && make && make install
    make clean
done

#Merge the compiled binaries into a single universal one
mkdir -p build/universal
lipo -create $build_files -output build/universal/libdsm.a

#Copy headers across
mkdir build/universal/include
cp -R build/armv7/include build/universal

#Move final product to parent directory
cp -R build/universal ../libdsm

from libdsm.

solidusex avatar solidusex commented on August 18, 2024

Thanks for your reply, I have just downloaded your project and test it, very good.
But I need to support bitcode, so I have to compile a library of my own.

Thank you build script, Let me try, thank you.

from libdsm.

TimOliver avatar TimOliver commented on August 18, 2024

Ahh whoops. That's right! Adding bitcode support was on my todo list!

No worries! Let me know how you go! It should just be a matter of appending '-fembed_bitcode' at the end of those CFLAGS variables in the build script.

I'll put up an updated build with bitcode support on my GitHub repo tonight.

from libdsm.

solidusex avatar solidusex commented on August 18, 2024

yeah, so much the better, and thanks your work!

from libdsm.

solidusex avatar solidusex commented on August 18, 2024

I don't know why, some problems in my environment(osx 10.11.3, xcode7.2), I don't
understand script language,so spent a couple of hours to make some changes and
finally I can work here, this result of my modified:

#!/bin/bash

Global build settings

export TARGET=$PWD/build
echo $TARGET

export SDKPATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
export SIMSDKPATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
export MIN_IOS_VERSION=7.0
export HOST=arm-apple-darwin
export LDFLAGS_NATIVE="-isysroot $SDKPATH"
export LDFLAGS_SIMULATOR="-isysroot $SIMSDKPATH"
#export TASN1_CFLAGS="-Ilibtasn1/include"
#export TASN1_LIBS="-Llibtasn1 -ltasn1"
export ARCHES=(armv7 arm64 i386 x86_64)
#export ARCHES=(i386 x86_64)

libtasn1 defines

export TASN1_URL="http://ftp.gnu.org/gnu/libtasn1/libtasn1-4.7.tar.gz"
export TASN1_DIR_NAME="libtasn1-4.7"

libdsm defines

export DSM_URL="https://github.com/videolabs/libdsm/archive/v0.1.0.zip"
export DSM_DIR_NAME="libdsm-0.1.0"

######################################################################

rm -rf $TARGET

######################################################################

echo "Checking libtasn1..."

Download the latest libtasn1 library

if [ ! -d $TASN1_DIR_NAME ]; then
echo "Downloading libtasn1..."
curl -o $TASN1_DIR_NAME.tar.gz $TASN1_URL
gunzip -c $TASN1_DIR_NAME.tar.gz | tar xopf -
fi
echo "... Done"

echo "Checking libdsm..."

Download the latest version of libdsm

if [ ! -d $DSM_DIR_NAME ]; then
echo "Downloading libdsm..."
curl -L -J -O $DSM_URL
unzip $DSM_DIR_NAME.zip -d $PWD
fi

echo "...Done"

######################################################################
#Build tasn1

#Remove the previous build of libtasn1 from libdsm
rm -rf $DSM_DIR_NAME/libtasn1

cd $TASN1_DIR_NAME
rm -rf build

#Build libtasn1 for each architecture
for i in "${ARCHES[@]}"
do
build_files="$build_files build/$i/lib/libtasn1.a"
export ARCH=$i
if [[ $i == "arm" ]]
then
export LDFLAGS=$LDFLAGS_NATIVE
else
export LDFLAGS=$LDFLAGS_SIMULATOR
fi
export CFLAGS="-fembed-bitcode -arch $ARCH $LDFLAGS -miphoneos-version-min=$MIN_IOS_VERSION"

#./configure --host=$HOST --prefix=$PWD/build/$ARCH && make -j 4 && make install
./configure --host=$HOST --prefix=$TARGET/$ARCH && make -j 4 && make install
make clean

done

echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

echo $build_files

cd ../

######################################################################
#Build libdsm

cd $DSM_DIR_NAME
rm -rf build

build_files=""
for i in "${ARCHES[@]}"
do
build_files="$build_files build/$i/lib/libdsm.a"
export ARCH=$i
if [[ $i == "arm" ]]
then
export LDFLAGS=$LDFLAGS_NATIVE
else
export LDFLAGS=$LDFLAGS_SIMULATOR

    export TASN1_LIBS="-L$TARGET/$ARCH/lib -ltasn1"
fi

export CFLAGS="-fembed-bitcode -arch $ARCH $LDFLAGS -miphoneos-version-min=$MIN_IOS_VERSION"

./bootstrap
./configure --host=$HOST --prefix=$TARGET/$ARCH && make -j 4&& make install
make clean

done

######################################################################

libasn1_build_files=""
libdsm_build_files=""

for i in "${ARCHES[@]}"
do
libasn1_build_files="$libasn1_build_files $TARGET/$i/lib/libtasn1.a"
libdsm_build_files="$libdsm_build_files $TARGET/$i/lib/libdsm.a"
done

mkdir $TARGET/universal
#mkdir $TARGET/universal/include
mkdir $TARGET/universal/lib

cp -R $TARGET/armv7/include $TARGET/universal/
lipo -create $libasn1_build_files -output $TARGET/universal/lib/libtasn1.a
lipo -create $libdsm_build_files -output $TARGET/universal/lib/libdsm.a

from libdsm.

TimOliver avatar TimOliver commented on August 18, 2024

Cool! Awesome! Looks like you got it sorted out! I also just finished uploading a new build of libdsm with bitcode enabled to my repo.

from libdsm.

jbkempf avatar jbkempf commented on August 18, 2024

Well, the best way to use liBDSM on iOS, is indeed in @TimOliver repository.
Just be careful, because next releases of liBDSM will probably break slightly the API to be more consistent.
Moreover, be careful on iOS and tvOS, that if your application is NOT open source, and you build statically (the default, IIRC), then you NEED a commercial license. It is very possible that bytecode requires such a license too.

from libdsm.

TimOliver avatar TimOliver commented on August 18, 2024

@jbkempf Thanks a lot for that! I'm actively watching this repo, so if any new API changes come out, I'll do my best to accommodate them as soon as I can.

Yeah, I was told by @fkuehne on Twitter a while ago that it would be necessary to follow Sparrow's model of releasing enough of the compiled source/assets to allow developers to re-build/re-sign the app with new versions of the library in order to comply with the LGPL. I should make that more apparent on my repo.

That being said, I am definitely interested in a commercial license for one of my own projects. Who would I need to contact about that?

from libdsm.

jbkempf avatar jbkempf commented on August 18, 2024

Either you build as shared library, and then, it's quite simple. But you loose some older iOS releases.
Or you build as a static library, and it's very very difficult, but is the sparrow way. In those cases, I advise a license, to be honest, because maybe this way is not perfect.
And you can [email protected] for licenses.

from libdsm.

TimOliver avatar TimOliver commented on August 18, 2024

Hmm fair enough. Yeah, iOS 8 and later allows externally compiled frameworks to be linked dynamically, but given the LGPL's 'relinking' clause, that alone probably isn't sufficient for iOS/tvOS apps. Having SMB support in my app is such a killer feature though, I'm happy to do whatever is necessary to ensure its properly licensed! :)

No worries! Thanks for that! I'll send an email there.

from libdsm.

jbkempf avatar jbkempf commented on August 18, 2024

No, if dynamically linked, there is no need for anything else.

from libdsm.

TimOliver avatar TimOliver commented on August 18, 2024

Oh! That's excellent to hear! Thanks a lot then! I'll see about refactoring my library so it's capable of being integrated as a dynamic framework.

In the meantime, I've sent an email regarding commercial licensing as well.

from libdsm.

jbkempf avatar jbkempf commented on August 18, 2024

But that means no iOS7, if I understand correctly, and probably not tvOS...

from libdsm.

TimOliver avatar TimOliver commented on August 18, 2024

Yep, that's correct! That being said, iOS 7 is now running on less than 7% of devices so it's not a huge tradeoff at this particular point.

And I just made a test tvOS app just to absolutely confirm: tvOS definitely IS capable of working with dynamic frameworks as well (tvOS is based on iOS 9, but it was still possible they could have removed it), so it's definitely not a problem on that platform at all. :)

from libdsm.

jbkempf avatar jbkempf commented on August 18, 2024

No, the problem about tvOS is the bytecode part. Because it might be LGPL incompatible.

from libdsm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.