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

Customization of Podfile generated by cordova-ios #1512

Open
faugusztin opened this issue Nov 29, 2024 · 0 comments
Open

Customization of Podfile generated by cordova-ios #1512

faugusztin opened this issue Nov 29, 2024 · 0 comments

Comments

@faugusztin
Copy link

Feature Request

Motivation Behind Feature

Sometimes developers need support for customization of Podfile, for example to add pod hooks or other items which are not supported by the podspec configuration tag.
One of common use cases i would need this is for removing IPHONEOS_DEPLOYMENT_TARGET from Pods automatically after installing the Pods using post_install hook, where the Pods specify lower deployment target than the app itself (which then causes build failures).

The code at moment of writing this feature request has Podfile template hardcoded in the source code of Podfile.js.

Feature Description

There are few possible options which can achieve the intended result (customized Podfile contents), i suspect first we would have to pick the solution and then implement it:

  • allow overriding of Podfile template - instead of having hardcoded Podfile template in Podfile.js, it could be a file named Podfile.template inside templates/project folder, copied to the platforms/ios folder when platform is added, and then developer could modify this template using any existing hooks. And Podfile.js would then use the template inside the platforms/ios folder for any Podfile rewrite.
    For this option to not break existing platforms the getTemplate method would have to have the hardcoded template still present as fallback, if the Podfile.template file doesn't exist in platforms/ios.
  • allow appending custom content to the existing template by providing a customization file - user would have to have a file with specific name at root of the project or copied to the root folder of platform, which would be then picked up by the getTemplate method inside Podfile.js and it's contents appended to the automatically generated content. While not identical in implementation, this idea is inspired by Android's build-extras.gradle or repositories.gradle. As podfiles do not have support for 'include files', the contents of the file would have to be copied to the actual Podfile on every Podfile regeneration by cordova-ios.
    This option would not break existing projects, as the base of template would stay same in getTemplate method, and the customization file would be used only if it exists inside the platforms/ios folder.
  • add after_podfile_change hook, which would be called right after Podfile is written - allows the developer to modify the generated Podfile before pod install --verbose is executed.
    This wouldn't break existing projects either, as the user would have to add the hook himself.
  • allow adding Podfile hooks using config.xml/plugin.xml - a new tag could reference a file inside config.xml/plugin, which would contain a content which that app/plugin wants added to Podfile. It would have to be a file, as typical customization of Podfile would be a multiline string. This would allow every plugin to add their own content to Podfile. Unfortunately because podspec is not allowed in config.xml, this would be either separate from podspec of we would have to allow podspec tag inside config.xml.
    This would not break existing projects unless they somehow had podspec tags inside config.xml already, or if the new XML tag would conflict with some third party plugins XML tags.

Alternatives or Workarounds

There are two alternatives/workarounds, but personally i consider both of them suboptimal:

  • patch node_modules/cordova-ios/lib/Podfile.js getTemplate method as part of build process with a modified hardcoded template, which includes the desired changes (in my case a post_install hook). Thus any time cordova-ios rewrites Podfile, it rewrites it with my modified template.
  • for my use case of removing deployment targets, i can use before_compile hook, where my hook modifies the Podfile inside platforms/ios, executes pod install --verbose one more time, and that performs the needed changes, thus compilation doesn't fail. But this solution might not be right for other use cases.
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

1 participant