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

Support :podspec as alternative to :path option #135

Open
Legion2 opened this issue Sep 23, 2021 · 4 comments
Open

Support :podspec as alternative to :path option #135

Legion2 opened this issue Sep 23, 2021 · 4 comments

Comments

@Legion2
Copy link

Legion2 commented Sep 23, 2021

Currently local a podspec can only be included using the --local-sources option which is a directory that may contain multiple podspec files for multiple pod dependencies. This option is used for local dependencies where the source is also local. However to include a library which itself does not have a podspec, a podspec can be created outside a spec repository and refrerenced in the podfile according to https://guides.cocoapods.org/syntax/podfile.html#pod.

If a podspec is available from another source outside of the library’s repository. Consider, for instance, a podspec available via HTTP:

pod 'JSONKit', :podspec => 'https://example.com/JSONKit.podspec'

The :podspec option can also be a local path, however currently pod gen has no option to specify the :podspec for a pod dependency.

Often it is not required to use the :podspec, because the :path option works for local podspecs as well. However, the installation process of :podspec and :path are different, which results in failures. For example the third party podspecs of react-native can not be included with the :path option.

@justinseanmartin
Copy link
Collaborator

If I'm understanding correctly, you'd like to use pod gen to generate a workspace for a remote podspec? Did I get that right? Does it work to have a local podspec w/ a dependency on the remote one (e.g. react-native) and you generate the workspace for both of those? I think we'd need to know more about your specific use case and what problem you're trying to solve by trying to generate a workspace for a remote podspec.

@Legion2
Copy link
Author

Legion2 commented Sep 29, 2021

If I'm understanding correctly, you'd like to use pod gen to generate a workspace for a remote podspec?

No, I would like to generate a workspace given a local podspec which has a dependency on a remote podspec which is not part of a repository.

The use case is, that the kotlin cocoapods integration use pod gen to integrate pods into kotlin. And we want to use react-native which has these podspecs which are not part of a repository. At build time react-native is available on the local machine. However with pod gen it is not possible/no documented how to include a the podspec in the correct way (with the :podspec option in the generated podfile).

@justinseanmartin
Copy link
Collaborator

Do you have any reference material on how the kotlin cocopaods integration is handled?

I've never looked at how react native interfaces with CocoaPods before today, but it looks complicated. I see they're defining these dependencies with podspec instead of path here. I assume this is being done to ensure that the prepare_command is being run.

All that said, it is still unclear to me exactly what functionality you would need to accomplish your goals. The --local-sources option is available for the case where your podspec defines dependencies and you're not using the pod gen podfile config options to manage how to fulfill that dependency.

I'd be happy to take a look at a PR if this was something that you were interested in working on.

@Legion2
Copy link
Author

Legion2 commented Sep 30, 2021

Do you have any reference material on how the kotlin cocopaods integration is handled?

Here is how pod gen is called in the kotlin build task: https://github.com/JetBrains/kotlin/blob/master/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/AdvancedCocoapodsTasks.kt#L389-L397

Before that the podspec is generated here: https://github.com/JetBrains/kotlin/blob/5c3ce67648c2d5ca9e2a7de4460c6256625fd479/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/CocoapodsTasks.kt#L115-L156

I see they're defining these dependencies with podspec instead of path here. I assume this is being done to ensure that the prepare_command is being run.

Exactly. And because pod gen does not support :podspec it uses :path. Nevertheless, the prepare_command is executed in the directory of the podspec file, however the directory does not contain the sources and fails (the sources must be downloaded from git).

The --local-sources option is available for the case where your podspec defines dependencies

Kotlin uses the --local-sources option, but this results in path instead of podspec in the generated podfile, which causes the error described above.

Using the [pod gen podfile config options(]https://github.com/square/cocoapods-generate/blob/master/lib/cocoapods/generate/configuration.rb#L139-L141) is not an option for the kotlin integration, because it kotlin relies on pod gen to generate the podfile.

I thinks what's needed is an option in pod gen to specify a podspec (url or local path) which should be put into the generated podfile with the podspec option instead of path, to reproduce the expected behavior.
e.g.
pod 'myPod', :podspec => './external/myPod.podspec' instead of pod 'myPod', :path => './external/'

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

2 participants