Skip to content

Commit 5707f12

Browse files
committed
chore: migrate dev setup to env-driven CNG and package-owned iOS tests
1 parent f40d28e commit 5707f12

97 files changed

Lines changed: 609 additions & 1344 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/test.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
working-directory: apps/example
103103

104104
swift-lint:
105-
name: SwiftLint (example project)
105+
name: SwiftLint (iOS harness)
106106
runs-on: macos-latest
107107
timeout-minutes: 10
108108
steps:
@@ -114,20 +114,20 @@ jobs:
114114

115115
- uses: actions/cache@v4
116116
with:
117-
path: apps/example/ios/Pods
118-
key: ${{ runner.os }}-pods-${{ hashFiles('apps/example/ios/Podfile.lock') }}
117+
path: packages/react-native-device-activity/ios/TestHarness/Pods
118+
key: ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-device-activity/ios/TestHarness/Podfile.lock') }}
119119
restore-keys: |
120120
${{ runner.os }}-pods-
121121
122122
- run: bun install
123123

124124
- run: pod install
125-
working-directory: apps/example/ios
125+
working-directory: packages/react-native-device-activity/ios/TestHarness
126126

127-
- run: apps/example/ios/Pods/SwiftLint/swiftlint lint
127+
- run: packages/react-native-device-activity/ios/TestHarness/Pods/SwiftLint/swiftlint lint --config .swiftlint.yml
128128

129129
swift-test:
130-
name: Swift Test (example project)
130+
name: Swift Test (iOS harness)
131131
runs-on: macos-latest
132132
timeout-minutes: 25
133133
steps:
@@ -149,8 +149,8 @@ jobs:
149149

150150
- uses: actions/cache@v4
151151
with:
152-
path: apps/example/ios/Pods
153-
key: ${{ runner.os }}-pods-${{ hashFiles('apps/example/ios/Podfile.lock') }}
152+
path: packages/react-native-device-activity/ios/TestHarness/Pods
153+
key: ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-device-activity/ios/TestHarness/Podfile.lock') }}
154154
restore-keys: |
155155
${{ runner.os }}-pods-
156156
@@ -172,9 +172,7 @@ jobs:
172172
run: swift --version
173173

174174
- run: pod install
175-
working-directory: apps/example/ios
175+
working-directory: packages/react-native-device-activity/ios/TestHarness
176176

177-
- run: cp .swiftlint.yml apps/example/ios
178-
179-
- run: xcodebuild test -workspace reactnativedeviceactivityexample.xcworkspace -scheme Tests -allowProvisioningUpdates -destination "platform=iOS Simulator,OS=latest,name=iPhone 17"
180-
working-directory: apps/example/ios
177+
- run: xcodebuild test -workspace reactnativedeviceactivityexample.xcworkspace -scheme Tests -destination "platform=iOS Simulator,OS=latest,name=iPhone 17" CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO
178+
working-directory: packages/react-native-device-activity/ios/TestHarness

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ project.xcworkspace
3636
local.properties
3737
android.iml
3838

39+
# Example native output (CNG)
40+
apps/example/ios/
41+
apps/example/android/
42+
3943
# Cocoapods
4044
#
4145
apps/example/ios/Pods

.husky/pre-commit

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
swift format -i -p -r ./packages/react-native-device-activity/ios ./packages/react-native-device-activity/targets ./apps/example/ios
2-
apps/example/ios/Pods/SwiftLint/swiftlint lint --fix
1+
swift format -i -p -r ./packages/react-native-device-activity/ios/Tests ./packages/react-native-device-activity/targets ./packages/react-native-device-activity/ios/TestHarness/reactnativedeviceactivityexample
2+
swift format -i -p ./packages/react-native-device-activity/ios/Shared.swift
3+
packages/react-native-device-activity/ios/TestHarness/Pods/SwiftLint/swiftlint lint --fix --config .swiftlint.yml

.swiftlint.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ disabled_rules:
1212
- inclusive_language
1313

1414
included:
15-
- packages/react-native-device-activity/ios
16-
- apps/example/ios
15+
- packages/react-native-device-activity/ios/Tests
16+
- packages/react-native-device-activity/ios/Shared.swift
17+
- packages/react-native-device-activity/ios/TestHarness/reactnativedeviceactivityexample
1718
- packages/react-native-device-activity/targets
19+
20+
excluded:
21+
- packages/react-native-device-activity/ios/TestHarness/Pods
22+
- packages/react-native-device-activity/ios/TestHarness/build

