Skip to content

Commit c8d56e5

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 c8d56e5

102 files changed

Lines changed: 10544 additions & 18 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/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

‎__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'

‎examples/demo-pods/README.md‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# OneSignal React Native Demo (CocoaPods)
2+
3+
The [`demo`](../demo) app's iOS build, integrated with CocoaPods. Use it to check the SDK in apps that have not moved to React Native's Swift Package Manager mode.
4+
5+
The JavaScript (`App.tsx`, `src/`, `assets/`, `types/`) must stay identical to `demo`; a test in the repository root fails when they drift. Make JavaScript changes in `demo` and copy them here. There is no Android project here; use `demo` for Android.
6+
7+
## Setup
8+
9+
Install the SDK's dependencies from the repository root, since setup builds and packs the SDK from there:
10+
11+
```sh
12+
vp install
13+
```
14+
15+
Then, in this directory, copy `.env.example` to `.env` and set your credentials as described in the [`demo` README](../demo/README.md#setup). Install CocoaPods on first run:
16+
17+
```sh
18+
bundle install
19+
cd ios && bundle exec pod install && cd ..
20+
```
21+
22+
## Run
23+
24+
```sh
25+
vp run ios
26+
```
27+
28+
## Other scripts
29+
30+
| Script | Purpose |
31+
| -------------------- | --------------------------------------------------------------------- |
32+
| `vp run setup` | Build, pack, and install the SDK into the demo. |
33+
| `vp run start` | Start Metro. |
34+
| `vp run update:pods` | Run `pod update OneSignalXCFramework` after native SDK changes. |
35+
| `vp run clean:ios` | Wipe iOS build outputs and `ios/Pods`. Run `pod install` again after. |

‎examples/demo-pods/app.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "demo",
3+
"displayName": "OneSignal Demo"
4+
}

0 commit comments

Comments
 (0)