Skip to content

Commit

Permalink
feat(expo-plugin): add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
CristiCeban committed Mar 13, 2024
1 parent 740cd2f commit 9de34e4
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ and run `pod install`.
### Expo Support

This library has been successfully used in Expo apps (Bare Workflow with EAS Build).

## Generating watch target in expo prebuild

This library is available as a [prebuild](https://docs.expo.dev/workflow/prebuild/) for Expo apps. It will automatically generate a watch target for you. For more information about integration, see [expo-prebuild.MD](expo-prebuild.MD).
45 changes: 45 additions & 0 deletions expo-prebuild.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
This library is available as a prebuild for Expo apps. To use it, add the following to your `app.json`:

```json
{
"expo": {
"plugins": [
"react-native-watch-connectivity",
{
"name": "watch",
"bundleId": "com.expo.watch.example",
"displayName": "EAS WATCH",
"sourceDir": "watch",
"deploymentTarget": "7.0"
}
]
}
}
```

Available options are:

- `name` (required) - the name of the watch app
- `bundleId` (required) - the bundle identifier of the companion iOS app (your main app)
- `displayName` (required) - the display name of the watch app
- `sourceDir` (required) - the directory where the watch files are located
- `deploymentTarget` (required) - the deployment target of the watch app

you can see a example integration [here](https://github.com/CristiCeban/watch-example).

Mainly, you will need a new folder with your watch app files.
`watch` folder should contain `Info.plist` (it also could be empty) like that:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>
```

and `Assets.xcassets` folder with `AppIcon.appiconset`. Here you can change the icon for your watch app. (be sure to change it's name also in `Contents.json` file)
Note - icon should be 1024x1024px.

After that, you can run `expo prebuild` and it will generate a `ios/watch` folder with the watch app files.
14 changes: 14 additions & 0 deletions plugin/src/ios/getFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,19 @@ export function getFilesForXcode(filesPath: string): WidgetFiles {
});
}

const allFiles = [...widgetFiles.resourcesFiles, ...widgetFiles.sourceFiles];

if (!allFiles.find((file) => file.includes('Info.plist'))) {
console.warn(
'Info.plist file is required for the watch, please add it to the folder declared as `sourceDir` in `app.json`',
);
}

if (!allFiles.find((file) => file.includes('Assets.xcassets'))) {
console.warn(
'Assets.xcassets file is required for the watch, please add it to the folder declared as `sourceDir` in `app.json`',
);
}

return widgetFiles;
}
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4185,11 +4185,6 @@ deep-is@~0.1.3:
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=

deep-object-diff@^1.1.9:
version "1.1.9"
resolved "https://registry.yarnpkg.com/deep-object-diff/-/deep-object-diff-1.1.9.tgz#6df7ef035ad6a0caa44479c536ed7b02570f4595"
integrity sha512-Rn+RuwkmkDwCi2/oXOFS9Gsr5lJZu/yTGpK7wAaAIE75CC+LCGEZHpY6VQJa/RoJcrmaA/docWJZvYohlNkWPA==

deepmerge@^3.2.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-3.3.0.tgz#d3c47fd6f3a93d517b14426b0628a17b0125f5f7"
Expand Down

0 comments on commit 9de34e4

Please sign in to comment.