Skip to content

Commit 60e93f7

Browse files
fadi-georgeclaude
andcommitted
chore: [SDK-5818] add CocoaPods demo-pods app
Copy the demo's iOS app into examples/demo-pods so the CocoaPods integration keeps a reference app and E2E coverage once demo moves to Swift Package Manager. Its JavaScript is shared with demo by copy, and a test fails when the two drift. iOS E2E and the release workflow's Podfile pin and lockfile refresh now cover demo-pods. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent fd65783 commit 60e93f7

104 files changed

Lines changed: 10562 additions & 31 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/actions/setup-demo/action.yml‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ inputs:
77
onesignal-api-key:
88
description: 'OneSignal API Key for the demo .env'
99
required: true
10+
demo-dir:
11+
description: 'Demo app directory to set up'
12+
required: false
13+
default: 'examples/demo'
1014
install-pods:
1115
description: 'Whether to run pod update for iOS'
1216
required: false
@@ -23,13 +27,13 @@ runs:
2327
- name: Cache bun dependencies
2428
uses: actions/cache@v5
2529
with:
26-
path: examples/demo/node_modules
27-
key: bun-${{ runner.os }}-${{ hashFiles('examples/demo/bun.lock') }}
28-
restore-keys: bun-${{ runner.os }}-
30+
path: ${{ inputs.demo-dir }}/node_modules
31+
key: bun-${{ runner.os }}-${{ inputs.demo-dir }}-${{ hashFiles(format('{0}/bun.lock', inputs.demo-dir)) }}
32+
restore-keys: bun-${{ runner.os }}-${{ inputs.demo-dir }}-
2933

3034
- name: Install and set up demo
3135
shell: bash
32-
working-directory: examples/demo
36+
working-directory: ${{ inputs.demo-dir }}
3337
run: |
3438
vp run setup
3539
vp install
@@ -38,19 +42,19 @@ runs:
3842
if: inputs.install-pods == 'true'
3943
uses: actions/cache@v5
4044
with:
41-
path: examples/demo/ios/Pods
42-
key: pods-${{ runner.os }}-${{ hashFiles('examples/demo/ios/Podfile.lock') }}
45+
path: ${{ inputs.demo-dir }}/ios/Pods
46+
key: pods-${{ runner.os }}-${{ hashFiles(format('{0}/ios/Podfile.lock', inputs.demo-dir)) }}
4347
restore-keys: pods-${{ runner.os }}-
4448

4549
- name: Update CocoaPods
4650
if: inputs.install-pods == 'true'
4751
shell: bash
48-
working-directory: examples/demo/ios
52+
working-directory: ${{ inputs.demo-dir }}/ios
4953
run: pod update OneSignalXCFramework --no-repo-update
5054

5155
- name: Create demo .env
5256
shell: bash
53-
working-directory: examples/demo
57+
working-directory: ${{ inputs.demo-dir }}
5458
run: |
5559
echo "ONESIGNAL_APP_ID=${{ inputs.onesignal-app-id }}" > .env
5660
echo "ONESIGNAL_API_KEY=${{ inputs.onesignal-api-key }}" >> .env

