ObjectiveRocks icon indicating copy to clipboard operation
ObjectiveRocks copied to clipboard

Can't use as a dependency within another cocoapod project.

Open mbalex99 opened this issue 7 years ago • 10 comments

I'd love to build a project, mine is named Liquid, that uses ObjectiveRocks however if you add the library you can't compile the pod.

  s.dependency 'ObjectiveRocks'

The compiler can't seem to find certain headers:

image

mbalex99 avatar Jun 27 '18 03:06 mbalex99

@mbalex99 Hey there, the headers in question are not available in the iOS target, because it only contains the RocksDB Lite version.

You could try to add these to the Preprocessor Macros of your project.

ROCKSDB_LITE=1 NROCKSDB_THREAD_STATUS=1

You also could add this to your Podfile:

post_install do |installer_representation|
    installer_representation.pods_project.targets.each do |target|
        if target.name == "Pods-ObjectiveRocks"
            target.build_configurations.each do |config|
                config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'ROCKSDB_LITE =1', 'NROCKSDB_THREAD_STATUS=1']
            end
        end
    end
end

Let me know if this helps. If not, I would investigate this further 😉

Haven't tried this directly in a project, just typed it down here.

iabudiab avatar Jun 27 '18 20:06 iabudiab

Thanks so much!!

Hmm that's what I've been trying:

Here's a dummy project that shows what I'm doing: https://github.com/mbalex99/rocksdb-liquid

You can open Examples/Liquid.xcworkspace and if you build it you will get an Error

In the podspec You can see that I'm doing this:

  s.dependency 'ObjectiveRocks'
  shared_ios_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'ROCKSDB_LITE=1 IOS_CROSS_COMPILE=1 NROCKSDB_THREAD_STATUS=1' }
  s.ios.pod_target_xcconfig = shared_ios_xcconfig
  s.ios.user_target_xcconfig = shared_ios_xcconfig

mbalex99 avatar Jun 27 '18 20:06 mbalex99

I'll give it a go now. I'll let you know when I find anything 👍

iabudiab avatar Jun 27 '18 20:06 iabudiab

Ah this is what I had to do

  1. add this to the podspec
  s.dependency 'ObjectiveRocks'
  s.ios.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'ROCKSDB_LITE=1 IOS_CROSS_COMPILE=1 NROCKSDB_THREAD_STATUS=1' }
  1. And in the YourCocoapodProject_Tests target go to Build Settings and go to Preprocessor Macros_ and add ROCKSDB_LITE=1 IOS_CROSS_COMPILE=1 NROCKSDB_THREAD_STATUS=1 to both Debug and Release

🤔 I wonder what we can do not have to add this so people can build rich experience on top of ObjectiveRocks

mbalex99 avatar Jun 27 '18 20:06 mbalex99

Yes, that's what I meant with the macros. And you're right, it is not ideal to have to add these manually to the project.

The most strait-forward way to tackle this would be to provide a separate pod for each platform, which I'm not really fond of 😞

I'll browse the Cocoapods docs, maybe I'll find something there.

iabudiab avatar Jun 27 '18 20:06 iabudiab

I see! I can't seem to find too much on Cocoapods repo about how do do this effectively.

mbalex99 avatar Jun 27 '18 21:06 mbalex99

Same here, no luck in the docs.

It seem that the pos_install hook is the only Cocoapods way to achieve this.

iabudiab avatar Jun 27 '18 21:06 iabudiab

@mbalex99 It's strange that you'd need to add those since they're already defined in the podspec itself: https://github.com/iabudiab/ObjectiveRocks/blob/develop/ObjectiveRocks.podspec#L126 These get pulled in during a normal pod install

Might be worth asking this on StackOverflow.com or https://github.com/CocoaPods/Core

iwasrobbed-ks avatar Jul 09 '18 19:07 iwasrobbed-ks

@rob-keepsafe The problem is the test target. It seems that CocoaPods does not add those definitions to it.

iabudiab avatar Jul 09 '18 19:07 iabudiab

I had same issue with test project, just added it to test project as dependency and issue goes away.

ex3ndr avatar Sep 07 '19 22:09 ex3ndr