为 iOS 建造 ICU
Build ICU for iOS
我需要 iPhone 的 ICU 库。我试图从 souce 构建它,但是,我得到了这个错误:
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
或者有什么其他方法,如何生成libicudata.a
?类似的构建脚本适用于 Android、Mac 和 Win。只有 iPhone 是问题。
问题是 system()
已弃用 iOS 11.
我认为您的快速修复方法是使用 Xcode 6 而不是 Xcode 9,因此您可以针对 iOS 7 作为目标进行编译,其中 system()没有弃用。
或者,如果您确实需要 iOS 完全兼容的解决方案,则需要重新编写 ICU 源代码以使用 posix 生成功能而不是 system()。查看此答案以获取更多详细信息:How do you use posix_spawn to replace the deprecated 'system' to launch opendiff in Objective-C?
另一种在 iOS 上成功构建 ICU 作为库的解决方案是在没有工具的情况下使用配置标志 --build-tools=no 进行构建。以下是我用于为各种平台构建的完整配置标志集,包括 android 和 ICU。
--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
我刚刚制作了一个 makefile,它将下载 ICU 源代码并为 Mac、Catalyst、iOS 模拟器和 iOS 创建一个通用框架。然后可以将其拖放到您的项目中。
https://github.com/dbquarrel/icu4c-xcframework
可能对你有帮助(虽然晚了很多年)。
我的用途是在 sqlite 中为 iOS 启用 icu 分词器。
我需要 iPhone 的 ICU 库。我试图从 souce 构建它,但是,我得到了这个错误:
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
或者有什么其他方法,如何生成libicudata.a
?类似的构建脚本适用于 Android、Mac 和 Win。只有 iPhone 是问题。
问题是 system()
已弃用 iOS 11.
我认为您的快速修复方法是使用 Xcode 6 而不是 Xcode 9,因此您可以针对 iOS 7 作为目标进行编译,其中 system()没有弃用。
或者,如果您确实需要 iOS 完全兼容的解决方案,则需要重新编写 ICU 源代码以使用 posix 生成功能而不是 system()。查看此答案以获取更多详细信息:How do you use posix_spawn to replace the deprecated 'system' to launch opendiff in Objective-C?
另一种在 iOS 上成功构建 ICU 作为库的解决方案是在没有工具的情况下使用配置标志 --build-tools=no 进行构建。以下是我用于为各种平台构建的完整配置标志集,包括 android 和 ICU。
--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
我刚刚制作了一个 makefile,它将下载 ICU 源代码并为 Mac、Catalyst、iOS 模拟器和 iOS 创建一个通用框架。然后可以将其拖放到您的项目中。
https://github.com/dbquarrel/icu4c-xcframework
可能对你有帮助(虽然晚了很多年)。
我的用途是在 sqlite 中为 iOS 启用 icu 分词器。