Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local path for s.source in podspec #216

Closed
sunil-chayagol opened this issue Aug 9, 2018 · 26 comments
Closed

local path for s.source in podspec #216

sunil-chayagol opened this issue Aug 9, 2018 · 26 comments

Comments

@sunil-chayagol
Copy link

instead of giving git path i have given the below path for s.source in my podspec
{:path=>"~/Users/sunil/workspace/MyFramework"}
validation does not pass and gives message as unsupported download strategy. is there a way to give local path instead of git path.

@davidperrenoud
Copy link

Apparently :path is not officially supported in CocoaPods 1.6.0:
https://guides.cocoapods.org/syntax/podspec.html#source

I am not sure why it was removed. 😕

@Katsz
Copy link

Katsz commented Mar 12, 2019

Can we get any response? This was so convenient

@Katsz
Copy link

Katsz commented Mar 12, 2019

I do, in fact, have a workaround. But it is questionable, I'd say.

How

Assuming Podfile, local .podspec and .zip are placed in the same directory

In Podfile specify local .podspec like so:

pod 'MyFramework', :podspec => "./MyFramework.podspec"

Then, edit your .podspec as following

s.source            = { :http => 'file:' + __dir__ + '/MyFramework.zip' }

Why

__dir__ is a ruby analog for pwd in bash, so the full path will look lie file:/Users/dev/projects/MyProject/MyFramework.zip. Under the hood ruby uses curl -f -L -o %tempdir% %s.source% for http requests, and curl can be used to fetch local files

¯\_(ツ)_/¯

@xzilja
Copy link

xzilja commented Mar 16, 2019

Was really missing this feature today, workaround above works, but is so cumbersome to implement due to need of manually zipping a package. Will CocoaPods consider bringing back :path as a valid option for source. If I am correct it used to be a valid option at some point, what was the reason for removing it?

@Katsz
Copy link

Katsz commented Mar 16, 2019

@iljadaderko I was talking about binary .framework. If it's your case, you can add post-build step to your xcode project to zip your artifact.

If you're developing an open source pod, you can use :git => on local git repo. According to docs git supports file:/ URL format

@mikegb
Copy link

mikegb commented Jun 28, 2019

These workarounds are pretty surprising. Is there no way to include a framework (podspec) that's in development locally to be used within another cocoapods project? It has to be uploaded somewhere?

@Katsz
Copy link

Katsz commented Jun 28, 2019

@mikegb

¯\_(ツ)_/¯

As I've said, someone in cocoapods team decided to remove this feature a long time ago.
Yet there is not a single reason to do so.

@clsource
Copy link

clsource commented Jul 4, 2019

I solved this by executing the zip command with the @Katsz solution.

Example

zipfile = "#{__dir__}/../../artifacts/JasonComponent.zip"

Pod::Spec.new do |s|
    s.name         = "JasonComponent"
    s.version      = "1.0.0"
    s.summary      = "Jason Component"
    s.description  = "Enables of Jason Components"

    s.homepage     = "https://github.com/jasonelle/jasonette-ios"
    s.screenshots  = ""

    s.license      = { :type => "MIT", :file => "LICENSE" }
    s.authors      = { 
        "Ethan Gliechtenstein" => "https://github.com/gliechtenstein" ,
        "Camilo Castro" => "https://github.com/clsource"
    }

    system("rm -rf #{zipfile} && zip -r #{zipfile} #{__dir__} > /dev/null")

    s.source = { :http => "file://#{zipfile}"}

    s.source_files  = "src", "src/**/*.{h,m,swift}"
    s.requires_arc  = true

    s.ios.deployment_target = '8.0'
end

Then just use pod install to fetch the zip and install it 👍

@xzilja
Copy link

xzilja commented Jul 4, 2019

It works for me with empty path s.source = { :git => '' }, in your projects Podfile you just point to your package and everything works out of the box.

@slootzky
Copy link

any news for this issue?
also asked in SO

@xT-Tx
Copy link

xT-Tx commented Jul 21, 2019

This works for me:
s.source = { :git => 'file:///Users/MyName/path' } # be noted the triple-slash
My pod version is 1.7.4

@slootzky
Copy link

doesn't work for me. I'm getting : does not appear to be a git repository fatal: Could not read from remote repository

@sunnymopada
Copy link

sunnymopada commented Aug 22, 2019

@slootzky @sunil-chayagol @xT-Tx's answer working for me, Hope you are giving git repo folder path, Not the podfile folder path.

Ex:
Give file:///Users/guest/Desktop/iOS/sample-pod-example
Not file:///Users/guest/Desktop/iOS/sample-pod-example/SamplePod

Thanks @xT-Tx

@slootzky
Copy link

Thanks, I'll give that a try

@eddyfrank
Copy link

Any news on that?

Support for local :path sources would be very useful. Especially for React Native modules which are distributed as npm packages and already contain all sources as well as a .podspec file referencing to those.

