Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Setup for CocoaPods and SPM distribution #5

Merged
merged 12 commits into from
Jul 18, 2023
Merged

Setup for CocoaPods and SPM distribution #5

merged 12 commits into from
Jul 18, 2023

Conversation

jkmassel
Copy link
Contributor

@jkmassel jkmassel commented May 23, 2023

Adds instructions on how to use the library, as well as the Podspec and Package.swift that make it work.

Doesn't yet publish the package to CocoaPods.

SwiftPM only allows packages to be distributed as ZIP files, so this PR adjusts that.

@jkmassel jkmassel requested a review from mokagio May 23, 2023 22:54
@mokagio mokagio changed the title Add README Setup for CocoaPods and SPM distribution May 24, 2023
Comment on lines +14 to +20
#### Development Builds
```ruby
# Reference a commit hash
pod 'WooCommerceShared', git: 'https://github.com/woocommerce/WooCommerce-Shared.git', commit: '6cba1e9'

# Reference a branch
pod 'WooCommerceShared', git: 'https://github.com/woocommerce/WooCommerce-Shared.git', branch: 'trunk'
Copy link
Contributor

Choose a reason for hiding this comment

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

Because this CocoaPod uses pre-built binaries, referencing a commit or a branch might not result in the binary that's downloaded reflecting the state of the source code.

Comment on lines +57 to +59
echo "--- :amazon-s3: Uploading"
GIT_HASH=$(git rev-parse --short HEAD)
aws s3 cp dist/WooCommerceShared.xcframework.zip s3://a8c-apps-public-artifacts/woocommerce-shared/${GIT_HASH}/WooCommerceShared.xcframework.zip
Copy link
Contributor

Choose a reason for hiding this comment

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

I started building an upload_to_s3 command in the CI toolkit, but I half regret it now... There's really little difference than calling aws directly

Copy link
Contributor

@mokagio mokagio left a comment

Choose a reason for hiding this comment

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

@jkmassel I run into various issue recently while working on the Gutenberg XCFramework with CocoaPods, and it looks like this setup is experiencing similar problems as the podspec doesn't pass validation:

image

Unfortunately, I haven't been able to get my Gutenberg setup to work yet. I am working around it by downloading and unpacking the archive and using a local podspec that refers to the files on my system. See wordpress-mobile/WordPress-iOS#20717

Add RuboCop configuration file and address violations
@jkmassel jkmassel force-pushed the add/readme branch 11 times, most recently from 0bff291 to cd13050 Compare May 25, 2023 18:58
@jkmassel
Copy link
Contributor Author

Ok, so weirdly enough 42fbf15 works, but it's...kinda gross.

For some reason the sources key seems to be ignored, but if I download the ZIP file manually and process it everything is fine?

I'm not sure what I'm missing – I know the sha1 is wrong, but I'd expect that to fail the build, not for pod install to just silently continue?

I think this approach proves the concept, but I might have to dig into CocoaPods internals to figure out the source issue

@mokagio
Copy link
Contributor

mokagio commented May 26, 2023

I'm not sure what I'm missing [...]

I think this approach proves the concept, but I might have to dig into CocoaPods internals to figure out the source issue

That's the same conclusion I got to 😞

I started looking into cocoapods-downloader which is what CP use to download sources etc, but haven't found the point where it tries to download and unpack an http: source.

@Ecarrion
Copy link
Contributor

Hi @jkmassel!

How are things going? Is merging this PR still part of your plan?

I ask because we are soon going to include the framework inside the main WC app and it would be good to do it through a POD or SPM package.

cc @wzieba

@jkmassel
Copy link
Contributor Author

@Ecarrion – sorry about the wait – this is ready.

CocoaPods is still a bit of a mess (we can make it build fine if we reference the Git repo, but we can't push to a public Pod until we figure out why it doesn't properly support xcframework distribution).

Fortunately, WCiOS seems to already heavily use SwiftPM, and that works fine. The release process is a little weird, but I've added it to README.md, so you can feel free to perform releases as needed, or I'm happy to help out with that.

Please try adding this repo to the project using SwiftPM, and choose the 0.1.0 release. It should work just fine, and if so, we can land this PR.

/cc @shiki

Copy link
Contributor

@Ecarrion Ecarrion left a comment

Choose a reason for hiding this comment

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

@jkmassel the SPM version seems to work fine on the WCiOS app. Thanks!

Can I( or you?) release the latest trunk as a new version to do a more comprehensive test? 😁

@jkmassel jkmassel merged commit a84b8d0 into trunk Jul 18, 2023
@jkmassel jkmassel deleted the add/readme branch July 18, 2023 17:39
@mokagio
Copy link
Contributor

mokagio commented Jul 19, 2023

@jkmassel

CocoaPods is still a bit of a mess (we can make it build fine if we reference the Git repo, but we can't push to a public Pod until we figure out why it doesn't properly support xcframework distribution).

#51 should move us in the right direction

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants