Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Boost with Cocoapods on IOS?

Has anyone succeeded in using Cocoapods with the Boost pod ?

I do not understand it does not seem to install fully. After pod Install into a blank project I get the below. Is there a step I am missing ?

enter image description here

This is the output from my install

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`
like image 678
Ryan Heitner Avatar asked Apr 01 '15 13:04

Ryan Heitner


1 Answers

Why is the Pod not listed?

This is an artifact of boost not being an Xcode project, merely a set of files. In addition, you will find that the boost inner directory is located properly inside ${PODS_ROOT}/boost, referenced in Header Search Path of Build Settings. This is what you gain by using the Pod.

Pod & Boost hierarchy

The nesting of boost in ../Pods/boost/boost is required to allow the files in the library to refer to themselves as in:

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

If you let the operation complete: (the boost library is well over 100 MB when zipped)

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

...the while you do not see it in your project, you will find it is in the source tree:

enter image description here

You can reference it:

#import "boost/date_time.hpp"

and start dealing with other pressing issues, like locating #include <cstdlib>, which is another topic entirely.

Objective-C++ Compilation

In order to compile boost, which is a C++ library, you need to explicitly refer to it from C++ source files (not C sources, which are the default in .m), or adopt alternative solutions listed in compiling a C++ class in Xcode: error during compilation: stl vector.

From a .mm file, include these two test lines:

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

For the sake of this example, I have renamed main.m into main.mm. Since the Pod did not import any of the .ipp files, you could add NO_BOOST_DATE_TIME_INLINE=1 in Preprocessor Macros in Build Settings. Doing so, you will get about a dozen of warnings, like the one below, and a successful compilation, without manual import.

Implicit conversion loses integer precision: 'long' to 'hour_type' (aka 'int')


Edit: deleted an off-topic manual import, not required


like image 166
SwiftArchitect Avatar answered Oct 19 '22 23:10

SwiftArchitect