2

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.

Martin Perry
  • 9,232
  • 8
  • 46
  • 114
  • Do you really need to build tools? They are actually a bunch of command line tools. If you build ICU without tools it will build as well without need for patching. – ceztko Feb 20 '20 at 22:06

3 Answers3

5

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?

Anton Malmygin
  • 3,406
  • 2
  • 25
  • 31
0

Another solution to successfully build ICU on iOS as a library is to build without tools with the configure flag --build-tools=no. The following is the complete set of configure flags I'm using to build for various platforms, android and ICU included.

    --enable-static=yes
    --enable-shared=no
    --enable-extras=no
    --enable-strict=no
    --enable-icuio=no
    --enable-layout=no
    --enable-layoutex=no
    --enable-tests=no
    --enable-samples=no
    --enable-tools=no
    --enable-dyload=no
    --with-data-packaging=archive
ceztko
  • 14,736
  • 5
  • 58
  • 73
0

I've just made a makefile which will download the ICU source and create a universal framework for Mac, Catalyst, iOS Simulator and iOS. This can then just be drag-and-dropped into your project.

https://github.com/dbquarrel/icu4c-xcframework

Might help you (though many years late).

My use was to enable the icu tokenizer in sqlite for iOS.

dbquarrel
  • 1,446
  • 1
  • 10
  • 8