swift-log icon indicating copy to clipboard operation
swift-log copied to clipboard

Add podspec

Open igor-makarov opened this issue 5 years ago • 32 comments

Hi, this PR adds a .podspec file to the package.

The podspec has been tested with a working app and is functioning.

I've also run pod lib lint which integrates the pod into a blank app target and executes its tests. This also passes.

This closes #19.

igor-makarov avatar Mar 20 '19 09:03 igor-makarov

Can one of the admins verify this patch?

swift-server-bot avatar Mar 20 '19 09:03 swift-server-bot

@weissi You generally need to check the podspec in because a Podfile can reference a git repo, in which case it will look in the root for a podspec.

The podspec file is expected to be in the root of the repository

http://guides.cocoapods.org/syntax/podfile.html#pod

chrisballinger avatar Apr 14 '19 02:04 chrisballinger

@chrisballinger what’s wrong with the way NIO does it? The pods look just fine to me: https://cocoapods.org/pods/SwiftNIO

The reason I don’t want to check it in is that there’s then two places for the version information: the git tags and the podspec and that’s not good.

weissi avatar Apr 15 '19 07:04 weissi

In addition to publishing the podspec in the spec repo, it is used for one more purpose: direct git pod integration. Right now, I'm referring to swift-log in my Podfile like so:

pod 'Logging', git: 'https://github.com/igor-makarov/swift-log.git', branch: 'add-podspec'

This way, the podspec is retrieved directly from the repo and the version tags are ignored, allowing for usage of latest dev version.

igor-makarov avatar Apr 15 '19 07:04 igor-makarov

Hi! It's been a long time but I've been recently doing similar integration with swift-llbuild and I've gotten a new angle on the whole podspec versioning thing.
The full explanation is over at https://github.com/apple/swift-llbuild/pull/545.

I think it covers all cases and is compatible with SwiftPM versioning, in a way. Let me know what you think!

igor-makarov avatar Aug 25 '19 07:08 igor-makarov

Wow, this looks great. I’m +1 on this.

weissi avatar Aug 25 '19 09:08 weissi

Thank you!

weissi avatar Aug 25 '19 09:08 weissi

I've removed the old podspec builder as suggested.

igor-makarov avatar Aug 25 '19 10:08 igor-makarov

Any updates on getting this merged?

danramteke avatar Sep 25 '19 01:09 danramteke

@weissi i know we added https://github.com/apple/swift-log/blob/master/scripts/build_podspec.sh instead, have we pushed the podspec?

tomerd avatar Sep 25 '19 01:09 tomerd

@danramteke / @tomerd yes, the podspec is live as cocoapods.org/pods/Logging

weissi avatar Sep 25 '19 08:09 weissi

@weissi thanks for the direct link. I was not able to find it by searching "logging"

danramteke avatar Oct 06 '19 07:10 danramteke

@danramteke yeah, the search indexer on the CP website broke a while ago, and because it's a volunteer project, nobody got around to fixing it yet.

igor-makarov avatar Oct 06 '19 08:10 igor-makarov

thanks @igor-makarov , I was wondering why it doesn't show up.

weissi avatar Oct 08 '19 10:10 weissi

can we close this since we are already publishing a pod?

tomerd avatar Dec 20 '19 02:12 tomerd

This is an improvement to the podspec, it removes the need for a separate script.

igor-makarov avatar Dec 20 '19 07:12 igor-makarov

@weissi do you prefer the script or the spec file? i dont have a strong opinion

tomerd avatar Dec 20 '19 09:12 tomerd

@tomerd definitely script because then there's one source of truth, right? The podspec needs to re-iterate the modules as well as the version number. So generating this from Package.swift sounds better to me

weissi avatar Dec 20 '19 12:12 weissi

@tomerd actually, the podspec seems to be automatically detecting the version which we might be fine with. Still seems a little dangerous that you don't have to specify which version exactly to upload though. But better than nothing.

weissi avatar Dec 20 '19 12:12 weissi

I thought that it would be nice to avoid having a generator script. What are the modules you're talking about?

igor-makarov avatar Dec 20 '19 13:12 igor-makarov

@igor-makarov well, the thing is that there might be new modules in the future. In that case we'd need to remember to change both the podspec and the Package.swift. A generator script wouldn't have this issue because it uses the real source of truth which is the Package.swift. For a more complicated example check the generator in swift-nio

weissi avatar Dec 20 '19 13:12 weissi

The current generator doesn't read from Package.swift though, right?

My original problem was that if there's no podspec in the git repo, there's no way to integrate the latest master version into a project.

igor-makarov avatar Dec 20 '19 13:12 igor-makarov

Did a rebase to clean up the commit history.

igor-makarov avatar Dec 21 '19 13:12 igor-makarov

@weissi This should be merged because even though the problem is semi-resolved by having a podspec version published to trunk, not having this merged prevents someone from pointing to the master branch (or another branch) on this repo. For example, this is a somewhat common workflow:

pod 'Logging', git: 'https://github.com/apple/swift-log.git', branch: 'master'

chrisballinger avatar Feb 04 '20 21:02 chrisballinger

Any updates on this?

FredrikAugust avatar Apr 06 '20 08:04 FredrikAugust

There is another option: We could check in a .podspec IF we have a script (that is run by CI) which regenerates the podspec in CI. Basically exactly like we do the LinuxMain.swift generation. If the CI detects that you haven't run the update script it fails. WDYT? @ktoso / @glbrntt / @tomerd

weissi avatar Jun 17 '20 10:06 weissi

@weissi that sounds reasonable, would it infer the version as per this PR or would the script just have to be run after tagging a new version?

glbrntt avatar Jun 18 '20 13:06 glbrntt

@weissi that sounds reasonable, would it infer the version as per this PR or would the script just have to be run after tagging a new version?

Oh man, I forgot about the version :. Could it use git in the podspec to find the version?

weissi avatar Jun 18 '20 14:06 weissi

Yes: inferring from git is one of the changes proposed by this PR.

glbrntt avatar Jun 18 '20 14:06 glbrntt

Yes: inferring from git is one of the changes proposed by this PR.

Cool! If we now get a generator script that generates exactly what this PR proposes and add that to the CI to double check it's not wrong, then I'm cool with this.

weissi avatar Jun 18 '20 14:06 weissi