为iOS构建ICU

时间:2018-01-06 14:07:26

标签: c++ ios icu

我需要iPhone的ICU库。我试图从源代码构建它,但是,我得到了这个错误:

stopWatchingMode

我的 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} 配置如下:

PREFIX

或者还有其他方法,如何生成--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 ?类似的构建脚本适用于Android,Mac和Win。只有iPhone才有问题。

3 个答案:

答案 0 :(得分:4)

问题是iOS 11已弃用system()

我认为快速修复将使用Xcode 6而不是Xcode 9,因此您可以编译iOS 7作为目标,其中system()不被弃用。

或者,如果您确实需要iOS完全兼容的解决方案,则需要重新编写ICU源代码以使用posix spawn功能而不是system()。请查看此答案以获取更多详细信息:How do you use posix_spawn to replace the deprecated 'system' to launch opendiff in Objective-C?

答案 1 :(得分:0)

将iOS作为库成功构建ICU的另一种解决方案是不使用带有configure标志--build-tools = no的工具进行构建。以下是我用来为各种平台(包括android和ICU)构建的一整套configure标志。

    --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

答案 2 :(得分:0)

我刚刚制作了一个 makefile,它将下载 ICU 源代码并为 Mac、Catalyst、iOS 模拟器和 iOS 创建一个通用框架。然后只需将其拖放到您的项目中即可。

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

可能会帮助你(虽然晚了很多年)。

我的用途是在用于 iOS 的 sqlite 中启用 icu 标记器。