apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 987 forks source link

Plugin creates an empty Podfile for some reason (problem for build services) #1365

Open AshleyScirra opened 1 year ago

AshleyScirra commented 1 year ago

Bug Report

Problem

For some reason, including cordova-plugin-inappbrowser ends up creating an empty Podfile in the Xcode project. If you then run pod install on the project, it ends up broken - you get a weird error:

The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

I've searched the web, tried deleting files and clean rebuilding, etc. etc. I could not find any workaround. It seems to just leave a permanently broken Xcode project.

This might sound weird - don't run pod install, right? But this caused us serious problems. We run a build service that builds people's Cordova projects for them. We'd like our build service to run pod install, but we can't, as it might break the project if it uses cordova-plugin-inappbrowser. So ideally cordova-plugin-inappbrowser would not create an empty Podfile.

What is expected to happen?

cordova-plugin-inappbrowser should not create an empty Podfile, as it does not appear to actually use any pods.

What does actually happen?

cordova-plugin-inappbrowser creates an empty Podfile that looks like this:

# DO NOT MODIFY -- auto-generated by Apache Cordova

platform :ios, '11.0'

target 'HelloWorld' do
    project 'HelloWorld.xcodeproj'

end

If you run pod install with that, you get weird errors and the Xcode project is basically broken. However in some cases we want to automatically run pod install, and this complicates that.

Information

Command or Code

The smallest repro is to run these commands:

cordova create hello com.example.hello HelloWord cd hello

Now edit config.xml and add the line:

<plugin name="cordova-plugin-inappbrowser"/>

Then run: cordova platform add ios cordova prepare

Now look in the subfolder platforms\ios. There's an empty Podfile. If cordova-plugin-inappbrowser is not included, then no Podfile is created.

I'm not sure what's going on here but would appreciate any insight in to why this file is created, or if any change could be made to avoid creating it. Thanks for any help!

Environment, Platform, Device

iOS, Cordova v11.1.0, cordova-plugin-inappbrowser@5.0.0

Checklist

jcesarmobile commented 9 months ago

Moved the issue to cordova-ios since this behavior happens with any plugin, not just with InAppBrowser.

But not really sure why would you want to run pod install in your user apps. Cordova will already run pod install if the project has plugins with CocoaPods dependencies. But also agree that it shouldn't create a Podfile if the project doesn't have any plugin that needs CocoaPods dependencies.

I can't reproduce your problem, do your users commit their ios folder? that could cause the issue you mention if the CocoaPods version of your users don't match the CocoaPods version in your servers as the version is stored in the Podfile.lock.

breautek commented 9 months ago

cordova-ios@7 behaviour seems consistent with cordova-ios@6 behaviour in this regard. If this is a regression, it's a regression that's been in the codebase for quite some time.

But I have a feeling that the behaviour has always been this way.

The Podfile only gets generated when a plugin is added. But I also agree in that the Podfile should only be generated if it's actually needed.