David T.
David T.

Reputation: 23399

How to modify compilation order with cocoapods?

For my xcode project, i have cocoapods set up where it uses Eigen 3.2.5 from my cloned repository. I have it set up where

  "source_files": ["Eigen/*", "Eigen/**/*"],
  "public_header_files": ["Eigen/*", "Eigen/**/*"],

because it seems that if i have another project that includes this project, it won't work unless i make these files public.

However, whenever i do this kind of setup, LLVM 7.0 seems to try to grab the wrong header files. For example, i have a Block.h in my eigen Pod, and it tries to compile the C++ Block.h for UIKit (which is totally objective-C and of course it will fail because there is a ton of C++ code in eigen's Block.h). Note that UIKit also uses a Block.h (same name as the one in Eigen), but obviously it is talking about the Block.h that is prolly in Objective-C.

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:11:9: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:11:

How do i fix it so that UIKit.h is looking in the correct spot for its own Block.h and not inside my Eigen cocoapod?

Alternatively, how do i set up my Eigen cocoapod so that if Project A uses eigen, but Project B uses project A as a cocoapod, then project B ACTUALLY finds eigen and doesn't complain that "Eigen files, like Eigen/Dense can not be found"?

Upvotes: 0

Views: 372

Answers (1)

David T.
David T.

Reputation: 23399

In case anyone is curious, The solution was to name all public header files with the appropriate file ending (Dense -> Dense.h). Also, after that, i have a working version of Podspecs that i will share, since this took me over a week to get working.

Pod::Spec.new do |s|
  s.name    = "eigen"
  s.version = "3.2.5"
  s.summary = "Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms."
  s.homepage    = "http://eigen.tuxfamily.org/index.php?title=Main_Page"
  s.license = { :type => "MPL2",
                    :file => "COPYING.LGPL" }
  s.author  = "Benoît Jacob", "Gaël Guennebaud"
  s.source  = { :git => "YOUR OWN CLONED GIT REPO FROM MERCURIAL", :tag => "3.2.5" }

  s.ios.deployment_target = "5.0"

  s.compiler_flags = '-DEIGEN_MPL2_ONLY'

  s.source_files = "Eigen/*.*", "Eigen/**/*.*"
  s.public_header_files = 'Eigen/*.h'
  s.header_mappings_dir = 'Eigen'

  s.dependency 'boost/numeric-includes', '~> 1.59.1'
  s.dependency 'boost/preprocessor-includes', '~> 1.59.1'

  s.xcconfig = { 
    'HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/eigen"',
  }
end

Upvotes: 1

Related Questions