CocoaPods / cocoapods-packager

CocoaPods plugin which allows you to generate a static library from a podspec.
Other
1.14k stars 220 forks source link

local path for s.source in podspec #216

Closed sunil-chayagol closed 3 years ago

sunil-chayagol commented 6 years ago

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 commented 5 years ago

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 commented 5 years ago

Can we get any response? This was so convenient

Katsz commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

any news for this issue? also asked in SO

xT-Tx commented 5 years ago

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

slootzky commented 5 years ago

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

sunnymopada commented 5 years ago

@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 commented 5 years ago

Thanks, I'll give that a try

eddyfrank commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 3 years ago

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

alloy commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@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 commented 2 years ago

Hi There,

What happens if the pod is private?

Best Regards