Skip to content

docs: update plugin development guide #1421

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

Merged
merged 7 commits into from
Jul 7, 2025

Conversation

erisu
Copy link
Member

@erisu erisu commented Jun 22, 2025

Motivation, Context & Description

Update and improve the plugin development guide including the iOS portion of the guide.

Closes #974

Testing

n/a

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@implementation Echo
### Supporting Swift Package Manager (SPM)

Starting from Cordova-iOS 8 and greater, support for the Swift Package Manager (SPM) has been implemented. To start using SPM with your plugin, a `Package.swift` file will need to be created in the plugin's root directory and a couple of things needs to be set and made aware in the `plugin.xml`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should mention in here the package="swift" attribute in plugin.xml

interface. If your plugin requires a great deal of processing or
requires a blocking call, you should use a background thread. For
example:
Plugin methods ordinarily execute in the same thread as the main interface. If your plugin requires a great deal of processing or requires a blocking call, you should use a background thread.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth mentioning that certain operations involving UI stuff (showing alerts, changing colours, etc.) can only run on the main thread

For additional reference, see the following classes:

- [CDVPlugin.h][CDVPlugin.h]
- [CDVPlugin.m][CDVPlugin.m]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


## CDVPluginResult Message Types

You can use `CDVPluginResult` to return a variety of result types back to the JavaScript callbacks, using class methods that follow this pattern:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to link to https://apache.github.io/cordova-ios/documentation/cordova/cdvpluginresult around here

(and then also improve the comments in the ObjC code so that documentation is more useful)

@erisu erisu requested a review from dpogue July 7, 2025 05:18
@erisu erisu merged commit 0000b1a into apache:master Jul 7, 2025
1 check passed
@erisu erisu deleted the docs/platform-plugin-development-guide branch July 7, 2025 13:11
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

Successfully merging this pull request may close these issues.

Issues with "iOS Plugin Development Guide"
2 participants