Skip to content

Commit d6d4564

Browse files
feat: Adding Cocoapods support
Signed-off-by: Jonathan Norris <[email protected]>
1 parent e2be585 commit d6d4564

File tree

6 files changed

+124
-2
lines changed

6 files changed

+124
-2
lines changed

.github/workflows/cocoapods.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CocoaPods
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
pod-lint:
11+
runs-on: macos-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Install CocoaPods
16+
run: gem install cocoapods
17+
18+
- name: Lint Podspec
19+
run: pod lib lint --allow-warnings
20+
21+
pod-publish:
22+
needs: pod-lint
23+
if: github.event_name == 'release'
24+
runs-on: macos-latest
25+
steps:
26+
- uses: actions/checkout@v3
27+
28+
- name: Install CocoaPods
29+
run: gem install cocoapods
30+
31+
- name: Update CocoaPods Trunk
32+
env:
33+
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
34+
run: |
35+
# Ensure the version in podspec matches the release
36+
./scripts/update_podspec.sh
37+
# Push the podspec to trunk
38+
pod trunk push --allow-warnings

.github/workflows/release-please.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,32 @@ jobs:
2424
run: |
2525
echo "$RELEASE_PLEASE_OUTPUT"
2626
27+
# Update podspec version when a release PR is created or updated
28+
- name: Checkout code if PR is generated/updated
29+
if: ${{ steps.release.outputs.pr }}
30+
uses: actions/checkout@v3
31+
with:
32+
ref: ${{ fromJSON(steps.release.outputs.pr).headBranchName }}
33+
34+
- name: Update podspec version
35+
if: ${{ steps.release.outputs.pr }}
36+
run: |
37+
./scripts/update_podspec.sh
38+
git config --global user.name "github-actions[bot]"
39+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
40+
git add OpenFeature.podspec
41+
git commit -m "chore: update podspec version [skip ci]" || true
42+
git push
43+
2744
# Outputs are namespaced by package when using a manifest in Release Please
2845
outputs:
2946
release_created: ${{ steps.release.outputs['OpenFeature--release_created'] }}
3047
# Version doesn't include `v` as a prefix. This is undocumented
3148
version: ${{ steps.release.outputs['OpenFeature--version'] }}
3249
upload_url: ${{ steps.release.outputs['OpenFeature--upload_url'] }}
50+
51+
# Trigger the CocoaPods workflow when a release is created
52+
cocoapods:
53+
needs: release-please
54+
if: ${{ needs.release-please.outputs.release_created == 'true' }}
55+
uses: ./.github/workflows/cocoapods.yaml

CONTRIBUTING.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,19 @@ You can automatically format your code using:
2323

2424
```shell
2525
swift test
26-
```
26+
```
27+
28+
### Maintaining CocoaPods Integration
29+
30+
The project includes CocoaPods support via the `OpenFeature.podspec` file. When making changes:
31+
32+
1. The version in the podspec is automatically updated from `version.txt` during the release process
33+
2. You can manually update the podspec version by running:
34+
```shell
35+
./scripts/update_podspec.sh
36+
```
37+
3. To validate the podspec locally, run:
38+
```shell
39+
pod spec lint OpenFeature.podspec --allow-warnings
40+
```
41+
4. The CocoaPods validation and publishing is handled automatically via GitHub workflows on release

OpenFeature.podspec

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'OpenFeature'
3+
s.version = '0.3.0'
4+
s.summary = 'OpenFeature iOS SDK'
5+
s.description = <<-DESC
6+
OpenFeature is an open specification that provides a vendor-agnostic, community-driven API for feature flagging that works with your favorite feature flag management tool or in-house solution.
7+
DESC
8+
s.homepage = 'https://github.com/open-feature/swift-sdk'
9+
s.license = { :type => 'Apache-2.0', :file => 'LICENSE' }
10+
s.author = { 'OpenFeature' => 'https://github.com/open-feature' }
11+
s.source = { :git => 'https://github.com/open-feature/swift-sdk.git', :tag => s.version.to_s }
12+
13+
s.ios.deployment_target = '14.0'
14+
s.osx.deployment_target = '11.0'
15+
s.swift_version = '5.5'
16+
17+
s.source_files = 'Sources/OpenFeature/**/*'
18+
19+
s.frameworks = 'Foundation'
20+
end

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ and in the target dependencies section add:
7171
.product(name: "OpenFeature", package: "swift-sdk"),
7272
```
7373

74+
#### CocoaPods
75+
76+
If you manage dependencies through CocoaPods, add the following to your Podfile:
77+
78+
```ruby
79+
pod 'OpenFeature', '~> 0.3.0'
80+
```
81+
82+
Then, run:
83+
84+
```bash
85+
pod install
86+
```
87+
7488
### Usage
7589

7690
```swift
@@ -194,7 +208,7 @@ A shutdown function is not yet available in the iOS SDK.
194208
### Develop a provider
195209

196210
To develop a provider, you need to create a new project and include the OpenFeature SDK as a dependency.
197-
Youll then need to write the provider by implementing the `FeatureProvider` interface exported by the OpenFeature SDK.
211+
You'll then need to write the provider by implementing the `FeatureProvider` interface exported by the OpenFeature SDK.
198212

199213
```swift
200214
import OpenFeature

scripts/update_podspec.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# Exit if any command fails
4+
set -e
5+
6+
# Get the version from version.txt
7+
VERSION=$(cat version.txt | tr -d '\n')
8+
9+
# Update the version in the podspec
10+
sed -i '' "s/s.version.*=.*/s.version = '$VERSION'/g" OpenFeature.podspec
11+
12+
echo "Updated OpenFeature.podspec to version $VERSION"

0 commit comments

Comments
 (0)