cocoapods-generate
cocoapods-generate copied to clipboard
Is there a way to ignore existing Podfile?
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).
--no-use-podfile
should work
--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
Btw, the workaround that I ended up using is creating (empty) Podfile in the same directory as the podspec.
In that example, it doesn’t look like you’re actually passing the flag?
@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
I need --no-use-podfile
too.