‎.github/workflows/create-release-pr.yml‎

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,14 @@ jobs:
182182
fi
183183
echo "✓ Updated Package.swift with iOS SDK ${VERSION}"
184184
185-
PODFILE=examples/demo/ios/Podfile
186-
sed -i '' -E "s/^([[:space:]]*pod 'OneSignalXCFramework', )'[^']+'.*$/\1'${VERSION}'/" "$PODFILE"
187-
if [ "$(grep -c "pod 'OneSignalXCFramework', '${VERSION}'$" "$PODFILE")" -ne 2 ]; then
188-
echo "::error::Failed to update OneSignalXCFramework pins in ${PODFILE} to ${VERSION}"
189-
exit 1
190-
fi
191-
echo "✓ Updated ${PODFILE} extension pods to iOS SDK ${VERSION}"
185+
for PODFILE in examples/demo/ios/Podfile examples/demo-pods/ios/Podfile; do
186+
sed -i '' -E "s/^([[:space:]]*pod 'OneSignalXCFramework', )'[^']+'.*$/\1'${VERSION}'/" "$PODFILE"
187+
if [ "$(grep -c "pod 'OneSignalXCFramework', '${VERSION}'$" "$PODFILE")" -ne 2 ]; then
188+
echo "::error::Failed to update OneSignalXCFramework pins in ${PODFILE} to ${VERSION}"
189+
exit 1
190+
fi
191+
echo "✓ Updated ${PODFILE} extension pods to iOS SDK ${VERSION}"
192+
done
192193
193194
# Only commit if there are changes
194195
git add -A
@@ -238,17 +239,19 @@ jobs:
238239
# repacked SDK tarball and OneSignalXCFramework pin both reflect
239240
# the new release. setup always runs because every version bump
240241
# changes the tarball integrity recorded in the demo bun.lock.
241-
(cd examples/demo && vp run setup)
242-
echo "✓ Refreshed examples/demo/bun.lock"
243-
244-
if [ -n "$IOS_VERSION" ]; then
245-
(cd examples/demo/ios && pod update OneSignalXCFramework)
246-
else
247-
# Still refresh the local react-native-onesignal pod's version and
248-
# checksum; pod install keeps OneSignalXCFramework at its locked version.
249-
(cd examples/demo/ios && pod install)
250-
fi
251-
echo "✓ Refreshed examples/demo/ios/Podfile.lock"
242+
for DEMO in examples/demo examples/demo-pods; do
243+
(cd "$DEMO" && vp run setup)
244+
echo "✓ Refreshed ${DEMO}/bun.lock"
245+
246+
if [ -n "$IOS_VERSION" ]; then
247+
(cd "$DEMO/ios" && pod update OneSignalXCFramework)
248+
else
249+
# Still refresh the local react-native-onesignal pod's version and
250+
# checksum; pod install keeps OneSignalXCFramework at its locked version.
251+
(cd "$DEMO/ios" && pod install)
252+
fi
253+
echo "✓ Refreshed ${DEMO}/ios/Podfile.lock"
254+
done
252255
253256
# Only commit if there are changes
254257
git add -A

‎.github/workflows/e2e.yml‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ jobs:
8989
with:
9090
onesignal-app-id: ${{ vars.APPIUM_ONESIGNAL_APP_ID }}
9191
onesignal-api-key: ${{ secrets.APPIUM_ONESIGNAL_API_KEY }}
92+
demo-dir: examples/demo-pods
9293
install-pods: 'true'
9394

9495
- name: Cache Xcode DerivedData
9596
uses: actions/cache@v5
9697
with:
97-
path: examples/demo/ios/build
98-
key: deriveddata-${{ runner.os }}-${{ hashFiles('examples/demo/ios/Podfile.lock') }}
98+
path: examples/demo-pods/ios/build
99+
key: deriveddata-${{ runner.os }}-${{ hashFiles('examples/demo-pods/ios/Podfile.lock') }}
99100
restore-keys: deriveddata-${{ runner.os }}-
100101

101102
- name: Set up iOS codesigning
@@ -108,7 +109,7 @@ jobs:
108109
asc-private-key: ${{ secrets.APPIUM_APP_STORE_CONNECT_PRIVATE_KEY }}
109110

