如何在IOS上使用Cocoapods的Boost?

Rya*_*ner 10 boost ios cocoapods

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

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

在此输入图像描述

这是我安装的输出

pod安装--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`
Run Code Online (Sandbox Code Playgroud)

Swi*_*ect 3

为什么 Pod 没有列出?

boost这并不是一个 Xcode 项目,而是一组文件的产物。另外,您会发现boost内部目录位于正确的内部,在构建设置标题搜索路径${PODS_ROOT}/boost中引用。这就是您通过使用 Pod 获得的收益。

Pod 和 Boost 层次结构

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

#include "boost/date_time/posix_time/posix_time_config.hpp"
Run Code Online (Sandbox Code Playgroud)

如果让操作完成:(boost压缩后该库远超过 100 MB)

Downloading dependencies
Installing boost (1.57.0)
Generating Pods project
Integrating client project
Run Code Online (Sandbox Code Playgroud)

...虽然您在项目中看不到它,但您会发现它位于源代码树中:

在此输入图像描述

你可以参考一下:

#import "boost/date_time.hpp"
Run Code Online (Sandbox Code Playgroud)

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

Objective-C++ 编译

为了编译C++boost库,您需要从C++源文件(不是C源文件,这是 中的默认值)显式引用它,或者采用在 Xcode 中编译 C++ 类中列出的替代解决方案:编译期间出错:STL矢量.m

.mm文件中包含以下两条测试行:

#include <cstdlib> // Proof of concept
#import "boost/date_time.hpp"
Run Code Online (Sandbox Code Playgroud)

为了这个例子,我已重命名main.mmain.mm. 由于Pod没有导入任何文件.ipp,您可以在Build SettingsNO_BOOST_DATE_TIME_INLINE=1中添加Preprocessor Macros。这样做,您将收到大约一打警告(如下所示),并且编译成功,无需手动导入。

隐式转换丢失整数精度:“long”到“hour_type”(又名“int”)


编辑:删除了一个偏离主题的手动导入,不是必需的