godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

iOS: Use CocoaPods to export project #4758

Open gumaciel opened 2 years ago

gumaciel commented 2 years ago

Describe the project you are working on

I'm working on an AdMob Plugin for iOS (and also Android): https://github.com/Poing-Studios/godot-admob-ios

Describe the problem or limitation you are having in your project

To export the Plugin for iOS, I need to download an SDK that the Google team makes available: https://developers.google.com/admob/ios/download, the problem is that it is not possible to download the version I want (e.g. 8.13.0), I always need download the latest version available.

What happens now is that it is no longer possible to download the latest version, and this makes it impossible for me to generate a version of the plugin to make available to users.

There's another thing that bothers me doing this is that I'm not sure which version I'm downloading, whereas on Android I have it.

Q: "But could you generate a build and make the Cocoapod content that was generated in the build available to your users?"

A: But it can cause another problem: What if some path of the Cocoapod content is changed? I'll need to look for the path again and that can bring bugs and problems, and I would also consider this a jerry-rigged because it's not ideal for me.

Besides that some contents that are downloaded by Cocoapods are not exactly a .framework or .xcframework, they work from something else that I don't know how I could export them and put them to work for Godot, in short, that would be very complicated and could be easily avoided by using Cocoapods when exporting.


I think at the moment I will ask users to convert the project on their own and download the SDK through Cocoapods, but I think it would be ideal if Godot itself made this option available to make it easier for end users

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Export the project as Cocoapods (.xcworkspace)

For example, Unity offers this kind of solution based on their documentation:

https://developers.google.com/admob/unity/quick-start Captura de Tela 2022-06-26 às 19 59 26

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Here could have some option like: "Install CocoaPods" ~(I also miss a button to add a folder "ios/plugins", like Android does)~

Captura de Tela 2022-06-26 às 19 45 07

And here too: "Export the project as Cocoapods" Captura de Tela 2022-06-26 às 19 46 54

And the .gdip could have some "pods" section like: ( ; tells the version) Captura de Tela 2022-06-26 às 19 53 05

If this enhancement will not be used often, can it be worked around with a few lines of script?

I think so, but this feature can be used to other plugins, like FacebookSDK or Firebase

Is there a reason why this should be core and not an add-on in the asset library?

It will make plugin development and maintenance easier for everyone

gumaciel commented 2 years ago

Here's an attempt I had back in the day when I was working on the Plugin: I was able to use Cocoapods to develop, but not able to export to the user https://github.com/Poing-Studios/godot-admob-ios/issues/11#issuecomment-964705348

I decided to open this proposal now because it is starting to get harder to maintain the project without this part of exporting the Cocoapods dependencies to the user

MileyHollenberg commented 1 week ago

I've started working on this issue, so far I've been able to get the One Click Deploy to both generate a Podfile, add some Pods (hardcoded for the P.O.C.), run the install command and have it compile and deploy succesfully onto my iPhone! Will continue to work on this throughout the week and into next week before creating a PR for Godot 4.4.

gumaciel commented 1 week ago

You're amazing @MileyHollenberg ! Thank you so much!

If there's something that I can do to help please let me know

MileyHollenberg commented 1 week ago

@gumaciel Do you have any experience getting Godot's source code to play nicely with XCode? For me the syntax highlighting 'sometimes' works and the jump to definition only works for classes but not for methods within the current file. I've followed the guide here and it's 'working' but not quite (I'd rather use Rider but that's simply not supported on macOS given its requirement for certain libraries). XCode is also often complaining about the code having errors in it when it clearly doesn't

zynga-jpetersen commented 1 week ago

Its great that you are getting cocospod working in the Godot Editor export pipeline. The way we're able to get this working in our current test projects is as a post export step from outside of godot and then kicking off the build from xcode on the commandline. Getting it working in the editor should be cleaner.

Separately, if you do get those xcode instructions worked out so you can debug, I think those instructions could be replaced with script which uses the same tool used by cocospods, Xcodeproj, to generate the project.

That would allow us to just use xcode as an ide for the editor without high maintenance cost of a project (or manual steps).