Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

:local pod development on a project that includes libraries #809

Closed
mattyohe opened this Issue · 9 comments

8 participants

@mattyohe

When writing a Podspec for a library, it has been the case that I would write something like:

Pod::Spec.new do |s|
⋮
s.xcconfig  =  { 'LIBRARY_SEARCH_PATHS' => '"$(PODS_ROOT)/MySDK/"' }
⋮
end

However, if I want to develop this as a :local pod, PODS_ROOT is not going to point to the correct library path.

Is there a solution to deal with this?

If not, would it be possible to have a PODS_ROOT-like variable that has knowledge of the pod being local, and thus pointing to the correct local pod location?

@alloy
Owner

Is there a solution to deal with this?

At the moment there is no built-in way to solve this. While not a good final solution, you could workaround it during development by adding some Ruby code like:

s.xcconfig  =  { 'LIBRARY_SEARCH_PATHS' => "#{File.join(File.dirname(__FILE__), 'subdir-in-repo')}" }

If not, would it be possible to have a PODS_ROOT-like variable that has knowledge of the pod being local, and thus pointing to the correct local pod location?

We should probably introduce env variables for each individual lib, so that we can make it point elsewhere with :local.

@johnsmule

The workaround seems to have broken with release .17.0. The clientspec gets copied into the "Pods/Local Podspecs" directory and the library search path ends up pointing to that.

We'd like a fix for this as well.

@MaxGabriel

I wasn't able to make this work locally, either. For anyone trying this, I had the most success following the lead of https://github.com/CocoaPods/Specs/tree/master/AppXperience

@ewangke

@alloy I tried with absolute path of my local libs but got a link error in build time.
Is there any way to get it right?

BTW, I also tried with your solution and failed. File.dirname(__FILE__) returns the podspec path, which is copied to the Pods/Local Podspes folder and lib files cannot be found there.

@johnsmule

So, I have a new hack that works with recent versions of cocoapods:

def s.pre_install(pod, target_installer)
  self.xcconfig = {
    'LIBRARY_SEARCH_PATHS' => File.join(target_installer.sandbox.local_pods['your-spec-name'], 'subdir-in-repo') }
  }
end 

Seems very fragile, so would love a real solution that won't get broken by future cocoapod updates.

@alloy
Owner

@johnsmule You should nowadays be able use the root method of the PodRepresentation pre_install hook argument to get the path to the pod's source.

Seems very fragile, so would love a real solution that won't get broken by future cocoapod updates.

We don’t make any promises till v1 (as described in the SemVer spec). Keeping the code to a minimum, like you have done, is the best solution. Also be sure to create a ticket if there is no supported way (e.g. a spec attribute) to do something that you feel should be supported by default.

@fabiopelosin fabiopelosin closed this issue from a commit
@fabiopelosin fabiopelosin [Changelog]
Closes #743
Closes #1186
Closes #809
Closes #1075
01f2a94
@kitschpatrol

I know this is closed... but I wanted to leave a note for others since I lost some time trying to integrate a compiled framework into my pod. (Installation was working fine from the repo, but broken on a local path.)

In my case, the solution (for frameworks, at least) was to use the vendored_frameworks file pattern instead of preserve_paths and xcconfig.

So, in my Podspec, this:

Pod::Spec.new do |s|
  # [...]
  s.preserve_paths = 'FLACiOS.framework'
  s.frameworks = 'FLACiOS'
  s.xcconfig  =  { 'FRAMEWORK_SEARCH_PATHS' => '"$(PODS_ROOT)/LPSpeechToText"' }
end

Became this:

Pod::Spec.new do |s|
  # [...]
  s.vendored_frameworks = 'FLACiOS.framework'
end

Thanks!

@iSevenDays

@kitschpatrol thank you! I was trying for hours to get the right solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.