How to build GLib for iOS
Given that you have built libffi and proxy-libintl for iOS, and installed both those to the same PREFIX as this script uses, this will build GLib for you:
#! /bin/bash
export MINVER="5.1" # the minimum supported OS version
export SDKVER="5.1" # SDK version
export PREFIX="$HOME/built-for-ios" # where the library goes
export DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer"
export SDKROOT="${DEVROOT}/SDKs/iPhoneOS${SDKVER}.sdk"
export PKG_CONFIG_LIBDIR="${PREFIX}/lib/pkgconfig:${SDKROOT}/usr/lib/pkgconfig"
export COMMON_FLAGS="-arch armv7 -isysroot ${SDKROOT}"
export CPPFLAGS="-I${PREFIX}/include ${COMMON_FLAGS} -miphoneos-version-min=${MINVER}"
export CFLAGS="${CPPFLAGS}"
export LDFLAGS="-L${PREFIX}/lib ${COMMON_FLAGS} -Wl,-iphoneos_version_min,${MINVER}"
export CC="${DEVROOT}/usr/bin/gcc"
export CXX="${DEVROOT}/usr/bin/g++"
export OBJC="${CC}"
export LD="${CC}"
[ ! -d "${PREFIX}" ] && mkdir -p "${PREFIX}"
./configure --prefix="${PREFIX}" \
--build="x86_64-apple-darwin" \
--host="arm-apple-darwin" \
--enable-static \
--disable-shared \
glib_cv_stack_grows=no \
glib_cv_uscore=no \
ac_cv_func_posix_getgrgid_r=yes \
ac_cv_func_posix_getpwuid_r=yes
How to use glib on iphone?
While it's certainly possible to compile and link glib for iOS, it seems that there's a legal problem: glib uses LGPL and some think LGPL is not compatible with Apple's terms.
GLib usage with XCode
see Setting C++ compile flags in xcode
in short:
add result ofpkg-config --cflags --libs glib-2.0
to Build Settings -> Linking -> Other Linker Flags
NOT Build Settings -> Custom Compiler Flags -> Other C Flags
for some reason using
'pkg-config --cflags --libs glib-2.0' directly does not work yielding:
clang: error: no such file or directory: 'pkg-config --cflags --libs glib-2.0'
Related Topics
Singleton in iOS Objective C Doesn't Prevent More Than One Instance
Searchdisplaycontroller Deprecated in iOS 8
Swift - How to Create Sort Query as Descending on Firebase
Face Recognition on the Iphone
Xcode 6 Save for Enterprise Deployment Does Not Create Plist for IPA Anymore
Fatal Error: Malformed or Corrupted Ast File - Xcode
Where Do I Find iOS Obj-C Code to Scan and Connect to Wifi (Private API)
Multiple Locations on Map (Using Mkmapitem and Clgeocoder)
Uitableview Auto Resizing Row Constraint Breaking Mysteriously on iPhone 6Plus
This Class Is Not Key Value Coding-Compliant for the Key Xxxxxx
iPhone Uitableview. How Do Turn on the Single Letter Alphabetical List Like the Music App
Development Team Not Showing in Xcode
Facebook Graph API Get Request - Should Contain "Fields" Parameter (Swift, Facebook Sdk V4.5.1)