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

Added Swift Package Manager Support #625

Closed

Conversation

balavor
Copy link

@balavor balavor commented Jan 8, 2021

Added Swift Package Manager Support

Description

  • Added Package.swift with YPImagePicker library
  • Updated dependencies and fixed warnings
  • Added static var local: Bundle to correctly use bundle for resources of package
  • Removed module inheritance from .xib files.
  • Updated README.md file

@balavor balavor force-pushed the feature/swift-package-manager branch from 25bf236 to 3aadf13 Compare January 9, 2021 10:37
@balavor balavor marked this pull request as ready for review January 9, 2021 14:02
@victormihaita
Copy link

Is this something ready to be merged. It would be really useful 👍

@balavor
Copy link
Author

balavor commented Jan 12, 2021

Well, works fine for me, including assets and xibs. They were the biggest pain )

@balavor
Copy link
Author

balavor commented Jan 14, 2021

@NikKovIos FYI :)

@NikKovIos NikKovIos requested a review from s4cha January 14, 2021 12:14
@NikKovIos
Copy link
Collaborator

@s4cha as soon as you did something with SPM, check this please.

@s4cha
Copy link
Member

s4cha commented Jan 22, 2021

Hey guys, haven't taken a deep look but spm support was already done and working a while back on the spm branch, which is documented on the readme. @RomanTysiachnik Could you elaborate the difference here?

@balavor
Copy link
Author

balavor commented Jan 25, 2021

@s4cha the spm branch seems to be a bit outdated. Moreover, as far as I understood, it is configured to work only in spm, so if you merge it to master, it will break Cocoapods integration. This one shouldn't break anything.

@fdocr
Copy link

fdocr commented Apr 1, 2021

Hi everyone, I just wanted to drop a message here to mention it would be great to have full SPM support in the releases.

The reason for this is we are trying to ship a library that has YPImagePicker as a dependency, and if we have that library fetch YPImagePicker from a branch instead of versioned releases it forces all projects downstream of our library to fetch our library on a branch. This is because of the way SPM works, it doesn't allow to fetch versioned dependencies if those dependencies themselves declare dependencies using a branch and not versioned releases.


Related to this PR: When using the spm branch directly we haven't run into any issues. I tested out this in my fork by merging this PR, tagging a 4.5.0 release there and then I ran into the following problem

Screen Shot 2021-04-01 at 13 56 16

The crash happens the moment the picker is presented with .present(picker, animated: true, completion: nil). The picker is configured the following way:

func imagePicker(_ ratio: String?) -> YPImagePicker {
    var config = YPImagePickerConfiguration()
    config.shouldSaveNewPicturesToAlbum = false
    config.startOnScreen = YPPickerScreen.library
    config.library.onlySquare = false
    config.library.isSquareByDefault = false
    if let ratio = ratio, let rectangleRatio = Double(ratio) {
        config.showsCrop = .rectangle(ratio: rectangleRatio)
    }
    config.library.mediaType = YPlibraryMediaType.photo
    return YPImagePicker(configuration: config)
}

....

let picker = imagePicker(message["ratio"])
picker.didFinishPicking { [unowned picker] items, _ in
    if let photo = items.singlePhoto {
        // Image selected now start uploading process
        ...
    }
    picker.dismiss(animated: true, completion: nil)
}

// This is where the app crashes
viewController.present(picker, animated: true, completion: nil)

I hope this helps in any way possible. If you need any help testing things out let me know and I'll be happy to help if possible.

@NikKovIos
Copy link
Collaborator

I think that is better to support the cocoapods and spm simultaneously. But in that case we need to test this branch very well. As soon as I didn't work with spm yet, it should be @s4cha, but it seems, that he has not time for that right now.

@balavor
Copy link
Author

balavor commented Apr 15, 2021

@fdoxyz dunno if you still have that issue, but that branch resolves, since the issue is connected with how xibs are stored in bundle and where they're trying to find a corresponding class (file-owner).

@fdocr
Copy link

fdocr commented Apr 18, 2021

There's a chance I'm doing something wrong, but I'm able to reproduce the problem in this example project I created: https://github.com/fdoxyz/YPImagePickerSPM

I merged this PR into my fork and released with a 4.6.0 tag.

The project above fails if I use that tag (4.6.0)

Screen Shot 2021-04-18 at 14 55 02

It also fails the same way if I use your branch

Screen Shot 2021-04-18 at 15 15 27

But works just fine if I use the branch spm

Screen Shot 2021-04-18 at 15 07 26

The error is always the same:

Screen Shot 2021-04-18 at 15 07 26

Please let me know if I'm making a mistake somewhere @RomanTysiachnik, or I hope this helps debug the problem I'm facing.

@NikKovIos
Copy link
Collaborator

Implemented here https://github.com/Yummypets/YPImagePicker/releases/tag/5.0.0

@NikKovIos NikKovIos closed this Sep 19, 2021
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.

5 participants