Question

Short description about library : Link of library

I want to compile swift library (i.e. http://swift.im/git/swift/tag/?id=swift-2.0beta1) for iPhone sdk. I have checked its document folder and way of compilation but they only mentioned compilation steps for Windows and Unix(i.e. This page contains link for compilation files http://swift.im/download/#apt). But I am not getting how to compile it for iPhone sdk. Steps that they mentioned are not getting. So, Can any one explain me ? After checking one of file i came to know that it should be possible to compile for iPhone.

One more question they mentioned that it is under GNU General public license v3 so can I use it commercial application specially apple approve it?

Any help would be appreciated. Thanks

Was it helpful?

Solution

Figures Swiften already has built-in support for building for an iOS device or simulator. I was able to build it, but haven't tested it.

I will assume you z XCode 4.4 (or something sufficiently modern) and target iOS 5.1 running on iPhone > 3GS. Also, I will assume you want to build swiften-1.0. (if building for earlier iPhone, change armv7 back to armv6 below)

There are several steps involved in order to build it.

Fix paths and SDK version

Open swift-1.0/BuildTools/SCons/SConstruct in a file editor, and :

  1. Change line 232 from

    env["XCODE_PLATFORM_DEVELOPER_BIN_DIR"] = "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin"

    to

    env["XCODE_PLATFORM_DEVELOPER_BIN_DIR"] = "/Applications/Xcode.app/Contents" + "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin"

  2. In line 234, change armv6 to armv7

  3. In line 239, change "4.0" to "5.1"
  4. Change line 240 from

    env["XCODE_SDKROOT"] = "/Developer/Platforms/" + sdkPart + ".platform/Developer/SDKs/" + sdkPart + sdkVer + ".sdk"

    to

    env["XCODE_SDKROOT"] = "/Applications/Xcode.app/Contents" + "/Developer/Platforms/" + sdkPart + ".platform/Developer/SDKs/" + sdkPart + sdkVer + ".sdk"

Copy crt_externs.h to swift-1.0/

(from Matt Galloway's Compiling Boost for the iPhone)

Copy crt_externs.h to swift's directory; when in swift-1.0/, execute:

cp /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/usr/include/crt_externs.h .

Download and Build openssl

swiften requires openssl, but iOS does not have a built-in one, so you'll have to download and compile it manually. Execute the following in a terminal:

cd <swift-directory>/3rdParty/OpenSSL
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz

This will download the soruce of openssl; to build it, I used a script from GitHub. Still in <swift-directory>/swift-1.0/3rdParty/OpenSSL, execute,

wget --no-check-certificate https://raw.github.com/st3fan/ios-openssl/master/build.sh

Edit build.sh - change line 10 from 1.0.1b to 1.0.1c.

Now, chmod +x build.sh and finally ./build.sh. This will take several minutes to build openssl.

Build swiften

You're almost there - change directory to the root of swift, and execute

./scons Swiften allow_warnings=yes target=iphone-device openssl="<swift-directory>/3rdParty/OpenSSL"

This will build a library for linking against an application built for the device; if you want to run it in the simulator, change target=iphone-device to target-iphone-simulator in the line above. The library file libSwiften.a can be found in <swift-directory>/Swiften.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top