Building for iOS

527 views
Skip to first unread message

Juha Suni

unread,
Nov 29, 2016, 3:00:17 AM11/29/16
to pdfium
Have you got any instructions for building for iOS? I tried setting gn args with target_os = "ios" but it fails immediately after saving the args and "Generating files...". All errors seem to be related to unit tests, but I didn't want to dig deeper unless there's really a chance to build it successfully for iOS.

Wei Li

unread,
Nov 29, 2016, 1:00:43 PM11/29/16
to Juha Suni, pdfium
Hi, Juha:

ios is not supported yet. We don't have any near-term plan to support that either. But PDFium is open-source, feel free to dig deeper to see what needs to be done. I would think compiling without tests would be a good start. 

On Tue, Nov 29, 2016 at 12:00 AM, Juha Suni <juhis...@gmail.com> wrote:
Have you got any instructions for building for iOS? I tried setting gn args with target_os = "ios" but it fails immediately after saving the args and "Generating files...". All errors seem to be related to unit tests, but I didn't want to dig deeper unless there's really a chance to build it successfully for iOS.

--
You received this message because you are subscribed to the Google Groups "pdfium" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdfium+unsubscribe@googlegroups.com.
To post to this group, send email to pdf...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdfium/05c7caa0-cf39-4af5-9425-5a3298d65a69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jokl...@gmail.com

unread,
Mar 1, 2017, 7:08:31 PM3/1/17
to pdfium, juhis...@gmail.com
Adding

 target_os = "ios"
 target_cpu = "arm64"

to args.gn seems to be supported (there is build/config/ios/ and such). Then you start compiling... core/fxcrt/fx_system.h includes <Carbon/Carbon.h> which is macOS only.

Should it now build for iOS (various script files seem to indicate so) or is there still some work left to be done? Maybe I missed a flag or option somewhere? I can put in the effort if work needs to be done.

Dan Sinclair

unread,
Mar 2, 2017, 9:03:32 AM3/2/17
to jokl...@gmail.com, pdfium, juhis...@gmail.com
The build/config/ios code is pulled in from the Chromium build
directory. We have not done any work on getting PDFium to build on
ios.

dan
> --
> You received this message because you are subscribed to the Google Groups
> "pdfium" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pdfium+un...@googlegroups.com.
> To post to this group, send email to pdf...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pdfium/82feca1c-e5c9-4b92-9ad8-64e122c40679%40googlegroups.com.

jokl...@gmail.com

unread,
Mar 2, 2017, 1:14:17 PM3/2/17
to pdfium, jokl...@gmail.com, juhis...@gmail.com
I have PDFium building and rendering pages on iOS devices.

The patches (below) are tiny due to macOS and iOS having identical APIs which PDFium is using. These minor changes support building for both macOS and iOS:

a) #include <Carbon/Carbon.h> is deprecated in macOS and not available in iOS. This outdated include has been removed in one header and replaced with #include <CoreGraphics/CoreGraphics.h> and #include <CoreFoundation/CFString.h> in another which pull in the definitions for the APIs PDFium is using.

b) BUILD.gn has been changed in two places from if (is_mac) to if (is_mac || is_ios) to pull in the platform specific files for iOS.

Finally, one hack to help the build along is to create a pdfium/testing/gtest_ios directory and populate it with sample Default.png and unittest-Info.plist files and then use the following for args.gn:

is_debug = false # Debugging features
pdf_use_skia = false # Set true to enable experimental skia backend
pdf_use_skia_paths = false # Set true to enable experimental skia backend (paths only)
pdf_enable_xfa = false # Set false to remove XFA support (implies JS support)
pdf_enable_v8 = false # Set false to remove Javascript support
pdf_is_standalone = true # Set for a non-embedded build
is_component_build = false # Disable component build (must be false)
clang_use_chrome_plugins = false # Currently must be false
use_sysroot = false # Currently must be false on Linux

