-
Notifications
You must be signed in to change notification settings - Fork 984
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
WIP - feat: Add support for SPM plugins #1430
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7ae36ee
WIP: Add CordovaPluginsSPM to template
jcesarmobile 4e432e8
Update Package.swift on plugin add/remove
jcesarmobile f643968
fix lint
jcesarmobile ca8c1e2
Revert "WIP: Add CordovaPluginsSPM to template"
jcesarmobile 7bb152b
Re add CordovaPluginsSPM
jcesarmobile 0459949
add license
jcesarmobile aafbbdb
restore deleted licenses
jcesarmobile 6f29fa4
format license
jcesarmobile 488bb45
undo project changes
jcesarmobile 56c5903
format
jcesarmobile 29fbbff
plugin dir check
jcesarmobile File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// swift-tools-version:5.5 | ||
|
||
/* | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
*/ | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "CordovaPluginsSPM", | ||
platforms: [.iOS(.v11)], | ||
products: [ | ||
.library( | ||
name: "CordovaPluginsSPM", | ||
targets: ["CordovaPluginsSPM"]) | ||
], | ||
targets: [ | ||
.target( | ||
name: "CordovaPluginsSPM" | ||
) | ||
] | ||
) |
18 changes: 18 additions & 0 deletions
18
templates/project/CordovaPluginsSPM/Sources/CordovaPluginsSPM/CordovaPluginsSPM.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
*/ | ||
|
||
public let isCordovaApp = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this PR again, and the one thing I don't really love is the "magic" behaviour based on the existence of a Package.swift file in the plugin folder. It feels safer to rely on an explicit declaration in the plugin.xml file.
We've already overloaded the
<framework>
tag to do a billion things, so adding this wouldn't be totally unreasonable. i.e.,Alternatively, the
lib-file
tag exists on Android but you could maybe stretch the definition to encompass Swift packages.Using
source-file
is an option, but feels like that goes back to "magic" behaviour based on file names.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of having a Package.swift file is to turn the plugin into a swift package itself.
Having the Package.swift file makes it possible to add other swift packages the plugin wants to use as dependencies the “swift package way”.
Adding the Package.swift file in a framework tag makes no sense, in any case we could totally ditch the Package.swift file from plugins and use the framework tag to declare SPM dependencies, and then read the tag and write the dependencies in the CordovaPluginsSPM/Package.swift file but the tag will fall short for all the possible options and will end up creating a new tag in a future release as we did for CocoaPods.
The CLI should also copy the plugin files to the CordovaPluginsSPM project instead of to the app as if the plugin relies in the dependency and the dependency is in CordovaPluginsSPM project the plugin files should be there.