cocoapods-generate icon indicating copy to clipboard operation
cocoapods-generate copied to clipboard

Is there a way to ignore existing Podfile?

Open grigorye opened this issue 5 years ago • 6 comments

I'm currently in progress of working on a module inside a big project. The module is kept in a subfolder of the root where the project Podfile is located. I'm not interested at the moment in integration with the project. However when I do pod gen in the subfolder, it detects the Podfile at the upper level and tries to interpret it, producing some warnings (irrelevant to the module I work on/potentially triggered due to loading Podfile multiple times) and actually misbehaving e.g. by outputting Open subfolder/gen/Module/Module.xcworkspace to work on Module (i.e. path is relative to Podfile not to the current directory).

The workaround for me is to rename Podfile to e.g. Podfile.ignored. But it would be great to have a way to ignore the Podfile by specifying e.g. --no-use-podfile or something like that. Probably I miss something (I'm not experienced with Ruby gems/command line option parsers).

grigorye avatar Aug 12 '19 10:08 grigorye

--no-use-podfile should work

segiddins avatar Oct 25 '19 08:10 segiddins

--no-use-podfile should work

Unfortunately it doesn't.

$ bundle show cocoapods
/Users/gentin/.transient/bundle/vendor/gems/cocoapods-1.8.4
$ bundle show cocoapods-generate
/Users/gentin/.transient/bundle/vendor/gems/cocoapods-generate-1.6.0
$ cat Gemfile
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# gem "rails"

gem "cocoapods-generate", "~> 1.6"

gem "cocoapods", "~> 1.8"
$ ls
Example/		Gemfile.lock		Module/			README.md
Gemfile			LICENSE			Module.podspec		_Pods.xcodeproj@
$ ls ..
Module/		Podfile
$ cat ../Podfile
bar
$ bundle exec pod gen --no-use-podfile
[in /Users/gentin/tmp/no-use-podfile]
[!] Error computing podfile,
[!] Invalid `Podfile` file: undefined local variable or method `bar' for #<Pod::Podfile:0x00007ff549863b48>.

 #  from /Users/gentin/tmp/no-use-podfile/Podfile:1
 #  -------------------------------------------
 >  bar
 #  -------------------------------------------
....
$ mv ../Podfile ../Podfile.bak
$ bundle exec pod gen --no-use-podfile

Generating Module in `gen/Module`
Open `gen/Module/Module.xcworkspace` to work on Module

grigorye avatar Oct 25 '19 13:10 grigorye

Btw, the workaround that I ended up using is creating (empty) Podfile in the same directory as the podspec.

grigorye avatar Oct 25 '19 13:10 grigorye

In that example, it doesn’t look like you’re actually passing the flag?

segiddins avatar Oct 25 '19 23:10 segiddins

@segiddins Uh, sorry, it was my error during "copy-pasting", it had --no-use-podfile in all invocations - corrected the example. (Just in case, I checked/redid it again).

This is the script of the invocations:

mkdir no-use-podfile
cd no-use-podfile/

# I use (brewed) cocoapods to create the module from standard template; confirm the defaults when asked.
pod lib create Module

# Make "bad" Podfile to illustrate the problem
echo bar > Podfile
cd Module/
# Bundle "recent" cocoapods/cocoapods-generate
bundle init
bundle add cocoapods
bundle add cocoapods-generate
# Try first, this fails due to usage of (bad) Podfile (that is the problem)
bundle exec pod gen --no-use-podfile

# Illustrate the workaround
mv ../Podfile ../Podfile.bak
# This succeeds
bundle exec pod gen --no-use-podfile

# This illustrates another workaround (empty Podfile alongside .podspec)
mv ../Podfile.bak ../Podfile
echo > Podfile
# This succeeds, because (empty) Podfile is "consulted" (instead of one in the parent directory)
bundle exec pod gen --no-use-podfile

grigorye avatar Oct 25 '19 23:10 grigorye

I need --no-use-podfile too.

yuhanle avatar Oct 30 '20 03:10 yuhanle