为 IOS 编译 Freetype 2.6.5 Xcode

Compiling Freetype 2.6.5 Xcode for IOS

好的伙计们,我发布了一个类似的问题并将其删除,因为它不够具体所以我开始了。从 Freetype 2.6.5 的 zip 文件我无法创建一个 Xcode 项目来编译库供 iOS 使用,仅供 i386_64.

我尝试了命令 here 但我没有通过第一个命令,我得到了这个

FreeType build system -- automatic system detection

The following settings are used:

platform unix compiler cc
configuration directory ./builds/unix configuration rules
./builds/unix/unix.mk

If this does not correspond to your system or settings please remove the file `config.mk' from this directory then read the INSTALL file for help.

Otherwise, simply type /Applications/Xcode.app/Contents/Developer/usr/bin/make' again to build the library, or /Applications/Xcode.app/Contents/Developer/usr/bin/make refdoc' to build the API reference (this needs python >= 2.6).

cd builds/unix; \ ./configure 'CFLAGS=-arch i386' /bin/sh: ./configure: No such file or directory make: *** [setup] Error 127

我也按照 cmakelists.txt 中的说明进行了操作,它出现在项目中,但仍然没有,我仍然得到了 osx 的 xcode 项目,而不是 IOS 这给了我过多的链接错误。以下是说明供您参考。

For an iOS static library, use #

cmake -D IOS_PLATFORM=OS -G Xcode

#

or

#

cmake -D IOS_PLATFORM=SIMULATOR -G Xcode

我不知道还能做什么。有帮助吗?

下面是为 iOS 编译 FreeType 库的基本构建过程的概述:

  1. 下载最新的FreeType source code
  2. 将存档解压并 cd 到未存档目录
  3. 为所需架构(arm64、arm7、i386、x86_64)设置工具链和导出变量
  4. 编译源代码并构建库

例如,arm64 的构建命令可能如下所示:

$ export CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
$ iphoneos="7.0" # target version of iOS 
$ ARCH="arm64" # architecture (arm64, arm7, i386, x86_64)
$ export CFLAGS="-arch ${ARCH} -pipe -mdynamic-no-pic -Wno-trigraphs -fpascal-strings \
-O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden \
-miphoneos-version-min=$iphoneos -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2 \
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" 
$ export AR="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"
$ export LDFLAGS="-arch ${ARCH} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
-miphoneos-version-min=7.0"
$ ./configure --host="aarch64-apple-darwin" --enable-static=yes --enable-shared=no           
$ make     
$ clean

It's a bit of work to construct the commands for each arch, but fortunately there's a build script — which automatically downloads, extracts, and builds the latest FreeType (2.6.5 currently).

要运行脚本只需在终端中使用以下命令:

./build_freetype.sh

完成后可以在 ~/Desktop/FreeType_iOS_Release 中找到生成的 iOS 库。