robbiehanson / XMPPFramework

An XMPP Framework in Objective-C for Mac and iOS
Other
5.91k stars 2.09k forks source link

Add Swift Package Manager support #1177

Closed karimhm closed 3 years ago

karimhm commented 4 years ago

Fixes #1176

karimhm commented 4 years ago

~⚠️ 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.

chrisballinger commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

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

karimhm commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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

karimhm commented 4 years ago

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

karimhm commented 4 years ago

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

karimhm commented 3 years ago

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

karimhm commented 3 years ago

@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