Search code examples
c++iosicu

Build ICU for iOS


I need ICU library for iPhone. I have tried to build it from souce, however, I am getting this erros:

   clang++   ...  /Users/petr/Development/icu-cross-compile-master/icu-60-2/source/tools/pkgdata/pkgdata.cpp
/Users/petr/Development/icu-cross-compile-master/icu-60-2/source/tools/pkgdata/pkgdata.cpp:544:18: error: call to unavailable function 'system': not available on iOS
    int result = system(cmd);
                 ^~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk/usr/include/stdlib.h:195:6: note: candidate function has been explicitly made unavailable
int      system(const char *) __DARWIN_ALIAS_C(system);

sh ${ICU_SOURCE}/configure --host=arm-apple-darwin --with-cross-build=${PREBUILD_DIR} ${PREFIX}

My PREFIX configuration is as:

--enable-extras=yes 
--enable-tools=yes 
--enable-icuio=yes 
--enable-strict=no 
--enable-static 
--enable-shared=no 
--enable-tests=yes 
--disable-renaming 
--enable-samples=no 
--enable-dyload=no
--with-data-packaging=static

Or is there any other way, how to generate libicudata.a? The similar build script works OK for Android, Mac and Win. Only iPhone is problem.


Solution

  • The problem is that system() is deprecated for iOS 11.

    I think quick fix for you will be in using Xcode 6, instead of Xcode 9, so you can compile for iOS 7 as a target, where system() wasn't deprecated.

    Or, if you really need iOS full compatible solution, you need to re-write ICU source code to use posix spawn functionality instead of system(). Check this answer for more details: How do you use posix_spawn to replace the deprecated 'system' to launch opendiff in Objective-C?