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 :
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"
In line 234, change armv6
to armv7
- In line 239, change "4.0" to "5.1"
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
.