target_os = "ios"
target_cpu = "arm64"
ios_enable_code_signing = false

*** orig/pdfium/BUILD.gn    2017-03-02 12:25:25.000000000 -0500
--- repo/pdfium/BUILD.gn    2017-03-01 12:00:00.000000000 -0500
*************** static_library("fxge") {
*** 910,916 ****
      ]
      deps += [ "third_party:fx_agg" ]
 
!     if (is_mac) {
        sources += [ "core/fxge/apple/fx_apple_platform.cpp" ]
      }
    }
--- 910,916 ----
      ]
      deps += [ "third_party:fx_agg" ]
 
!     if (is_mac || is_ios) {
        sources += [ "core/fxge/apple/fx_apple_platform.cpp" ]
      }
    }
*************** static_library("fxge") {
*** 932,938 ****
      configs -= [ "//build/config/win:lean_and_mean" ]
    }
 
!   if (is_mac) {
      sources += [
        "core/fxge/apple/apple_int.h",
        "core/fxge/apple/fx_mac_imp.cpp",
--- 932,938 ----
      configs -= [ "//build/config/win:lean_and_mean" ]
    }
 
!   if (is_mac || is_ios) {
      sources += [
        "core/fxge/apple/apple_int.h",
        "core/fxge/apple/fx_mac_imp.cpp",


*** orig/pdfium/core/fxcrt/fx_system.h    2017-03-02 12:25:25.000000000 -0500
--- repo/pdfium/core/fxcrt/fx_system.h    2017-03-01 12:00:00.000000000 -0500
***************
*** 59,65 ****
  #endif
 
  #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
! #include <Carbon/Carbon.h>
  #include <libkern/OSAtomic.h>
  #endif
 
--- 59,66 ----
  #endif
 
  #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
! #include <CoreGraphics/CoreGraphics.h>
! #include <CoreFoundation/CFString.h>
  #include <libkern/OSAtomic.h>
  #endif
 

*** orig/pdfium/core/fxge/apple/apple_int.h    2017-03-02 12:25:25.000000000 -0500
--- repo/pdfium/core/fxge/apple/apple_int.h    2017-03-01 12:00:00.000000000 -0500
***************
*** 15,22 ****
  #include "core/fxge/fx_dib.h"
  #include "core/fxge/ifx_renderdevicedriver.h"
 
- #include <Carbon/Carbon.h>
-
  class CQuartz2D {
   public:
    void* createGraphics(CFX_DIBitmap* bitmap);
--- 15,20 ----

Dan Sinclair

unread,
Mar 2, 2017, 1:38:20 PM3/2/17
to jokl...@gmail.com, pdfium, juhis...@gmail.com
Thanks a lot for looking into and getting this building. Can you
upload cls to gerrit [1] for these issues? We mostly follow the
Chromium contributing guidelines [2] with the exception of following
existing code formatting. You will need to sign the CLA [3] before we
can accept any CLs.

Thanks,
dan


1- https://pdfium-review.googlesource.com/dashboard/self
2- http://dev.chromium.org/developers/contributing-code
3- https://cla.developers.google.com/clas
> --
> You received this message because you are subscribed to the Google Groups
> "pdfium" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pdfium+un...@googlegroups.com.
> To post to this group, send email to pdf...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pdfium/4c9890ff-6709-4f12-8092-b73baca1932a%40googlegroups.com.

sheetal gowda

unread,
Oct 12, 2018, 7:16:14 AM10/12/18
to pdfium
Hello,
I tried using your patch. but am getting following error while generating args. please specify how to resolve it. thanks in advance.
WindowsError: [Error 2] The system cannot find the file specified
ERROR at //build/config/ios/ios_sdk.gni:100:21: Script returned non-zero exit code.
  _ios_sdk_result = exec_script(script_name, ios_sdk_info_args, "scope")


Reply all
Reply to author
Forward
0 new messages