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

Add Swift Package Manager support #1177

Merged
merged 10 commits into from
Dec 31, 2020
Merged

Conversation

karimhm
Copy link
Contributor

@karimhm karimhm commented Jul 28, 2020

Fixes #1176

@karimhm
Copy link
Contributor Author

karimhm commented Jul 28, 2020

⚠️ This PR is half done. XMPPFramework will crash when attempting to use Core Data storage. ⚠️

As of Swift v5.2 it is not possible to distribute resources alongside a Swift Package, therefore the Core Data models need to be copied in a way or another as they are needed for the proper function of XMPPFramework.

They can be copied in serval ways:
- Copy them one by one inside the target application.
- Group all the models inside a bundle and then that bundle needs to be copied into the target application.
- Programmatically create the models and avoid the resource distribution issue.

This remains the case until Xcode 12 becomes publicly available.
Please take a look at Package Manager Resources and SE-0271.

Package.swift Outdated Show resolved Hide resolved
Package.swift Outdated Show resolved Hide resolved
@chrisballinger
Copy link
Collaborator

@karimhm This is awesome! What do you think about attempting a parallel Package@swift-5.3.swift that includes the Core Data resources until Xcode 12 reaches GM? Travis has support for Xcode 12 beta now which could allow running those tests on CI.

@karimhm
Copy link
Contributor Author

karimhm commented Jul 29, 2020

@chrisballinger Swift tools version 5.3 are now supported via a parallel Package.swift
But I couldn't find a way to copy Core Data resources to the unit test bundle, otherwise, everything works as expected.

@karimhm
Copy link
Contributor Author

karimhm commented Jul 29, 2020

I posted a question at the swift forum regarding the issue.

@karimhm
Copy link
Contributor Author

karimhm commented Aug 1, 2020

@chrisballinger Swift tools version 5.3 are now supported via a parallel Package.swift
But I couldn't find a way to copy Core Data resources to the unit test bundle, otherwise, everything works as expected.

This seems to be a known bug (SR-12912) (SR-13560).
We need to wait until it gets resolved.

@chrisballinger
Copy link
Collaborator

It looks like SR-12912 won't be fixed in time for Swift 5.3, so perhaps we should move forward with this and just make sure to exclude any resource-related tests from SPM. We still have tests for those in the other Xcode projects that are run on CI. We should just make another ticket to track re-enabling those tests in SPM whenever it's fixed.

I did have another concern about the approach of using symlinks for the include/XMPPFramework folder. It seems like there will be a maintenance burden of maintaining those symlinks when new files are added to the project, or moved around. Perhaps it would be better to reorganize the project's folder structure to avoid needing the symlinks.

@karimhm
Copy link
Contributor Author

karimhm commented Sep 13, 2020

This PR have unit tests on the SPM side excluding files that depend on module resources. Until SR-12912 gets resolved.

@karimhm
Copy link
Contributor Author

karimhm commented Sep 17, 2020

This might be related to SR-13560, who knows.

@karimhm
Copy link
Contributor Author

karimhm commented Sep 17, 2020

SR-13560 seems to be the bug that is preventing tests from running properly.

@karimhm
Copy link
Contributor Author

karimhm commented Dec 30, 2020

@chrisballinger All the tests are running now. Nothing excluded.

Copy link
Collaborator

@chrisballinger chrisballinger left a comment

Choose a reason for hiding this comment

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

@karimhm This is awesome stuff! Will be good to merge once the package manifest dependency URLs are fixed.

On a side note, Travis-CI has been crippled for open source projects and it would make sense to migrate to GitHub Actions at some point soon.

Package.swift Outdated Show resolved Hide resolved
- rm -rf *.xcodeproj
# Test the Swift PM project using `xcodebuild`.
# The test is performed using `xcodebuild` rather than `swift test` due to this bug:
# https://bugs.swift.org/browse/SR-13560
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great job on the workaround! Hopefully Apple fixes this bug someday. Is there a Feedback Assistant report number that could be added to that ticket?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Im not aware of any

Co-authored-by: Chris Ballinger <chrisballinger@gmail.com>
@karimhm
Copy link
Contributor Author

karimhm commented Dec 30, 2020

@karimhm This is awesome stuff! Will be good to merge once the package manifest dependency URLs are fixed.

On a side note, Travis-CI has been crippled for open source projects and it would make sense to migrate to GitHub Actions at some point soon.

This can be done once this PR get merged

@chrisballinger chrisballinger merged commit 76969d1 into robbiehanson:master Dec 31, 2020
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.

Add Swift Package Manager support
2 participants