lytics / ios-sdk

MIT License
0 stars 0 forks source link

CocoaPods Support #132

Closed mgacy closed 11 months ago

mgacy commented 12 months ago

Adds support for distribution through CocoaPods.

I used separate podspecs rather than subspecs as the latter generates a single target for the different subspecs rather than separate Lytics and LyticsUI targets.

Attention should be paid to my choice of values for the different settings like s.homepage and s.social_media_url.

The next PR will include changes to the tag-release workflow to automate publishing the podspecs. I am submitting that separately to ensure that any potential CI issues do not disrupt other work that depends on the published podspecs.


Post-Merge Configuration

Once this PR is merged and tagged -- this tag will need to be created manually rather than with the Release workflow if we use 0.0.1 -- the podspecs will need to be published to the CocoaPods ‘Trunk’ web-service. As this involves a claim of ownership it should be performed by someone from Lytics. The process to do this is as follows:

Install CocoaPods:

The documentation suggests installing CocoaPods using gem; if using the default Ruby install on macOS you will need to use sudo when installing:

$ sudo gem install cocoapods

Alternatively, it is available through homebrew (brew install cocoapods).

Create Account

Documentation: Getting setup with Trunk

Register for an account:

$ pod trunk register <email> '<name>' [--description='<session description>']

Trunk accounts do not have passwords, only per-computer session tokens; you must click a link in an email Trunk sends you to verify the connection between your Trunk account and the current computer. Note that when I tried this on 2023/10/02 I saw erroneous error messages on the verification page. After clicking the link in the email verify your session by running pod trunk me.

Publish Specs

The podspecs use the LIB_VERSION environment variable for the version number, so set that first (using whatever version number we use; a normal rather than pre-release version number would be preferable):

$ export LIB_VERSION=0.0.1

Publish the core spec by running the following from the repo's root directory:

$ pod trunk push LyticsSDK.podspec --use-json

Then, publish the UI spec:

$ pod trunk push LyticsUI.podspec --use-json

Obtain Cocoapods Token

Get the token for an account session for use with GitHub actions; you can separate the CI session from the one created above by first running pod trunk register to create a new one.

$ grep -A2 'trunk.cocoapods.org' ~/.netrc

The results should look like:

machine trunk.cocoapods.org
 login <your@email.com>
 password <TOKEN>

Then, add the token as the value for the COCOAPODS_TRUNK_TOKEN secret in the repo's settings (the secret has already been created with a placeholder value).