如何在IOS上使用Cocoapods的Boost?

时间:2015-04-01 13:13:38

标签: ios boost cocoapods

有没有人成功地将Cocoapods与Boost pod一起使用?

我不明白它似乎没有完全安装。 pod安装到空白项目后,我得到以下内容。我缺少一步吗?

enter image description here

这是我安装的输出

pod install --verbose

Analyzing dependencies

Updating spec repositories
  $ /Applications/XCode.app/Contents/Developer/usr/bin/git rev-parse  >/dev/null 2>&1
  $ /Applications/XCode.app/Contents/Developer/usr/bin/git rev-parse  >/dev/null 2>&1
Updating spec repo `master`
  $ /Applications/XCode.app/Contents/Developer/usr/bin/git pull --ff-only
  Already up-to-date.

CocoaPods 0.36.3 is available.
To update use: `gem install cocoapods`

For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.


Inspecting targets to integrate
  Using `ARCHS` setting to build architectures of target `Pods`: (``)
  Using `ARCHS` setting to build architectures of target `Pods-PodBoost`: (``)

Resolving dependencies of `Podfile`
Starting resolution (2015-04-01 15:48:56 +0300)
Creating possibility state for boost (~> 1.57) (1 remaining)
  Attempting to activate boost (1.57.0)
  Activated boost at boost (1.57.0)
  Requiring nested dependencies (boost/string_algorithms-includes (= 1.57.0), boost/shared_ptr-includes (= 1.57.0), boost/pointer_cast-includes (= 1.57.0), boost/numeric-includes (= 1.57.0), boost/preprocessor-includes (= 1.57.0), boost/math-includes (= 1.57.0), boost/graph-includes (= 1.57.0))
  Creating possibility state for boost/string_algorithms-includes (= 1.57.0) (1 remaining)
    Attempting to activate boost/string_algorithms-includes (1.57.0)
    Activated boost/string_algorithms-includes at boost/string_algorithms-includes (1.57.0)
    Requiring nested dependencies ()
    Creating possibility state for boost/shared_ptr-includes (= 1.57.0) (1 remaining)
      Attempting to activate boost/shared_ptr-includes (1.57.0)
      Activated boost/shared_ptr-includes at boost/shared_ptr-includes (1.57.0)
      Requiring nested dependencies ()
      Creating possibility state for boost/pointer_cast-includes (= 1.57.0) (1 remaining)
        Attempting to activate boost/pointer_cast-includes (1.57.0)
        Activated boost/pointer_cast-includes at boost/pointer_cast-includes (1.57.0)
        Requiring nested dependencies ()
        Creating possibility state for boost/numeric-includes (= 1.57.0) (1 remaining)
          Attempting to activate boost/numeric-includes (1.57.0)
          Activated boost/numeric-includes at boost/numeric-includes (1.57.0)
          Requiring nested dependencies ()
          Creating possibility state for boost/preprocessor-includes (= 1.57.0) (1 remaining)
            Attempting to activate boost/preprocessor-includes (1.57.0)
            Activated boost/preprocessor-includes at boost/preprocessor-includes (1.57.0)
            Requiring nested dependencies ()
            Creating possibility state for boost/math-includes (= 1.57.0) (1 remaining)
              Attempting to activate boost/math-includes (1.57.0)
              Activated boost/math-includes at boost/math-includes (1.57.0)
              Requiring nested dependencies ()
              Creating possibility state for boost/graph-includes (= 1.57.0) (1 remaining)
                Attempting to activate boost/graph-includes (1.57.0)
                Activated boost/graph-includes at boost/graph-includes (1.57.0)
                Requiring nested dependencies ()
Finished resolution (8 steps) (Took 0.007472 seconds) (2015-04-01 15:48:56 +0300)
Unactivated: 
Activated: boost, boost/string_algorithms-includes, boost/shared_ptr-includes, boost/pointer_cast-includes, boost/numeric-includes, boost/preprocessor-includes, boost/math-includes, boost/graph-includes

Comparing resolved specification to the sandbox manifest
  A boost

Downloading dependencies

-> Installing boost (1.57.0)
 > Http download
   $ /usr/bin/curl -f -L -o /Users/ryanheitner/Projects/PodBoost/Pods/boost/file.tgz "http://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.tar.gz" --create-dirs
     % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                    Dload  Upload   Total   Spent    Left  Speed
  0   353    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0   423    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0   337    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100 70.0M  100 70.0M    0     0  2744k      0  0:00:26  0:00:26 --:--:-- 3007k
   $ /usr/bin/tar xfz /Users/ryanheitner/Projects/PodBoost/Pods/boost/file.tgz -C /Users/ryanheitner/Projects/PodBoost/Pods/boost
  - Running pre install hooks

Generating Pods project
  - Creating Pods project
  - Adding source files to Pods project
  - Adding frameworks to Pods project
  - Adding libraries to Pods project
  - Adding resources to Pods project
  - Linking headers
  - Installing targets
    - Installing target `Pods-PodBoost` iOS 8.2
  - Running post install hooks
  - Writing Xcode project file to `Pods/Pods.xcodeproj`
  - Writing Lockfile in `Podfile.lock`
  - Writing Manifest in `Pods/Manifest.lock`

1 个答案:

答案 0 :(得分:2)

为什么没有列出Pod?

这是boost不是Xcode项目的工件,只是一组文件。此外,您会发现boost内部目录位于${PODS_ROOT}/boost内,在构建设置标题搜索路径中引用。这是你使用Pod获得的。

Pod&提升层次结构

需要在boost中嵌套../Pods/boost/boost才能允许库中的文件引用自身,如下所示:

#include "boost/date_time/posix_time/posix_time_config.hpp"

如果让操作完成:(压缩时boost库的数量超过100 MB)

Downloading dependencies
Installing boost (1.57.0)
Generating Pods project
Integrating client project

...当你在项目中没有看到它时,你会发现它在源代码树中:

enter image description here

您可以参考:

#import "boost/date_time.hpp"

并开始处理其他紧迫问题,例如找到#include <cstdlib>,这完全是另一个主题。

Objective-C ++编译

为了编译boost,这是一个 C ++ 库,您需要从 C ++ 源文件中显式引用它(不是 C 来源,.m)中的默认值,或采用compiling a C++ class in Xcode: error during compilation: stl vector中列出的替代解决方案。

.mm文件中,包括以下两个测试行:

#include <cstdlib> // Proof of concept
#import "boost/date_time.hpp"

为了这个例子,我已将main.m重命名为main.mm。 由于Pod未导入任何.ipp文件,因此您可以在构建设置中的预处理器宏中添加NO_BOOST_DATE_TIME_INLINE=1。这样做,您将获得大约十几个警告,如下面的警告,以及成功的编译,无需手动导入。

  

隐式转换失去整数精度:&#39; long&#39;到&#39; hour_type&#39; (又名&#39; int&#39;)

编辑:删除了非主题手动导入,不是必需的