问题描述
我可以使用MuPDF库在iphone / ipad上开发电子书阅读器吗?
你有什么好主意吗?请帮我一些好的教程。
对于迟到的答案感到抱歉,但它可以帮助人们一天或另一天。
由于我必须将MuPDF库集成到我的一个(Swift)项目中,我生成
静态胖库并将它们集成到Xcode中。
如何构建静态胖库:
- git clone --recursive git://git.ghostscript.com/mupdf.git
- 转到
mupdf / platform / ios
- 使用Xcode打开 MuPDF.xcodeproj 。
- 配置方案MuPDF定位到发布。
- 在iPhone模拟器上构建并运行应用程序。
- 这将生成平台的库
i386
和x86_64
- 这将生成平台的库
- 在真实的iPhone设备上构建并运行应用程序 - 使用您自己的软件包ID,证书和配置文件。
- 这将为平台生成库
armv7
和arm64
- 这将为平台生成库
- 转到
mupdf / build /
- 您将找到两个包含所有内置库的文件夹:
release-ios-i386-x86_64
和release-ios-armv7-arm64
- 您将找到两个包含所有内置库的文件夹:
- 现在需要创建包含所有4种体系结构的胖库对于mupdf及其所有依赖项。
lipo -create ./*/libcurl.a -output 'libcurl.a'; lipo -create ./*/libfreetype.a -output'libfreetype.a'; lipo -create ./*/libjbig2dec.a -output'libjbig2dec.a'; lipo -create ./*/libjpeg.a -output'libjpeg.a'; lipo -create ./*/libmujs.a -output'libmujs.a'; lipo -create ./*/libmupdf.a -output'libmupdf.a'; lipo -create ./*/libopenjpeg.a -output'libopenjpeg.a'; lipo -create ./*/libz.a -output'libz.a'
如何将MuPDF集成到您的项目中:
- 添加/导入项目:
- 来自<$的所有头文件c $ c> mupdf / include / mupdf
- 来自
mupdf / platform / ios / $ c $的所有obj-c类c> classes
- 来自
的常见。[h,m]文件mupdf / platform / ios
- 添加/导入先前生成的胖库(8个文件)
- 配置
库搜索路径
通过添加库文件的路径。
- 例如
$(继承)$(PROJECT_DIR)/外部/ MuPDF / lib /
- 例如
您现在应该可以使用包含的库来构建和运行您的应用程序。
使用示例项目来了解库的工作原理或任何在线教程。
专业提示:
最终的胖库一共都很大(约46mb)。
你可以通过导入轻松减少应用程序的最终大小:
- 在一个发布文件夹下只有lib.a来自
mupdf / build / release-ios-armv7-arm64
- 在调试文件夹下,来自
的大量生成的胖库mupdf / build /
- 为
Debug设置不同的
和库搜索路径
发布
config。
完成后,你将会能够在每个模拟器和设备上构建并运行 Debug
。但仅适用于发布
的设备。最后,您需要作为您的应用,AppStore
应该只在真实设备上运行。没有必要包含调试模拟器架构静态库。
以下是我的Xcode项目中所有导入文件的屏幕截图:
Can I develop an ebook reader on iphone/ipad using MuPDF library?
Do you have any good idea? Please help me with some good tutorials.
Sorry for the late answer but it could help people a day or another.As I had to integrate the MuPDF library into one of my (Swift) project, I generatedthe static fat libraries and integrate them into Xcode.
Here you go with a step-by-step quick tutorial:
How to build the static fat library:
- git clone --recursive git://git.ghostscript.com/mupdf.git
- Go to
mupdf/platform/ios
- Open MuPDF.xcodeproj with Xcode.
- Configure the scheme of the MuPDF target to Release.
- Build and run the app on an iPhone simulator.
- This will generate the library for platforms
i386
andx86_64
- This will generate the library for platforms
- Build and Run the app on a real iPhone device - use your own bundle id, certificate and provisioning profile.
- This will generate the library for platforms
armv7
andarm64
- This will generate the library for platforms
- Go to
mupdf/build/
- You will find two folders that contains all built librairies:
release-ios-i386-x86_64
andrelease-ios-armv7-arm64
- You will find two folders that contains all built librairies:
- Now you need to create fat libraries with all 4 architectures for the mupdf one and all its dependencies.
lipo -create ./*/libcurl.a -output 'libcurl.a' ; lipo -create ./*/libfreetype.a -output 'libfreetype.a' ; lipo -create ./*/libjbig2dec.a -output 'libjbig2dec.a' ; lipo -create ./*/libjpeg.a -output 'libjpeg.a' ; lipo -create ./*/libmujs.a -output 'libmujs.a' ; lipo -create ./*/libmupdf.a -output 'libmupdf.a' ; lipo -create ./*/libopenjpeg.a -output 'libopenjpeg.a' ; lipo -create ./*/libz.a -output 'libz.a'
How to integrate MuPDF into your project:
- Add/import into your project:
- All header files from
mupdf/include/mupdf
- All obj-c classes from
mupdf/platform/ios/
classes - The common.[h,m] files from
mupdf/platform/ios
- All header files from
- Add/import the previously generated fat libraries (8 files)
- Configure the
Library Search Path
by adding the path to your library files.- For example
$(inherited) $(PROJECT_DIR)/External/MuPDF/lib/
- For example
You should now be able to build and run your app with the library included.Use the sample project to understand how the library works or any online tutorial.
Pro Tip:
The final fat libraries are pretty big all together (~ 46mb).You could easily reduce the final size of your app by importing:
- Under a release folder just the lib.a from
mupdf/build/release-ios-armv7-arm64
- Under a debug folder the big generated fat librairies from
mupdf/build/
- Set different
Library Search Path
forDebug
andRelease
config.
Once done, you will be able to build and run on Debug
on every simulator and devices. But only on devices for Release
. Which in the end you need as your app, through, the AppStoreshould only run on real devices. There is no need to include debug-simulator architecture static librairies.
Here is a screenshot of all imported files into my Xcode project:
这篇关于使用MuPDF库在iPhone / iPad上开发电子书阅读器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!