c++ - 如何用cocoapods修改编译顺序?

标签 c++ ios xcode header cocoapods

对于我的 xcode 项目,我设置了 cocoapods,它使用我的克隆存储库中的 Eigen 3.2.5。我把它设置在哪里

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

因为似乎如果我有另一个包含该项目的项目,除非我将这些文件公开,否则它将无法工作。

但是,每当我进行此类设置时,LLVM 7.0 似乎都会尝试获取错误的头文件。例如,我的 eigen Pod 中有一个 Block.h,它会尝试为 UIKit 编译 C++ Block.h (这完全是 objective-C,当然它会失败,因为在 eigen 的 Block.h 中有大量的 C++ 代码)。请注意,UIKit 还使用了一个 Block.h(与 Eigen 中的同名),但显然它在谈论 Block.h这很可能在 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:

我该如何修复它,以便 UIKit.h 在正确的位置寻找它自己的 Block.h 而不是在我的 Eigen cocoapod 中?

或者,我如何设置我的 Eigen cocoapod,这样如果项目 A 使用 eigen,但项目 B 使用项目 A 作为 cocoapod,那么项目 B 实际上找到了 eigen 并且不会提示“Eigen 文件,如 Eigen/密密麻麻找不到”?

最佳答案

如果有人好奇,解决方案是用适当的文件结尾命名所有公共(public)头文件(Dense -> Dense.h)。此外,在那之后,我将分享一个 Podspecs 的工作版本,因为这花了我一个多星期的时间才开始工作。

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

关于c++ - 如何用cocoapods修改编译顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35168731/

相关文章:

c++ - 如果我不给它一点额外的空间,弦就会发疯。谁能解释这里发生了什么?

c++ - CRTP相对于抽象类的好处?

ios - 我的网站不断将 iPhone (Safari) 用户重定向到其他 IP,导致超时

iOS swift 如何知道即使应用程序被终止,是否有任何联系人已更新

swift - 带有大标题 iOS 11 的导航栏图像

swift - 通过ViewController.swift文件调用GameScene.swift文件【Swift 3.0 Spritekit】

c++ - 错误 MSB6006 : "cmd.exe" exited with code 1 running QT application

c++ - QT 在 QGraphicsitem 上绘制矩形

ios - Admob 框架未找到 GoogleMobileAds 链接器错误

ios - 为什么我发布的 ios 应用程序似乎是用我的开发者 key 签名的?