From 9de34e46c8df253e0987a09c694888bc5551cfef Mon Sep 17 00:00:00 2001 From: cristianceban Date: Wed, 13 Mar 2024 13:58:15 +0200 Subject: [PATCH] feat(expo-plugin): add docs --- README.md | 4 ++++ expo-prebuild.MD | 45 ++++++++++++++++++++++++++++++++++++++ plugin/src/ios/getFiles.ts | 14 ++++++++++++ yarn.lock | 5 ----- 4 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 expo-prebuild.MD diff --git a/README.md b/README.md index 56b7bef..d25f531 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/expo-prebuild.MD b/expo-prebuild.MD new file mode 100644 index 0000000..e88888b --- /dev/null +++ b/expo-prebuild.MD @@ -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 + + + + + + +``` + +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. diff --git a/plugin/src/ios/getFiles.ts b/plugin/src/ios/getFiles.ts index c5447aa..f2a486e 100644 --- a/plugin/src/ios/getFiles.ts +++ b/plugin/src/ios/getFiles.ts @@ -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; } diff --git a/yarn.lock b/yarn.lock index 6470ab3..3bdd0e5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"