Skip to content

Support for Swift Package Manager #19

@andreasley

Description

@andreasley

It would be great if the repository contained a Package.swift manifest to allow using objectbox-swift as a dependency with Swift Package Manager.

With Xcode 11, Swift Packages can be added and managed very easily directly in the GUI and without any external requirements (e.g. CocoaPods).

Activity

uli-objectbox

uli-objectbox commented on Sep 26, 2019

@uli-objectbox
Contributor

We're keeping an eye on SPM, but there are a few features missing in it currently to work for ObjectBox.

uli-objectbox

uli-objectbox commented on Sep 26, 2019

@uli-objectbox
Contributor

To be clearer: SwiftPM currently does not support including an already-built library, nor a helper executable like our code generator.

greenrobot

greenrobot commented on Sep 26, 2019

@greenrobot
Member

There is a proposal here:
https://forums.swift.org/t/pitch-support-for-binary-dependencies/27620/90

If you find a better way of "tracking" Apple's progress for this, please post here.

Can we work around those limitations some how? E.g. have the Swift code packaged with SPM, and have a hook somewhere to provide the non-Swift parts?

andreasley

andreasley commented on Nov 15, 2019

@andreasley
Author
fishcharlie

fishcharlie commented on Apr 16, 2020

@fishcharlie

This will be implemented into Swift 5.3. Hopefully objectbox will be able to implement it shortly after.

PS @greenrobot Check out https://apps.apple.com/us/app/evolution-app/id1210898168.

greenrobot

greenrobot commented on Jun 30, 2020

@greenrobot
Member

This small WWDC 2020 video "Distribute binary frameworks as Swift packages" might be helpful:
https://developer.apple.com/videos/play/wwdc2020/10147

greenrobot

greenrobot commented on Jun 30, 2020

@greenrobot
Member

I guess setting up an XCFramework and enabling .swiftinterface would be a prerequisite. Would be also useful to Carthage; see Carthage/Carthage#2887 (comment).

ratranqu

ratranqu commented on Jul 1, 2020

@ratranqu

Hi all,

@paulofaria and I have been looking at this, and we are able to build and use the ObjectBox framework using spm on MacOS Catalina using the 5.2 toolchain. To do so, we've reorganised the repo to better match the standard spm project structure, and would like to discuss how we can merge the main repo and our fork going forward. Below, you can find the result of our work:
https://github.com/katalysis-io/objectbox-swift (spm version ported to 1.3.1)
https://github.com/katalysis-io/objectbox-spm-test (simple cli binary linking to objectbox using spm to manage dependencies)

We still have issues compiling on Linux due to the presence of Foundation in the ObjectiveC/C++ wrappers around the ObjectBox C lib to catch exceptions.

greenrobot

greenrobot commented on Jul 1, 2020

@greenrobot
Member

@ratranqu Cool. Thanks for pushing this!

Seems like we have 3 topics here:

  1. Reorganizing the repo is not trivial for us, as there are some interdependent things at our end internally. But let's see what we can do over time...

  2. I'd like to understand better the swift build approach vs. XCFrameworks. Iirc, XCFrameworks only works on Apple platforms, but not on Linux? XCFrameworks still seems to be the way to go for Apple ecosystem.

  3. Not sure if those ObjectiveC/C++ wrappers are still required... Could you open a new issue with some details?

greenrobot

greenrobot commented on Jul 1, 2020

@greenrobot
Member

We've been experimenting with XCFramework a little bit.

You can download it here if you want to play around with it:
https://github.com/objectbox/objectbox-swift/releases/download/v1.3.1/ObjectBox.xcframework.zip

Related commit with the script building the xcframework: 25222a5

While the framework is one of the pieces, we also have to get the ObjectBox Swift code generator working. Not sure if Swift Package Manager can help with that...

greenrobot

greenrobot commented on Jul 10, 2020

@greenrobot
Member

@ratranqu (off-topic) old error handling code was removed in ced59de - for any ObjC/NS leftovers, please raise an issues.

rogerluan

rogerluan commented on Nov 15, 2020

@rogerluan

Any updates regarding adding support to SPM? As of Swift 5.3, SPM supports embeded binaries if needed 🙏

27 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @greenrobot@aeigenmann@fishcharlie@andreasley@funcJeff

        Issue actions

          Support for Swift Package Manager · Issue #19 · objectbox/objectbox-swift