110111
- name: Build signed IPA
111-
working-directory: examples/demo/ios
112+
working-directory: examples/demo-pods/ios
112113
run: |
113114
xcodebuild archive \
114115
-workspace demo.xcworkspace \
@@ -129,7 +130,7 @@ jobs:
129130
-quiet
130131
131132
- name: Verify aps-environment in IPA
132-
working-directory: examples/demo/ios
133+
working-directory: examples/demo-pods/ios
133134
run: |
134135
IPA=$(ls build/ipa/*.ipa | head -n1)
135136
unzip -oq "$IPA" -d /tmp/ipa
@@ -144,7 +145,7 @@ jobs:
144145
uses: actions/upload-artifact@v7
145146
with:
146147
name: demo-ipa
147-
path: examples/demo/ios/build/ipa/demo.ipa
148+
path: examples/demo-pods/ios/build/ipa/demo.ipa
148149
retention-days: 1
149150
compression-level: 0
150151

‎__tests__/demoSync.test.ts‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/// <reference types="node" />
2+
3+
import { readdirSync, readFileSync } from 'node:fs';
4+
import path from 'node:path';
5+
6+
import { expect, test } from 'vite-plus/test';
7+
8+
// demo-pods is demo's iOS app on CocoaPods; its JavaScript must not drift from demo.
9+
const examples = path.resolve(import.meta.dirname, '../examples');
10+
const demo = path.join(examples, 'demo');
11+
const demoPods = path.join(examples, 'demo-pods');
12+
const sharedPaths = [
13+
'App.tsx',
14+
'index.js',
15+
'app.json',
16+
'babel.config.js',
17+
'src',
18+
'assets',
19+
'types',
20+
];
21+
22+
function listFiles(root: string, relative: string): string[] {
23+
const full = path.join(root, relative);
24+
try {
25+
return readdirSync(full, { withFileTypes: true }).flatMap((entry) =>
26+
listFiles(root, path.join(relative, entry.name)),
27+
);
28+
} catch {
29+
return [relative];
30+
}
31+
}
32+
33+
const sharedFiles = (root: string) => sharedPaths.flatMap((p) => listFiles(root, p)).sort();
34+
35+
test('demo-pods has the same JavaScript files as demo', () => {
36+
expect(sharedFiles(demoPods)).toEqual(sharedFiles(demo));
37+
});
38+
39+
test.each(sharedFiles(demo))('demo-pods/%s matches demo', (file) => {
40+
expect(readFileSync(path.join(demoPods, file))).toEqual(readFileSync(path.join(demo, file)));
41+
});
42+
43+
test('demo-pods has the same dependencies as demo', () => {
44+
const deps = (root: string) => {
45+
const pkg = JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8')) as Record<
46+
string,
47+
unknown
48+
>;
49+
return { dependencies: pkg.dependencies, devDependencies: pkg.devDependencies };
50+
};
51+
52+
expect(deps(demoPods)).toEqual(deps(demo));
53+
});

‎examples/demo-pods/.bundle/config‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

‎examples/demo-pods/.env.example‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Required. The Metro bundle fails when this is unset.
2+
ONESIGNAL_APP_ID=
3+
ONESIGNAL_API_KEY=your-onesignal-api-key
4+
5+
# Optional: Android Notification Channel ID for the WITH SOUND test notification.
6+
# Create one in your OneSignal dashboard under Settings > Android Notification Categories.
7+
ONESIGNAL_ANDROID_CHANNEL_ID=

‎examples/demo-pods/.gitignore‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Environment
2+
.env
3+
android/app/google-services.json
4+
.rn-demo-env.stamp
5+
6+
# OSX
7+
#
8+
.DS_Store
9+
10+
# Xcode
11+
#
12+
build/
13+
*.pbxuser
14+
!default.pbxuser
15+
*.mode1v3
16+
!default.mode1v3
17+
*.mode2v3
18+
!default.mode2v3
19+
*.perspectivev3
20+
!default.perspectivev3
21+
xcuserdata
22+
*.xccheckout
23+
*.moved-aside
24+
DerivedData
25+
*.hmap
26+
*.ipa
27+
*.xcuserstate
28+
**/.xcode.env.local
29+
30+
# Android/IntelliJ
31+
#
32+
build/
33+
.idea
34+
.gradle
35+
local.properties
36+
*.iml
37+
*.hprof
38+
.cxx/
39+
*.keystore
40+
!debug.keystore
41+
.kotlin/
42+
43+
# node.js
44+
#
45+
node_modules/
46+
npm-debug.log
47+
yarn-error.log
48+
49+
# fastlane
50+
#
51+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
52+
# screenshots whenever they are needed.
53+
# For more information about the recommended setup visit:
54+
# https://docs.fastlane.tools/best-practices/source-control/
55+
56+
**/fastlane/report.xml
57+
**/fastlane/Preview.html
58+
**/fastlane/screenshots
59+
**/fastlane/test_output
60+
61+
# Bundle artifact
62+
*.jsbundle
63+
64+
# Ruby / CocoaPods
65+
**/Pods/
66+
/vendor/bundle/
67+
68+
# Temporary files created by Metro to check the health of the file watcher
69+
.metro-health-check*
70+
71+
# testing
72+
/coverage
73+
74+
# Yarn
75+
.yarn/*
76+
!.yarn/patches
77+
!.yarn/plugins
78+
!.yarn/releases
79+
!.yarn/sdks
80+
!.yarn/versions

‎examples/demo-pods/.watchmanconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

‎examples/demo-pods/App.tsx‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { NavigationContainer } from '@react-navigation/native';
2+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
3+
import React, { useEffect } from 'react';
4+
import { StatusBar, StyleSheet, Text, View } from 'react-native';
5+
import { SafeAreaProvider } from 'react-native-safe-area-context';
6+
7+
import OneSignalLogo from './assets/onesignal_logo.svg';
8+
import AppHeader from './src/components/AppHeader';
9+
import { ToastProvider } from './src/components/ToastProvider';
10+
import { OneSignalProvider } from './src/hooks/useOneSignal';
11+
import HomeScreen from './src/screens/HomeScreen';
12+
import SecondaryScreen from './src/screens/SecondaryScreen';
13+
import TooltipHelper from './src/services/TooltipHelper';
14+
import { AppColors } from './src/theme';
15+
16+
const Stack = createNativeStackNavigator();
17+
18+
function App() {
19+
useEffect(() => {
20+
void TooltipHelper.getInstance().init();
21+
}, []);
22+
23+
return (
24+
<SafeAreaProvider>
25+
<StatusBar barStyle="light-content" />
26+
<ToastProvider>
27+
<OneSignalProvider>
28+
<NavigationContainer>
29+
<Stack.Navigator
30+
screenOptions={{
31+
header: (props) => <AppHeader {...props} />,
32+
}}
33+
>
34+
<Stack.Screen
35+
name="Home"
36+
component={HomeScreen}
37+
options={{
38+
headerTitle: () => (
39+
<View style={headerStyles.container}>
40+
<OneSignalLogo height={22} width={99} style={headerStyles.logo} />
41+
<Text style={headerStyles.subtitle}>React Native</Text>
42+
</View>
43+
),
44+
}}
45+
/>
46+
<Stack.Screen
47+
name="Secondary"
48+
component={SecondaryScreen}
49+
options={{ title: 'Secondary Activity' }}
50+
/>
51+
</Stack.Navigator>
52+
</NavigationContainer>
53+
</OneSignalProvider>
54+
</ToastProvider>
55+
</SafeAreaProvider>
56+
);
57+
}
58+
59+
const headerStyles = StyleSheet.create({
60+
container: {
61+
flexDirection: 'row',
62+
alignItems: 'center',
63+
},
64+
logo: {
65+
marginRight: 6,
66+
},
67+
subtitle: {
68+
fontSize: 14,
69+
fontWeight: '400',
70+
color: AppColors.white,
71+
},
72+
});
73+
74+
export default App;

‎examples/demo-pods/Gemfile‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
source 'https://rubygems.org'
2+
3+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
ruby ">= 2.6.10"
5+
6+
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
7+
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
8+
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
9+
gem 'xcodeproj', '< 1.26.0'
10+
gem 'concurrent-ruby', '< 1.3.4'
11+
12+
# Ruby 3.4.0 has removed some libraries from the standard library.
13+
gem 'bigdecimal'
14+
gem 'logger'
15+
gem 'benchmark'
16+
gem 'mutex_m'
17+
gem 'nkf'

0 commit comments

Comments
 (0)