{"_id":"@duell10111/apple-targets","_rev":"3-3030760a4ba8900cabf7aea985a90877","name":"@duell10111/apple-targets","dist-tags":{"latest":"0.1.14"},"versions":{"0.0.6-alpha.0":{"name":"@duell10111/apple-targets","version":"0.0.6-alpha.0","keywords":["expo","config-plugins","apple-targets"],"author":{"name":"Evan Bacon"},"license":"MIT","_id":"@duell10111/apple-targets@0.0.6-alpha.0","maintainers":[{"name":"duell10111","email":"duell10111@t-online.de"}],"dist":{"shasum":"57202a9a97b3d079967cb6751ed4c87f0a7a84f9","tarball":"https://registry.npmjs.org/@duell10111/apple-targets/-/apple-targets-0.0.6-alpha.0.tgz","fileCount":32,"integrity":"sha512-5sMGI92vnhqeyaBdeMw0W3flsR3HmqGuR4rTZLEcWDXn1q9pXe9vYeHEmT2VvzY8AcJ1Tr4NMNd5mpPlkX3JuQ==","signatures":[{"sig":"MEQCIEx4tvH1P9+wWaASU9Pi4h+WIlWesLw/hZGNeg6qY7WBAiACEKs3WSAS/LSwTy/E0ucTsA1CUsFBmoOSgbSgViNPPg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":156259},"main":"build/index.js","scripts":{"lint":"expo-module lint","test":"jest --watch","build":"expo-module build","clean":"expo-module clean","prepare":"expo-module prepare","expo-module":"expo-module","prepublishOnly":"expo-module prepublishOnly"},"_npmUser":{"name":"duell10111","email":"duell10111@t-online.de"},"repository":{"url":"https://github.com/evanbacon/expo-apple-targets.git","type":"git"},"description":"Generate Apple Targets with Expo Prebuild","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2023 evanbacon\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","dependencies":{"glob":"^10.2.6","fs-extra":"^11.2.0","@bacons/xcode":"^1.0.0-alpha.13","@react-native/normalize-color":"^2.1.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/glob":"^8.1.0","@types/fs-extra":"^11.0.4","jest-environment-node":"^26","@expo/babel-preset-cli":"^0.3.1"},"_npmOperationalInternal":{"tmp":"tmp/apple-targets_0.0.6-alpha.0_1723759736918_0.32395869949780165","host":"s3://npm-registry-packages"}},"0.0.6-alpha.1":{"name":"@duell10111/apple-targets","version":"0.0.6-alpha.1","keywords":["expo","config-plugins","apple-targets"],"author":{"name":"Evan Bacon"},"license":"MIT","_id":"@duell10111/apple-targets@0.0.6-alpha.1","maintainers":[{"name":"duell10111","email":"duell10111@t-online.de"}],"dist":{"shasum":"05bb62a0ae8e53c55693d3012760781bdc034ce3","tarball":"https://registry.npmjs.org/@duell10111/apple-targets/-/apple-targets-0.0.6-alpha.1.tgz","fileCount":32,"integrity":"sha512-/Ana03gTFzr9VUu6Kgoq01OYd0tCa42BwWokngSCk+kFIcheuBaLHmBsE4oZ+8KXHxKua+bMlaCslBgPIdpgew==","signatures":[{"sig":"MEYCIQCye8RZHE2Iw4krsP8pKWhMPKPQ13p5PDOP68E9ZRVQHQIhALw+pVSQu6wpZ+MAz0o3k4Wp/uB8V8BA70Tv15LLixXl","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":156724},"main":"build/index.js","scripts":{"lint":"expo-module lint","test":"jest --watch","build":"expo-module build","clean":"expo-module clean","prepare":"expo-module prepare","expo-module":"expo-module","prepublishOnly":"expo-module prepublishOnly"},"_npmUser":{"name":"duell10111","email":"duell10111@t-online.de"},"repository":{"url":"https://github.com/evanbacon/expo-apple-targets.git","type":"git"},"description":"Generate Apple Targets with Expo Prebuild","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2023 evanbacon\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","dependencies":{"glob":"^10.2.6","fs-extra":"^11.2.0","@bacons/xcode":"^1.0.0-alpha.13","@react-native/normalize-color":"^2.1.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/glob":"^8.1.0","@types/fs-extra":"^11.0.4","jest-environment-node":"^26","@expo/babel-preset-cli":"^0.3.1"},"_npmOperationalInternal":{"tmp":"tmp/apple-targets_0.0.6-alpha.1_1723994120332_0.5089926225114736","host":"s3://npm-registry-packages"}},"0.0.6-alpha.2":{"name":"@duell10111/apple-targets","version":"0.0.6-alpha.2","keywords":["expo","config-plugins","apple-targets"],"author":{"name":"Evan Bacon"},"license":"MIT","_id":"@duell10111/apple-targets@0.0.6-alpha.2","maintainers":[{"name":"duell10111","email":"duell10111@t-online.de"}],"dist":{"shasum":"333529890cc19e565451261d1a7b2962363bf9ab","tarball":"https://registry.npmjs.org/@duell10111/apple-targets/-/apple-targets-0.0.6-alpha.2.tgz","fileCount":32,"integrity":"sha512-wMTIG029aoLIp7N95GHxFUH2lv4LUG3OQOqsSylS59KXUlehNdomUoxE84PIRSBnDjOD4+QBtcEC67jaB+zp/g==","signatures":[{"sig":"MEUCIHLEl88OfTu+6N4uKzICtV5tGrS8JNRKcuGC7BOuUa1FAiEA6lJBeEZ0vk5Qv/IOgzwdZz7vdGtiqM7o+sCCbiAWoI0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":156932},"main":"build/index.js","scripts":{"lint":"expo-module lint","test":"jest --watch","build":"expo-module build","clean":"expo-module clean","prepare":"expo-module prepare","expo-module":"expo-module","prepublishOnly":"expo-module prepublishOnly"},"_npmUser":{"name":"duell10111","email":"duell10111@t-online.de"},"repository":{"url":"https://github.com/evanbacon/expo-apple-targets.git","type":"git"},"description":"Generate Apple Targets with Expo Prebuild","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2023 evanbacon\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","dependencies":{"glob":"^10.2.6","fs-extra":"^11.2.0","@bacons/xcode":"^1.0.0-alpha.13","@react-native/normalize-color":"^2.1.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/glob":"^8.1.0","@types/fs-extra":"^11.0.4","jest-environment-node":"^26","@expo/babel-preset-cli":"^0.3.1"},"_npmOperationalInternal":{"tmp":"tmp/apple-targets_0.0.6-alpha.2_1730708748312_0.6695855072795611","host":"s3://npm-registry-packages"}},"0.1.14":{"name":"@duell10111/apple-targets","version":"0.1.14","description":"Generate Apple Targets with Expo Prebuild","main":"build/ExtensionStorage.js","types":"build/ExtensionStorage.d.ts","scripts":{"build":"expo-module build","clean":"expo-module clean","lint":"expo-module lint","test":"jest --watch","prepare":"expo-module prepare","prepublishOnly":"expo-module prepublishOnly","expo-module":"expo-module"},"repository":{"type":"git","url":"https://github.com/evanbacon/expo-apple-targets.git"},"keywords":["expo","config-plugins","apple-targets"],"author":{"name":"Evan Bacon"},"license":"MIT","dependencies":{"@react-native/normalize-colors":"^0.76.1","glob":"^10.2.6","@bacons/xcode":"1.0.0-alpha.24","fs-extra":"^11.2.0"},"devDependencies":{"@types/fs-extra":"^11.0.4","@types/glob":"^8.1.0","@expo/babel-preset-cli":"^0.3.1","jest-environment-node":"^26"},"licenseText":"MIT License\n\nCopyright (c) 2023 evanbacon\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@duell10111/apple-targets@0.1.14","dist":{"shasum":"128e6fae498e2c6a258cfe0f3fa0f36fe040065d","integrity":"sha512-KJGkGa/PFeV2ZlyFS7oDo4JakjwVXf7SFbM53kzh0FiDENb7hoY89Bh2uPhgCUFrpl+CS9J+XaEGegY5hGdNWQ==","tarball":"https://registry.npmjs.org/@duell10111/apple-targets/-/apple-targets-0.1.14.tgz","fileCount":45,"unpackedSize":469818,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE9+QKDhasrxrrSqKpg7EDdH3K170RqHgQmJPfkAYBqWAiBHUZhxTX2StViAaZDBNnYYQ54554tyUFdWti5OLtn9mg=="}]},"_npmUser":{"name":"duell10111","email":"duell10111@t-online.de"},"directories":{},"maintainers":[{"name":"duell10111","email":"duell10111@t-online.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/apple-targets_0.1.14_1734232573063_0.5941926452314736"},"_hasShrinkwrap":false}},"time":{"created":"2024-08-15T22:08:56.818Z","modified":"2024-12-15T03:16:13.461Z","0.0.6-alpha.0":"2024-08-15T22:08:57.136Z","0.0.6-alpha.1":"2024-08-18T15:15:20.508Z","0.0.6-alpha.2":"2024-11-04T08:25:48.489Z","0.1.14":"2024-12-15T03:16:13.282Z"},"author":{"name":"Evan Bacon"},"license":"MIT","keywords":["expo","config-plugins","apple-targets"],"repository":{"type":"git","url":"https://github.com/evanbacon/expo-apple-targets.git"},"description":"Generate Apple Targets with Expo Prebuild","maintainers":[{"name":"duell10111","email":"duell10111@t-online.de"}],"readme":"# Apple Targets plugin\n\n> [!WARNING]\n> This is highly experimental and not part of any official Expo workflow.\n\n<img width=\"1061\" alt=\"Screenshot 2023-06-10 at 1 59 26 PM\" src=\"https://github.com/EvanBacon/expo-apple-targets/assets/9664363/4cd8399d-53aa-401a-9caa-3a1432a0640c\">\n\nAn experimental Expo Config Plugin that generates native Apple Targets like Widgets or App Clips, and links them outside the `/ios` directory. You can open Xcode and develop the targets inside the virtual `expo:targets` folder and the changes will be saved outside of the `ios` directory. This pattern enables building things that fall outside of the scope of React Native while still obtaining all the benefits of Continuous Native Generation.\n\n## 🚀 How to use\n\n> This plugin requires at least CocoaPods 1.16.2 (ruby 3.2.0), Xcode 16 (macOS 15 Sequoia), and Expo SDK +52.\n\n1. Run `npx create-target` in your Expo project to generate an Apple target.\n2. Select a target to generate, I recommend starting with a `widget` (e.g. `npx create-target widget`). This will generate the required widget files in the root `/targets` directory, install `@bacons/apple-targets`, and add the Expo Config Plugin to your project.\n3. If you already know your Apple Team ID, then set it under the `ios.appleTeamId` property in your `app.json`. You can find this in Xcode under the Signing & Capabilities tab and set it later if needed.\n4. Run `npx expo prebuild -p ios --clean` to generate the Xcode project.\n5. You can now open your project in Xcode (`xed ios`) and develop the widget inside the `expo:targets/<target>` folder.\n6. When you're ready to build, select the target in Xcode and build it.\n\n### How it works\n\nThe root `/targets` folder is magic, each sub-directory should have a `expo-target.config.js` file that defines the target settings. When you run `npx expo prebuild --clean`, the plugin will generate the Xcode project and link the target files to the project. The plugin will also generate an `Info.plist` file if one doesn't exist.\n\nThe Config Plugin will link the subfolder (e.g. `targets/widget`) to Xcode, and all files inside of it will be part of the target. This means you can develop the target inside the `expo:targets` folder and the changes will be saved outside of the generated `ios` directory.\n\nThe root `Info.plist` file in each target directory is not managed and can be freely modified.\n\nAny files in a top-level `target/{name}/assets` directory will be linked as resources of the target. This rule was added to support Safari Extensions.\n\n### Entitlements\n\nIf the `expo-target.config` file defines an `entitlements: {}` object, then a `generated.entitlements` will be added. Avoid using this file directly, and instead update the `expo-target.config.js` file. If the `entitlements` object is not defined, you can manually add any top-level `*.entitlements` file to the target directory—re-running `npx expo prebuild` will link this file to the target as the entitlements file. Only one top-level `*.entitlements` file is supported per target.\n\nSome targets have special entitlements behavior:\n\n- App Clips (`clip`) automatically set the required `com.apple.developer.parent-application-identifiers` to `$(AppIdentifierPrefix)${config.ios.bundleIdentifier}`\n- Targets that can utilize App Groups will automatically mirror the `ios.entitlements['com.apple.security.application-groups']` array from the `app.json` if it's defined. This can be overwritten by specifying an `entitlements['com.apple.security.application-groups']` array in the `expo-target.config.js` file.\n\n### Development\n\nAny changes you make outside of the `expo:targets` directory in Xcode are subject to being overwritten by the next `npx expo prebuild --clean`. Check to see if the settings you want to toggle are available in the Info.plist or the `expo-target.config.js` file.\nIf you modify the `expo-target.config.js` or your root `app.json`, you will need to re-run `npx expo prebuild --clean` to sync the changes.\n\nYou can use the custom Prebuild template `--template node_modules/@bacons/apple-targets/prebuild-blank.tgz` to create a build without React Native, this can make development a bit faster since there's less to compile.\n\n## Target config\n\nThe target config can be a `expo-target.config.js`, or `expo-target.config.json` file.\n\nThis file can have the following properties:\n\n```js\n/** @type {import('@bacons/apple-targets/app.plugin').Config} */\nmodule.exports = {\n  type: \"widget\",\n\n  // Name of the target/product. Defaults to the directory name.\n  name: \"My Widget\",\n\n  // Generates colorset files for the target.\n  colors: {\n    // or \"$accent\": \"red\",\n    $accent: { color: \"red\", darkColor: \"blue\" },\n  },\n  icon: \"../assets/icon.png\",\n  // Can also be a URL\n  frameworks: [\n    // Frameworks with or without the `.frameworks` extension, these will be added to the target.\n    \"SwiftUI\",\n  ],\n  entitlements: {\n    // Serialized entitlements. Useful for configuring with environment variables.\n  },\n  // Generates xcassets for the target.\n  images: {\n    thing: \"../assets/thing.png\",\n  },\n\n  // The iOS version fot the target. Defaults to 18.1\n  deploymentTarget: \"15.1\",\n\n  // Optional bundle identifier for the target. Will default to a sanitized version of the root project bundle id + target name.\n  // If the specified bundle identifier is prefixed with a dot (.), the bundle identifier will be appended to the main app's bundle identifier.\n  bundleIdentifier: \".mywidget\",\n\n  // Should the release build export the JS bundle and embed. Intended for App Clips and Share Extensions where you may want to use React Native.\n  exportJs: false,\n};\n```\n\nYou can also return a function that accepts the Expo Config and returns a target function for syncing entitlements and other values:\n\n```js\n/** @type {import('@bacons/apple-targets/app.plugin').ConfigFunction} */\nmodule.exports = (config) => ({\n  type: \"widget\",\n  colors: {\n    $accent: \"steelblue\",\n  },\n  entitlements: {\n    // Use the same app groups:\n    \"com.apple.security.application-groups\":\n      config.ios.entitlements[\"com.apple.security.application-groups\"],\n    // Or generate an app group:\n    \"com.apple.security.application-groups\": [\n      `group.${config.ios.bundleIdentifier}.widget`,\n    ],\n  },\n});\n```\n\n> ESM and TypeScript are not supported in the target config. Stick to `require` for sharing variables across targets.\n\n## Colors\n\nThere are certain values that are shared across targets. We use a predefined convention to map these values across targets.\n\n| Name                | Build Setting                                        | Purpose                                                                                                      |\n| ------------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |\n| `$accent`           | `ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME`     | Sets the global accent color, in widgets this is used for the tint color of buttons when editing the widget. |\n| `$widgetBackground` | `ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME` | Sets the background color of the widget.                                                                     |\n\n## CocoaPods\n\nAdding a file `pods.rb` in the root of the repo will enable you to modify the target settings for the project.\n\nThe ruby module evaluates with global access to the property `podfile_properties`.\n\nFor example, the following is useful for enabling React Native in an App Clip target:\n\n```rb\nrequire File.join(File.dirname(`node --print \"require.resolve('react-native/package.json')\"`), \"scripts/react_native_pods\")\n\nexclude = []\nuse_expo_modules!(exclude: exclude)\n\nif ENV['EXPO_USE_COMMUNITY_AUTOLINKING'] == '1'\n  config_command = ['node', '-e', \"process.argv=['', '', 'config'];require('@react-native-community/cli').run()\"];\nelse\n  config_command = [\n    'node',\n    '--no-warnings',\n    '--eval',\n    'require(require.resolve(\\'expo-modules-autolinking\\', { paths: [require.resolve(\\'expo/package.json\\')] }))(process.argv.slice(1))',\n    'react-native-config',\n    '--json',\n    '--platform',\n    'ios'\n  ]\nend\n\nconfig = use_native_modules!(config_command)\n\nuse_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']\nuse_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS']\n\nuse_react_native!(\n  :path => config[:reactNativePath],\n  :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',\n  # An absolute path to your application root.\n  :app_path => \"#{Pod::Config.instance.installation_root}/..\",\n  :privacy_file_aggregation_enabled => podfile_properties['apple.privacyManifestAggregationEnabled'] != 'false',\n)\n```\n\nThis block executes at the end of the Podfile in a block like:\n\n```rb\ntarget \"target_dir_name\" do\n   target_file\nend\n```\n\nThe name of the target must match the name of the target directory.\n\n## Examples\n\n### `widget`\n\n> I wrote a blog about this one and used it in production. Learn more: [Expo x Apple Widgets](https://evanbacon.dev/blog/apple-home-screen-widgets).\n\n```js\n/** @type {import('@bacons/apple-targets/app.plugin').Config} */\nmodule.exports = {\n  type: \"widget\",\n  icon: \"../../icons/widget.png\",\n  colors: {\n    // This color is referenced in the Info.plist\n    $widgetBackground: \"#DB739C\",\n\n    $accent: \"#F09458\",\n\n    // Optional: Add colors that can be used in SwiftUI.\n    gradient1: {\n      light: \"#E4975D\",\n      dark: \"#3E72A0\",\n    },\n  },\n  // Optional: Add images that can be used in SwiftUI.\n  images: {\n    valleys: \"../../valleys.png\",\n  },\n  // Optional: Add entitlements to the target, this one can be used to share data between the widget and the app.\n  entitlements: {\n    \"com.apple.security.application-groups\": [\"group.bacon.data\"],\n  },\n};\n```\n\n### `action`\n\nThese show up in the share sheet. The icon should be transparent as it will be masked by the system.\n\n```js\n/** @type {import('@bacons/apple-targets/app.plugin').Config} */\nmodule.exports = {\n  type: \"action\",\n  name: \"Inspect Element\",\n  icon: \"./assets/icon.png\",\n  colors: {\n    TouchBarBezel: \"#DB739C\",\n  },\n};\n```\n\nAdd a JavaScript file to `assets/index.js`:\n\n```js\nclass Action {\n  /**\n   * `extensionName: \"com.bacon.2095.axun\"`\n   * @param {*} arguments: {completionFunction: () => unknown; extensionName: string; }\n   */\n  run({ extensionName, completionFunction }) {\n    // Here, you can run code that modifies the document and/or prepares\n    // things to pass to your action's native code.\n\n    // We will not modify anything, but will pass the body's background\n    // style to the native code.\n    completionFunction({\n      /* */\n    });\n  }\n\n  finalize() {\n    // Runs after the native action code has completed.\n  }\n}\n\nwindow.ExtensionPreprocessingJS = new Action();\n```\n\nEnsure `NSExtensionJavaScriptPreprocessingFile: \"index\"` in the Info.plist.\n\n### `spotlight`\n\nPopulate the Spotlight search results with your app's content.\n\n```js\n/** @type {import('@bacons/apple-targets/app.plugin').Config} */\nmodule.exports = {\n  type: \"spotlight\",\n};\n```\n\n### Supported types\n\nIdeally, this would be generated automatically based on a fully qualified Xcode project, but for now it's a manual process. The currently supported types are based on static analysis of the most commonly used targets in the iOS App Store. I haven't tested all of these and they may not work.\n\n| Type                    | Description                        |\n| ----------------------- | ---------------------------------- |\n| action                  | Share Action                       |\n| app-intent              | App Intent Extension               |\n| widget                  | Widget / Live Activity             |\n| watch                   | Watch App (with companion iOS App) |\n| clip                    | App Clip                           |\n| safari                  | Safari Extension                   |\n| share                   | Share Extension                    |\n| notification-content    | Notification Content Extension     |\n| notification-service    | Notification Service Extension     |\n| intent                  | Siri Intent Extension              |\n| intent-ui               | Siri Intent UI Extension           |\n| spotlight               | Spotlight Index Extension          |\n| bg-download             | Background Download Extension      |\n| quicklook-thumbnail     | Quick Look Thumbnail Extension     |\n| location-push           | Location Push Service Extension    |\n| credentials-provider    | Credentials Provider Extension     |\n| account-auth            | Account Authentication Extension   |\n| device-activity-monitor | Device Activity Monitor Extension  |\n\n<!-- | imessage             | iMessage Extension               | -->\n\n## Code Signing\n\nThe codesigning is theoretically handled entirely by [EAS Build](https://docs.expo.dev/build/introduction/). This plugin will add the requisite entitlements for target signing to work. I've only tested this end-to-end with my Pillar Valley Widget.\n\nYou can also manually sign all sub-targets if you want, I'll light a candle for you.\n\n> I haven't gotten App Clip codesigning to be fully automated yet. PRs welcome.\n\n## Building Widgets\n\nI've written a blog post about building widgets with this plugin: [Expo x Apple Widgets](https://evanbacon.dev/blog/apple-home-screen-widgets).\n\nIf you experience issues building widgets, it might be because React Native is shipped uncompiled which makes the build complexity much higher. This often leads to issues with the Swift compiler and SwiftUI previews.\n\nSome workarounds:\n\n- Prebuild without React Native: `npx expo prebuild --template node_modules/@bacons/apple-targets/prebuild-blank.tgz --clean`\n- If the widget doesn't show on the home screen when building the app, use iOS 18. You can long press the app icon and select the widget display options to transform the app icon into the widget.\n\n## Sharing data between targets\n\nTo share values between the app and the target, you must use App Groups and NSUserDefaults. I've added a native module to make the React Native API a bit easier.\n\n### Configuring App Groups\n\nStart by defining an App Group, a good default is `group.<bundle identifier>`. App Groups can be used across apps so you may want something more generic or less generic if you plan on having multiple extensions.\n\nFirst, define your main App Group entitlement in your `app.json`:\n\n```json\n{\n  \"expo\": {\n    \"ios\": {\n      \"entitlements\": {\n        \"com.apple.security.application-groups\": [\"group.bacon.data\"]\n      }\n    },\n    \"plugins\": [\"@bacons/apple-targets\"]\n  }\n}\n```\n\nSecond, define the same App Group in your target's `expo-target.config.js`:\n\n```js\n/** @type {import('@bacons/apple-targets/app.plugin').ConfigFunction} */\nmodule.exports = (config) => ({\n  type: \"widget\",\n  entitlements: {\n    // Use the same app groups:\n    \"com.apple.security.application-groups\":\n      config.ios.entitlements[\"com.apple.security.application-groups\"],\n  },\n});\n```\n\nNow you can prebuild to generate the entitlements. You may need to create an EAS Build or open Xcode to sync the entitlements.\n\n### Setting shared data\n\nTo define shared data, we'll use a native module (`ExtensionStorage`) that interacts with `NSUserDefaults`.\n\nSomewhere in your Expo app, you can set a value:\n\n```js\nimport { ExtensionStorage } from \"@bacons/apple-targets\";\n\n// Create a storage object with the App Group.\nconst storage = new ExtensionStorage(\n  // Your app group identifier. Should match the values in the app.json and expo-target.config.json.\n  \"group.bacon.data\"\n);\n\n// Then you can set data:\nstorage.set(\"myKey\", \"myValue\");\n\n// Finally, you can reload the widget:\nExtensionStorage.reloadWidget();\n```\n\n`ExtensionStorage` has the following API:\n\n- `set(key: string, value: string | number | Record<string, string | number> | Array<Record<string, string | number>> | undefined): void` - Sets a value in the shared storage for a given key. Setting `undefined` will remove the key.\n- `ExtensionStorage.reloadWidget(name?: string): void` - A static method for reloading the widget. Behind the scenes, this calls `WidgetCenter.shared.reloadAllTimelines()`. If given a name, it will reload a specific widget using `WidgetCenter.shared.reloadTimelines(ofKind: timeline)`.\n\n### Accessing shared data\n\nAssuming this is done using Swift code, you'll access data using `NSUserDefaults` directly. Here's an example of how you might access the data in a widget:\n\n```swift\nlet defaults = UserDefaults(suiteName:\n  // Use the App Group from earlier.\n  \"group.bacon.data\"\n)\n// Access the value you set:\nlet index = defaults?.string(forKey: \"myKey\")\n```\n\n## Xcode parsing\n\nThis plugin makes use of my proprietary Xcode parsing library, [`@bacons/xcode`](https://github.com/evanbacon/xcode). It's mostly typed, very untested, and possibly full of bugs––however, it's still 10x nicer than the alternative.\n","readmeFilename":"README.md"}