PS: Since v0.60.0 react-native provides CocoaPods integration by default (https://github.com/facebook/react-native/releases/tag/v0.60.0).

@xzilja
Copy link

xzilja commented Aug 27, 2019

@eddyfrank you can just use empty git path in react native i.e. following works for me

require 'json'

package = JSON.parse(File.read(File.join(__dir__, '../..', 'package.json')))
name = 'ModuleName'

Pod::Spec.new do |s|
  s.name           = name
  s.version        = package['version']
  s.summary        = package['description']
  s.license        = package['license']
  s.author         = package['author']
  s.homepage       = package['homepage']
  s.platform       = :ios, '11.4'
  s.source         = { :git => '' }
  s.source_files   = '**/*.{h,m}'
  s.preserve_paths = '**/*.{h,m}'

  s.dependency    'React'
end

@eddyfrank
Copy link

@iljadaderko Thanks. Sounds like a workaround. However, it does not work here :(

Error on pod install or pod update:

[!] Error installing MyReactNativeModule
[!] /usr/bin/git clone  /var/folders/mq/wfwmj51j2hb5bqdv30zq2s100000gn/T/d20190827-99417-1mtb6ja --template= --single-branch --depth 1
fatal: repository '' does not exist

$ pod --version
1.7.5
$ git --version
git version 2.20.1 (Apple Git-117)

@teodorciuraru
Copy link

teodorciuraru commented Jul 21, 2020

I do, in fact, have a workaround. But it is questionable, I'd say.

How

Assuming Podfile, local .podspec and .zip are placed in the same directory

What .zip file are you referring to?

@wilau2
Copy link

wilau2 commented Aug 24, 2020

I do, in fact, have a workaround. But it is questionable, I'd say.

How

Assuming Podfile, local .podspec and .zip are placed in the same directory

In Podfile specify local .podspec like so:

pod 'MyFramework', :podspec => "./MyFramework.podspec"

Then, edit your .podspec as following

s.source            = { :http => 'file:' + __dir__ + '/MyFramework.zip' }

Why

__dir__ is a ruby analog for pwd in bash, so the full path will look lie file:/Users/dev/projects/MyProject/MyFramework.zip. Under the hood ruby uses curl -f -L -o %tempdir% %s.source% for http requests, and curl can be used to fetch local files

¯\_(ツ)_/¯

This will cause the podfile.lock file to update on every developer local environment 😢

@fahmisdk6
Copy link

I do, in fact, have a workaround. But it is questionable, I'd say.

How

Assuming Podfile, local .podspec and .zip are placed in the same directory
In Podfile specify local .podspec like so:

pod 'MyFramework', :podspec => "./MyFramework.podspec"

Then, edit your .podspec as following

s.source            = { :http => 'file:' + __dir__ + '/MyFramework.zip' }

Why

__dir__ is a ruby analog for pwd in bash, so the full path will look lie file:/Users/dev/projects/MyProject/MyFramework.zip. Under the hood ruby uses curl -f -L -o %tempdir% %s.source% for http requests, and curl can be used to fetch local files
¯\_(ツ)_/¯

This will cause the podfile.lock file to update on every developer local environment 😢

Hi, do you have any workarround on this problem?

@wilau2
Copy link

wilau2 commented Sep 16, 2020

@fahmisdk6 not yet.. Our problematic dependency is RNQualtricsDigital from react-native-qualtrics

Every time a developer installs dependencies the podfile.lock changes.

Here is their podspec:


Pod::Spec.new do |s|
  s.name         = "RNQualtricsDigital"
  s.version      = "0.0.1"
  s.summary      = "RNQualtricsDigital"
  s.description  = <<-DESC
                  RNQualtricsDigital
                   DESC
  s.homepage     = "https://api.qualtrics.com"
  s.platform     = :ios, "9.0"
  s.source_files  = "*.{h,m}"
  s.requires_arc = true
  s.dependency "Qualtrics"
  s.source       = { :http => 'file:' + __dir__ + '/RNQualtricsDigital.zip' }
  s.author       = "Qualtrics"
  s.dependency "React"
end

This is the node_module:

image

@henninghall
Copy link

@wilau2 We're also having this issue with Qualtrics, found any workaround yet?

@alloy
Copy link
Member

alloy commented Dec 3, 2020

I’m unsure what people refer to when they say that this used to work, perhaps it did but was a fluke as the :path option is solely meant to be used by a user in their Podfile, not in a podspec.

In the case of React Native and pods being shipped inside npm packages, “auto-linking” uses the Podfile :path option under the hood. If you are not using “auto-linking”, then you can specify the :path option in your Podfile explicitly.

In short, the source property of a podspec will actually never be used, so I would just point it to a helpful URL, e.g. the repo.

@alloy alloy closed this as completed Dec 3, 2020
@alloy
Copy link
Member

alloy commented Dec 3, 2020

I missed context about what repo this was on, I incorrectly assumed it was the main repo, so I better understand your point now. I can’t speak for the current maintainers, only why historically this has been as it was. I would suggest you open a issue on the main repo to clearly discuss your needs and how they deviate from normal CP users.

@wilau2
Copy link

wilau2 commented Dec 7, 2020

@wilau2 We're also having this issue with Qualtrics, found any workaround yet?

@henninghall, no.. we have some discussions with Qualtrics support and it's not the best experience.
The SDK is not open source... so we can't really fix it ourselves, I suggest you write to them as well so that they feel more pressure coming from a wider group.

@aluco100
Copy link

Hi There,

What happens if the pod is private?

Best Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests