Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
root: true,
extends: ['universe/native', 'universe/web'],
ignorePatterns: ['build'],
extends: ["universe/native", "universe/web"],
ignorePatterns: ["build"],
};
22 changes: 11 additions & 11 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,41 @@ on:
workflow_dispatch:
inputs:
description:
description: 'Description'
description: "Description"
required: false
type: string
release_type:
description: 'Release Type'
description: "Release Type"
required: true
default: 'patch'
default: "patch"
type: choice
options:
- 'patch'
- 'minor'
- 'major'
- "patch"
- "minor"
- "major"

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- run: bun install

- run: bun lint

- run: bun typecheck

publish-to-npm:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4

- uses: oven-sh/setup-bun@v2
Expand Down Expand Up @@ -90,4 +90,4 @@ jobs:
with:
name: ${{ env.versionTag }} ${{ github.event.inputs.description }}
tag_name: ${{ env.versionTag }}
generate_release_notes: true
generate_release_notes: true
6 changes: 3 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
Expand All @@ -21,6 +21,6 @@ jobs:
cd packages/react-native-device-activity
bun run build
bun run prepublishOnly

- name: Publish preview
run: bunx pkg-pr-new@latest publish './packages/*'
run: bunx pkg-pr-new@latest publish './packages/*'
24 changes: 11 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
working-directory: apps/example

swift-lint:
name: SwiftLint (example project)
name: SwiftLint (iOS harness)
runs-on: macos-latest
timeout-minutes: 10
steps:
Expand All @@ -114,20 +114,20 @@ jobs:

- uses: actions/cache@v4
with:
path: example/ios/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('example/ios/Podfile.lock') }}
path: packages/react-native-device-activity/ios/TestHarness/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-device-activity/ios/TestHarness/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-

- run: bun install

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

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

swift-test:
name: Swift Test (example project)
name: Swift Test (iOS harness)
runs-on: macos-latest
timeout-minutes: 25
steps:
Expand All @@ -149,8 +149,8 @@ jobs:

- uses: actions/cache@v4
with:
path: example/ios/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('example/ios/Podfile.lock') }}
path: packages/react-native-device-activity/ios/TestHarness/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-device-activity/ios/TestHarness/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-

Expand All @@ -172,9 +172,7 @@ jobs:
run: swift --version

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

- run: cp .swiftlint.yml apps/example/ios

- run: xcodebuild test -workspace reactnativedeviceactivityexample.xcworkspace -scheme Tests -allowProvisioningUpdates -destination "platform=iOS Simulator,OS=latest,name=iPhone 17"
working-directory: apps/example/ios
- 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
working-directory: packages/react-native-device-activity/ios/TestHarness
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,17 @@ project.xcworkspace
local.properties
android.iml

# Example native output (CNG)
apps/example/ios/
apps/example/android/
apps/example/targets/

# Cocoapods
#
example/ios/Pods
apps/example/ios/Pods

# Ruby
example/vendor/
apps/example/vendor/

# node.js
#
Expand Down
5 changes: 3 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
swift format -i -p -r ./packages/react-native-device-activity/ios ./packages/react-native-device-activity/targets ./apps/example/ios
apps/example/ios/Pods/SwiftLint/swiftlint lint --fix
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
swift format -i -p ./packages/react-native-device-activity/ios/Shared.swift
packages/react-native-device-activity/ios/TestHarness/Pods/SwiftLint/swiftlint lint --fix --config .swiftlint.yml
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run pre-push
bun run pre-push
4 changes: 2 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ __tests__
/android/src/androidTest/
/android/src/test/
/android/build/
/example/
/apps/example/

# Test files
*.test.ts
Expand All @@ -18,4 +18,4 @@ __tests__
__tests__/

# seems like something is causing example to get installed recursively (bun bug?)
example
apps/example
15 changes: 15 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
node_modules/
bun.lock

# Expo / native generated artifacts
apps/example/.expo/
apps/example/dist/
apps/example/ios/Pods/
apps/example/ios/build/

# Package build output
packages/react-native-device-activity/build/

# iOS test harness generated artifacts
packages/react-native-device-activity/ios/TestHarness/Pods/
packages/react-native-device-activity/ios/TestHarness/build/
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"singleQuote": false,
"semi": true,
"trailingComma": "all"
}
11 changes: 8 additions & 3 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ disabled_rules:
- inclusive_language

included:
- packages/react-native-device-activity/ios
- apps/example/ios
- packages/react-native-device-activity/targets
- packages/react-native-device-activity/ios/Tests
- packages/react-native-device-activity/ios/Shared.swift
- packages/react-native-device-activity/ios/TestHarness/reactnativedeviceactivityexample
- packages/react-native-device-activity/targets

excluded:
- packages/react-native-device-activity/ios/TestHarness/Pods
- packages/react-native-device-activity/ios/TestHarness/build
7 changes: 2 additions & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"recommendations": [
"vknabel.vscode-swiftlint",
"swiftlang.swift-vscode"
],
}
"recommendations": ["vknabel.vscode-swiftlint", "swiftlang.swift-vscode"]
}
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"android": {}
}
]
}
}
8 changes: 3 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"cSpell.words": [
"Triggerable"
],
"swiftlint.path": "apps/example/ios/Pods/SwiftLint/swiftlint",
"cSpell.words": ["Triggerable"],
"swiftlint.path": "packages/react-native-device-activity/ios/TestHarness/Pods/SwiftLint/swiftlint",
"swift.SDK": "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.2.sdk"
}
}
82 changes: 73 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,77 @@
# Example project setup
# Repository development setup

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.
## Example app config (env-driven)

- 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.
- 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.
- The entitlements and info.plist files however duplicated - to not mess with the example project/signing etc.
- 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.
- In addition the example project contains an XCode test target as well as SwiftLint.
The example app uses `apps/example/app.config.ts` so local developer values do not need to be committed.

## Prebuild
Create local env values from the template:

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.
```bash
cp apps/example/.env.example apps/example/.env
```

Supported variables:

- `RNDA_APPLE_TEAM_ID`
- `RNDA_APP_GROUP`
- `RNDA_IOS_BUNDLE_ID`
- `RNDA_ANDROID_PACKAGE`

If these variables are missing, `app.config.ts` falls back to stable defaults for this repository.

## Example app follows CNG

The example app no longer tracks `apps/example/ios` and `apps/example/android`.
The example target folder `apps/example/targets` is also generated during prebuild and should not be committed.

Regenerate native folders when needed:

```bash
cd apps/example
bun run prebuild
# or
bun run ios
bun run android
```

## Swift test ownership

Swift test sources are package-owned and live in:

- `packages/react-native-device-activity/ios/Tests`

The iOS test runner lives in:

- `packages/react-native-device-activity/ios/TestHarness`

## SwiftLint setup

The repository runs SwiftLint from the iOS test harness CocoaPods installation:

- `packages/react-native-device-activity/ios/TestHarness/Pods/SwiftLint/swiftlint`

Run this once after cloning (and again if Pod dependencies are cleaned):

```bash
cd packages/react-native-device-activity/ios/TestHarness
pod install
```

Then run repository checks from the root:

```bash
bun run pre-push
```

## Plugin testing

In addition to app/prebuild validation, config plugin regression tests are defined under:

- `packages/react-native-device-activity/plugin/__tests__`

Run them with:

```bash
cd packages/react-native-device-activity
bun run test:plugin
```
Loading