CONTRIBUTING.md

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,57 @@
1-
# Example project setup
1+
# Repository development setup
22

3-
The example project is linked specifically to simplify development. This means it's not looking exactly like the published package, but for most intents and purposes it should result in the same outcome.
3+
## Example app config (env-driven)
44

5-
- The config plugin has a `copyToTargetFolder` option that is set to false. This is to prevent the target folder from being copied to the example project and potentially overwriting the original files.
6-
- The swift files in the targets folder are linked to the root project instead of duplicated. If adding new swift files, try to link them instead of duplicating to keep things clean.
7-
- The entitlements and info.plist files however duplicated - to not mess with the example project/signing etc.
8-
- There is a Shared.swift file that can be accessed by all targets. This is linked to each target in the example project, but in the published package it's copied and duplicated to each target. I prefer this to making more changes in @bacons/xcode package which only supports swift files on the root level of each target directory.
9-
- In addition the example project contains an XCode test target as well as SwiftLint.
5+
The example app uses `apps/example/app.config.ts` so local developer values do not need to be committed.
106

11-
## Prebuild
7+
Create local env values from the template:
128

13-
To try out prebuild functionality (i.e. the config plugin) run `bun run prebuild` in the example project (it uses the `INTERNALLY_TEST_EXAMPLE_PROJECT` and `COPY_TO_TARGET_FOLDER` env variables to behave like a published package). This should be used to verify changes are expected, but the result should not in it's full state be commited to the example project, since it will break the DX of the example project as explained above.
9+
```bash
10+
cp apps/example/.env.example apps/example/.env
11+
```
12+
13+
Supported variables:
14+
15+
- `RNDA_APPLE_TEAM_ID`
16+
- `RNDA_APP_GROUP`
17+
- `RNDA_IOS_BUNDLE_ID`
18+
- `RNDA_ANDROID_PACKAGE`
19+
20+
If these variables are missing, `app.config.ts` falls back to stable defaults for this repository.
21+
22+
## Example app follows CNG
23+
24+
The example app no longer tracks `apps/example/ios` and `apps/example/android`.
25+
26+
Regenerate native folders when needed:
27+
28+
```bash
29+
cd apps/example
30+
bun run prebuild
31+
# or
32+
bun run ios
33+
bun run android
34+
```
35+
36+
## Swift test ownership
37+
38+
Swift test sources are package-owned and live in:
39+
40+
- `packages/react-native-device-activity/ios/Tests`
41+
42+
The iOS test runner lives in:
43+
44+
- `packages/react-native-device-activity/ios/TestHarness`
45+
46+
## Plugin testing
47+
48+
In addition to app/prebuild validation, config plugin regression tests are defined under:
49+
50+
- `packages/react-native-device-activity/plugin/__tests__`
51+
52+
Run them with:
53+
54+
```bash
55+
cd packages/react-native-device-activity
56+
bun run test:plugin
57+
```

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,23 @@ For a complete implementation, see the [example app](https://github.com/Kingstin
583583

584584
Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo#contributing).
585585

586+
### Repository development setup
587+
588+
This repository uses an env-driven Expo example config in `apps/example/app.config.ts` to avoid committing local developer values such as team ID and app group.
589+
590+
Use `apps/example/.env.example` as a template for local values:
591+
592+
- `RNDA_APPLE_TEAM_ID`
593+
- `RNDA_APP_GROUP`
594+
- `RNDA_IOS_BUNDLE_ID`
595+
- `RNDA_ANDROID_PACKAGE`
596+
597+
The example app follows CNG workflow (`expo prebuild --clean` / `expo run:*`) and native folders are generated as needed.
598+
599+
Swift test sources are package-owned in `packages/react-native-device-activity/ios/Tests` and run through the iOS harness in `packages/react-native-device-activity/ios/TestHarness`.
600+
601+
For repository-specific details, see [`CONTRIBUTING.md`](./CONTRIBUTING.md).
602+
586603
## Weird behaviors ⚠️
587604

588605
- Authorization changes outside app not captured

apps/example/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
RNDA_APPLE_TEAM_ID=YOUR_APPLE_TEAM_ID
2+
RNDA_APP_GROUP=group.your-app-group
3+
RNDA_IOS_BUNDLE_ID=com.yourcompany.yourapp
4+
RNDA_ANDROID_PACKAGE=com.yourcompany.yourapp

apps/example/android/.gitignore

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)