Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
274 views
in Technique[技术] by (71.8m points)

ios - Develop an ebook reader on iPhone/iPad using MuPDF library

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 generated the 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:

  1. git clone --recursive git://git.ghostscript.com/mupdf.git
  2. Go to mupdf/platform/ios
  3. Open MuPDF.xcodeproj with Xcode.
  4. Configure the scheme of the MuPDF target to Release.
  5. Build and run the app on an iPhone simulator.
    • This will generate the library for platforms i386 and x86_64
  6. 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 and arm64
  7. Go to mupdf/build/
    • You will find two folders that contains all built librairies: release-ios-i386-x86_64 and release-ios-armv7-arm64
  8. 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:

  1. 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
  2. Add/import the previously generated fat libraries (8 files)
  3. Configure the Library Search Path by adding the path to your library files.
    • For example $(inherited) $(PROJECT_DIR)/External/MuPDF/lib/

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:

  1. Under a release folder just the lib.a from mupdf/build/release-ios-armv7-arm64
  2. Under a debug folder the big generated fat librairies from mupdf/build/
  3. Set different Library Search Path for Debug and Release 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 AppStore should 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:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...