为iOS构建ICU

Mar*_*rry 1 c++ icu ios

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

   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}
Run Code Online (Sandbox Code Playgroud)

我的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
Run Code Online (Sandbox Code Playgroud)

或者有没有其他方法,如何生成libicudata.a?类似的构建脚本适用于 Android、Mac 和 Win。只有 iPhone 有问题。

Ant*_*gin 5

问题是system()iOS 11 已弃用。

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

或者,如果您确实需要 iOS 完全兼容的解决方案,则需要重新编写 ICU 源代码以使用 posix spawn 功能而不是 system()。查看此答案以获取更多详细信息:如何使用 posix_spawn 替换已弃用的“系统”以在 Objective-C 中启动 opendiff?