diff --git a/__e2e__/install.test.ts b/__e2e__/install.test.ts deleted file mode 100644 index d46ac7559..000000000 --- a/__e2e__/install.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -import path from 'path'; -import {run, getTempDirectory, cleanup, writeFiles} from '../jest/helpers'; - -const DIR = getTempDirectory('command-install-test'); -const pkg = 'react-native-config'; - -beforeEach(() => { - cleanup(DIR); - writeFiles(DIR, { - 'node_modules/react-native/package.json': '{}', - 'package.json': '{}', - }); -}); -afterEach(() => cleanup(DIR)); - -test.each(['yarn', 'npm'])('install module with %s', pm => { - if (pm === 'yarn') { - writeFiles(DIR, {'yarn.lock': ''}); - } - const {stdout, code} = run(DIR, ['install', pkg]); - - expect(stdout).toContain(`Installing "${pkg}"`); - expect(stdout).toContain(`Linking "${pkg}"`); - // TODO – this behavior is a bug, linking should fail/warn without native deps - // to link. Not a high priority since we're changing how link works - expect(stdout).toContain(`Successfully installed and linked "${pkg}"`); - expect(require(path.join(DIR, 'package.json'))).toMatchObject({ - dependencies: { - [pkg]: expect.any(String), - }, - }); - expect(code).toBe(0); -}); diff --git a/__e2e__/uninstall.test.ts b/__e2e__/uninstall.test.ts deleted file mode 100644 index 748d46f5e..000000000 --- a/__e2e__/uninstall.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -import {run, getTempDirectory, cleanup, writeFiles} from '../jest/helpers'; - -const DIR = getTempDirectory('command-uninstall-test'); -const pkg = 'react-native-config'; - -beforeEach(() => { - cleanup(DIR); - writeFiles(DIR, { - 'node_modules/react-native/package.json': '{}', - 'node_modules/react-native-config/package.json': '{}', - 'package.json': `{ - "dependencies": { - "react-native-config": "*" - } - }`, - }); -}); -afterEach(() => cleanup(DIR)); - -test('uninstall fails when package is not defined', () => { - writeFiles(DIR, { - 'package.json': `{ - "dependencies": {} - }`, - }); - const {stderr, code} = run(DIR, ['uninstall'], {expectedFailure: true}); - - expect(stderr).toContain('missing required argument'); - expect(code).toBe(1); -}); - -test('uninstall fails when package is not installed', () => { - writeFiles(DIR, { - 'package.json': `{ - "dependencies": {} - }`, - }); - const {stderr, code} = run(DIR, ['uninstall', pkg], {expectedFailure: true}); - - expect(stderr).toContain(`Failed to unlink "${pkg}".`); - expect(code).toBe(1); -}); - -test.each(['yarn', 'npm'])('uninstall module with %s', pm => { - if (pm === 'yarn') { - writeFiles(DIR, {'yarn.lock': ''}); - } - const {stdout, code} = run(DIR, ['uninstall', pkg]); - - expect(stdout).toContain(`Unlinking "${pkg}"`); - expect(stdout).toContain(`Uninstalling "${pkg}"`); - expect(stdout).toContain(`Successfully uninstalled and unlinked "${pkg}"`); - expect(code).toBe(0); -}); diff --git a/docs/configuration.md b/docs/configuration.md index 24aeb533e..ab24afbed 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -2,8 +2,6 @@ React Native CLI has a configuration mechanism that allows changing its behavior and providing additional features. -> Note: Configuring CLI used to be possible via `rn-cli.config.js` (that has been renamed to `metro.config.js`) and never documented `rnpm` entry on the `package.json`. We have provided migration guides where possible. - React Native CLI can be configured by creating a `react-native.config.js` at the root of the project. Depending on the type of a package, the set of valid properties is different. Check the documentation for @@ -17,104 +15,4 @@ to learn more about different types of configuration and features available. ## Migration guide -`"rnpm"` is deprecated and support for it will be removed in next major version of the CLI. - -> **Important**: Proceed further only if your project uses `"rnpm"` in `package.json`. - -There are different kinds of React Native projects, including apps, libraries and platforms. For each we prepared a brief "before & after" of the configuration shape with legacy `"rnpm"` and current `react-native.config.js`. Please mind that all configuration entries are optional. - -### Apps - -`package.json` entry: - -```json -{ - "rnpm": { - "ios": {}, - "android": {}, - "assets": ["./path-to-assets"], - "plugin": "./path-to-commands.js" - } -} -``` - -becomes `react-native.config.js` - -```js -module.exports = { - project: { - ios: {}, - android: {}, // grouped into "project" - }, - assets: ['./path-to-assets'], // stays the same - commands: require('./path-to-commands.js'), // formerly "plugin", returns an array of commands -}; -``` - -### Libraries - -`package.json` entry: - -```json -{ - "rnpm": { - "ios": {}, - "android": {}, - "assets": ["./path-to-assets"], - "hooks": { - "prelink": "./path-to-a-prelink-hook" - } - } -} -``` - -becomes `react-native.config.js`: - -```js -module.exports = { - // config for a library is scoped under "dependency" key - dependency: { - platforms: { - ios: {}, - android: {}, // projects are grouped into "platforms" - }, - assets: ['./path-to-assets'], // stays the same - // hooks are considered anti-pattern, please avoid them - hooks: { - prelink: './path-to-a-prelink-hook', - }, - }, -}; -``` - -You'll find more details in [dependencies](./dependencies.md) docs. - -### Out-of-tree platforms - -`package.json` entry: - -```json -{ - "rnpm": { - "haste": { - "platforms": ["windows"], - "providesModuleNodeModules": ["react-native-windows"] - }, - "platform": "./local-cli/platform.js" - } -} -``` - -becomes `react-native.config.js` - -```js -module.exports = { - platforms: { - // grouped under "platforms" entry - windows: require('./local-cli/platform.js').windows, - }, - // "haste" is no longer needed -}; -``` - -You'll find more details in [platforms](./platforms.md) docs. +Support for `rnpm` has been removed with the 4.x release of the CLI. If your project or library still uses `rnpm` for altering the behaviour of the CLI, please check [documentation of the older CLI release](https://github.com/react-native-community/cli/blob/3.x/docs/configuration.md) for steps on how to migrate. diff --git a/docs/dependencies.md b/docs/dependencies.md index 4bd2d35f6..8b84d8c8b 100644 --- a/docs/dependencies.md +++ b/docs/dependencies.md @@ -6,7 +6,7 @@ For example, `lodash` is a dependency that doesn't have any native code to link. By default, CLI analyses the folder structure inside the dependency and looks for assets and native files to link. This simple heuristic works in most of the cases. -At the same time, a dependency can explicitly set its configuration in case CLI cannot infer it properly. A dependency can also define additional settings, such as a script to run after linking, in order to support some advanced use-cases. +At the same time, a dependency can explicitly set its configuration in case CLI cannot infer it properly. ## How does it work? @@ -17,34 +17,29 @@ module.exports = { dependency: { platforms: { ios: { - project: './Custom.xcodeproj' - } - } - assets: ['./assets'] - } + project: './Custom.xcodeproj', + }, + }, + }, }; ``` -> The above configuration informs CLI of the additional assets to link and about a custom project location. +> The above configuration informs CLI about a custom project location. ## Dependency interface The following type describes the configuration of a dependency that can be set under `dependency` key inside `react-native.config.js`. ```ts -type DependencyConfigT = { +interface Dependency = { platforms: { + ios?: IOSDependencyParams | null; + android?: AndroidDependencyParams | null; [key: string]: any; }; - assets: string[]; - hooks: { - [key: string]: string; - }; }; ``` -> Note: This interface is subject to breaking changes. We may consider renaming some keys to simplify the configuration further. If you are going to use it, be prepared to update before we ship a stable 0.60.0 release. - ### platforms A map of specific settings that can be set per platform. The exact shape is always defined by the package that provides given platform. @@ -54,18 +49,24 @@ In most cases, as a library author, you should not need to define any of these. The following settings are available on iOS and Android: ```ts -type DependencyParamsIOST = { +interface IOSDependencyParams { project?: string; podspecPath?: string; - sharedLibraries?: string[]; -}; + scriptPhases?: Array<{ + name: string; + path: string; + execution_position: string; + }>; +} -type DependencyParamsAndroidT = { +interface AndroidDependencyParams { + packageName?: string; sourceDir?: string; manifestPath?: string; + packageImportPath?: string; packageInstance?: string; -}; +} ``` #### platforms.ios.project @@ -76,10 +77,6 @@ Custom path to `.xcodeproj`. Custom path to `.podspec` file to use when auto-linking. Example: `node_modules/react-native-module/ios/module.podspec`. -#### platforms.ios.sharedLibraries - -An array of shared iOS libraries to link with the dependency. E.g. `libc++`. This is mostly a requirement of the native code that a dependency ships with. - #### platforms.ios.scriptPhases An array of iOS script phases to add to the project. Specifying a `path` property with a path relative to the dependency root will load the contents of the file at the path as the script contents. @@ -91,7 +88,7 @@ An array of iOS script phases to add to the project. Specifying a `path` propert module.exports = { dependency: { platforms: { - ios: { + ios: { scriptPhases: [ { name: '[MY DEPENDENCY] My Script', @@ -111,6 +108,10 @@ See [`script_phase` options](https://www.rubydoc.info/gems/cocoapods-core/Pod/Po A relative path to a folder with source files. E.g. `custom-android`, or `custom-android/app`. By default, CLI searches for `android` and `android/app` as source dirs. +#### platforms.android.packageName + +Custom package name, unless the default one present under `AndroidManifest.xml` is wrong. + #### platforms.android.manifestPath Path to a custom `AndroidManifest.xml` @@ -125,62 +126,6 @@ Custom syntax to instantiate a package. By default, it's a `new AwesomePackage() For settings applicable on other platforms, please consult their respective documentation. -### assets - -An array of assets folders to glob for files to link. - -### hooks - -A map where key is the name of a hook and value is the path to a file to execute. - -For example, `link` command supports `prelink` and `postlink` hooks to run before and after linking is done. - -These are the only ones supported by CLI at the moment. Depending on the packages used in your project, you may find other hooks supported to. - -> Note: This has nothing to do with React Hooks. - -## Migrating from `rnpm` configuration - -The changes are mostly cosmetic so the migration should be pretty straight-forward. - -> Note: We read `rnpm` configuration to remain backwards-compatible. Dependency maintainers should update their configuration in the nearest future. - -### Changing the configuration - -Properties were renamed. Look at the following example for the differences. - -```json -{ - "rnpm": { - "ios": {}, - "android": {}, - "assets": ["./path-to-assets"], - "hooks": { - "prelink": "./path-to-a-prelink-hook" - } - } -} -``` - -to a `react-native.config.js` - -```js -module.exports = { - dependency: { - platforms: { - ios: {}, - android: {}, - }, - assets: ['./path-to-assets'], - hooks: { - prelink: './path-to-a-prelink-hook', - }, - }, -}; -``` - -### Asking for params while linking has been removed - -If your library needs it, do not upgrade over to the new config format. +## Migrating from `rnpm` -If you want to ask users for additional settings, consider setting a custom `postlink` hook, just like [`react-native-code-push`](https://github.com/Microsoft/react-native-code-push/blob/master/package.json#L53). +Support for `rnpm` has been removed with the 4.x release of the CLI. If your project or library still uses `rnpm` for altering the behaviour of the CLI, please check [documentation of the older CLI release](https://github.com/react-native-community/cli/blob/3.x/docs/dependencies.md#migrating-from-rnpm-configuration) for steps on how to migrate. diff --git a/docs/platforms.md b/docs/platforms.md index 8f85fbbd9..39c7387dd 100644 --- a/docs/platforms.md +++ b/docs/platforms.md @@ -17,12 +17,10 @@ const android = require('@react-native-community/cli-platform-android'); module.exports = { platforms: { ios: { - linkConfig: ios.linkConfig, projectConfig: ios.projectConfig, dependencyConfig: ios.dependencyConfig, }, android: { - linkConfig: android.linkConfig, projectConfig: android.projectConfig, dependencyConfig: android.dependencyConfig, }, @@ -39,31 +37,28 @@ At the end, a map of available platforms is passed to the bundler (Metro) to mak ## Platform interface ```ts -type PlatformConfig = { - projectConfig: (string, ProjectParams) => ?ProjectConfig, - dependencyConfig: (string, ProjectParams) => ?DependencyConfig, - linkConfig: () => { - isInstalled: (ProjectConfig, string, DependencyConfig) => boolean, - register: (string, DependencyConfig, Object, ProjectConfig) => void, - unregister: ( - string, - DependencyConfig, - ProjectConfig, - Array, - ) => void, - copyAssets: (string[], ProjectConfig) => void, - unlinkAssets: (string[], ProjectConfig) => void, - }, -}; +interface PlatformConfig< + ProjectConfig, + ProjectParams, + DependencyConfig, + DependencyParams +> { + projectConfig: ( + projectRoot: string, + projectParams: ProjectParams | void, + ) => ProjectConfig | null; + dependencyConfig: ( + dependency: string, + params: DependencyParams, + ) => DependencyConfig | null; +} ``` ### projectConfig -Returns a project configuration for a given platform or `null`, when no project found. This is later used inside `linkConfig` to perform linking and unlinking. +Returns a project configuration for a given platform or `null`, when no project found. -First argument is a root folder where the project is located. - -Second argument is everything that users defined under: +First argument is a root folder where the project is located. Second argument is everything that users defined under: ```js module.exports = { @@ -78,35 +73,22 @@ module.exports = { On Android and iOS, this function returns: ```ts -type ProjectConfigIOST = { +interface IOSProjectConfig { sourceDir: string; - folder: string; - pbxprojPath: string; - podfile: null; - podspecPath: null; - projectPath: string; - projectName: string; - libraryFolder: string; - sharedLibraries: Array; - plist: Array; -}; + scriptPhases: Array<{ + name: string; + path: string; + execution_position: string; + }>; + podfile: string | null; +} -type ProjectConfigAndroidT = { +interface AndroidProjectConfig { sourceDir: string; - isFlat: boolean; - folder: string; - stringsPath: string; - manifestPath: string; - buildGradlePath: string; - settingsGradlePath: string; - assetsPath: string; - mainFilePath: string; packageName: string; -}; +} ``` -We suggest performing all side-effects inside this function (such as resolving paths to native files) and making `linkConfig` functions pure, operating on provided data. - ### dependencyConfig Similar to [`projectConfig`](#projectconfig) above, but for a dependency of a project. @@ -126,134 +108,25 @@ module.exports = { On Android and iOS, this function returns: ```ts -type DependencyConfigIOST = ProjectConfigIOST; - -type DependencyConfigAndroidT = { +interface IOSDependencyConfig { sourceDir: string; - folder: string; - packageImportPath: string; - packageInstance: string; -}; -``` - -### linkConfig - -Returns an object with utilities that are run by the CLI while linking. - -> Note: The following is deprecated and will stop working in the future. Consider providing a [`autolinking`](./autolinking.md) support. - -#### linkConfig.isInstalled - -Returns true if a library is already linked to a given project. False otherwise. - -#### linkConfig.register - -Performs platform-specific steps in order to link a library. - -#### linkConfig.unregister - -Performs platform-specific steps in order to unlink a library. - -#### linkConfig.copyAssets - -Performs platform-specific steps in order to copy assets of a library to a project. - -#### linkConfig.unlinkAssets - -Performs platform-specific steps in order to unlink assets of a library from a project. - -## Migrating from `rnpm` configuration - -The changes are mostly cosmetic so the migration should be pretty straight-forward. - -### Changing the configuration for a platform - -A `platform` property would need to be renamed to `platforms`. `haste` is no longer supported - we are able to infer that automatically. - -For example: - -```json -{ - "rnpm": { - "haste": { - "platforms": ["windows"], - "providesModuleNodeModules": ["react-native-windows"] - }, - "platform": "./local-cli/platform.js" - } + scriptPhases: Array<{ + name: string; + path: string; + execution_position: string; + }>; + podspecPath: string | null; } -``` - -to `react-native.config.js` -```js -module.exports = { - platforms: { - windows: require('./local-cli/platform.js').windows, - }, -}; -``` - -> The above configuration is taken from `react-native-windows` and adds support for `windows` platform. - -### Changing platform configuration for a [`dependency`](./dependencies.md) - -Platform keys are now under `dependency.platforms`. - -For example: - -```json -{ - "rnpm": { - "ios": { - "project": "PathToCustomProject.xcodeproj" - } - } -} -``` - -to `react-native.config.js` - -```js -module.exports = { - dependency: { - platforms: { - ios: { - project: 'PathToCustomProject.xcodeproj', - }, - }, - }, -}; -``` - -> The above is a configuration of a dependency that explicitly sets a path to `.xcodeproj`. - -### Changing platform configuration for a [`project`](./projects.md) - -Platform keys are now under `project.platforms`. - -For example: +interface AndroidDependencyConfig { + sourceDir: string; + packageName: string; -```json -{ - "rnpm": { - "ios": { - "project": "PathToCustomProject.xcodeproj" - } - } + packageImportPath: string; + packageInstance: string; } ``` -to `react-native.config.js` - -```js -module.exports = { - project: { - ios: { - project: 'PathToCustomProject.xcodeproj', - }, - }, -}; -``` +## Migrating from `rnpm` -> The above is a configuration of a project that explicitly sets its main `.xcodeproj` project. +Support for `rnpm` has been removed with the 4.x release of the CLI. If your project or library still uses `rnpm` for altering the behaviour of the CLI, please check [documentation of the older CLI release](https://github.com/react-native-community/cli/blob/3.x/docs/platforms.md#migrating-from-rnpm-configuration) for steps on how to migrate. diff --git a/docs/plugins.md b/docs/plugins.md index 82d988b59..c57c6349b 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -107,48 +107,6 @@ String that describes this particular usage. A command with arguments and options (if applicable) that can be run in order to achieve the desired goal. -## Migrating from `rnpm` configuration +## Migrating from `rnpm` -The changes are mostly cosmetic so the migration should be pretty straight-forward. - -### Changing the configuration - -A `plugin` property should be renamed to `commands`. - -For example, the following `rnpm` configuration inside `package.json`: - -```json -{ - "rnpm": { - "plugin": "./path-to-commands.js" - } -} -``` - -should be moved to a `react-native.config.js`: - -```js -module.exports = { - commands: require('./path-to-commands.js'), -}; -``` - -provided that `./path-to-commands.js` returns an array of commands. - -### Renaming command options - -If your command accepts options, rename `command` property of each of them to `name`. - -```diff - module.exports = { - name: 'foo', - func: () => console.log('My work'), - options: [ - { -- command: '--reset-cache, --resetCache', -+ name: '--reset-cache, --resetCache', - description: 'Removes cached files', - } - ] - } -``` +Support for `rnpm` has been removed with the 4.x release of the CLI. If your project or library still uses `rnpm` for altering the behaviour of the CLI, please check [documentation of the older CLI release](https://github.com/react-native-community/cli/blob/3.x/docs/plugins.md#migrating-from-rnpm-configuration) for steps on how to migrate. diff --git a/docs/projects.md b/docs/projects.md index 2a424f9ba..92fdb6055 100644 --- a/docs/projects.md +++ b/docs/projects.md @@ -6,50 +6,46 @@ Projects can provide additional properties to alter the CLI behavior, such as cu ## How does it work? -A project can define a `react-native.config.js` at the root with custom configuration to be picked up by the CLI. - -For example, below configuration informs CLI of the additional assets to link and about a custom project location. +A project can define the following `react-native.config.js` at the root: ```js module.exports = { project: { - ios: { - project: './CustomProject.xcodeproj', + platforms: { + ios: { + project: './Custom.xcodeproj', + }, }, }, - assets: ['./assets'], }; ``` -You can check all available options below. +> The above configuration informs CLI about a custom project location. ## Project interface ```ts -type ProjectConfigT = { - reactNativePath: ?string, - project: { - android?: ProjectParamsAndroidT, - ios?: ProjectParamsIOST, - [key: string]: any, - }, - assets: string[], - platforms: PlatformT, - dependencies: { - [key: string]: { - name: string, - root: string, - platforms: { - [key: string]: PlatformSettingsT - }, - assets: string[], - hooks: { - [key: string]: string - } - }, - }, - commands: CommandT[] -}; +interface Config = { + reactNativePath: string; + project: ProjectConfig; + dependencies: {[key: string]: Dependency}; + platforms: { + android: PlatformConfig< + AndroidProjectConfig, + AndroidProjectParams, + AndroidDependencyConfig, + AndroidDependencyParams + >; + ios: PlatformConfig< + IOSProjectConfig, + IOSProjectParams, + IOSDependencyConfig, + IOSDependencyParams + >; + [name: string]: PlatformConfig; + }; + commands: Command[]; +} ``` ### reactNativePath @@ -66,31 +62,18 @@ In most cases, as a React Native developer, you should not need to define any of The following settings are available on iOS and Android: ```ts -type ProjectParamsAndroidT = { +interface AndroidProjectParams { sourceDir?: string; manifestPath?: string; packageName?: string; - packageFolder?: string; - mainFilePath?: string; - stringsPath?: string; - settingsGradlePath?: string; - assetsPath?: string; - buildGradlePath?: string; -}; +} -type ProjectParamsIOST = { +interface IOSProjectParams { project?: string; - podspecPath?: string; - sharedLibraries?: string[]; - libraryFolder?: string; - plist: any[]; -}; + scriptPhases?: Array; +} ``` -### assets - -An array of folders to check for project assets - ### platforms A object with platforms defined inside a project. You can check the format and options available [`here`](platforms.md#platform-interface) @@ -135,32 +118,6 @@ The object provided here is deep merged with the dependency config. Check [`proj > Note: This is an advanced feature and you should not need to use it mos of the time. -## Migrating from `rnpm` configuration - -The changes are mostly cosmetic so the migration should be pretty straight-forward. - -### Changing the configuration - -Properties `ios` and `android` were moved under `project`. Take a look at the following example for the differences. - -```json -{ - "rnpm": { - "ios": {}, - "android": {}, - "assets": ["./path-to-assets"] - } -} -``` +## Migrating from `rnpm` -to a `react-native.config.js` - -```js -module.exports = { - project: { - ios: {}, - android: {}, - }, - assets: ['./path-to-assets'], -}; -``` +Support for `rnpm` has been removed with the 4.x release of the CLI. If your project or library still uses `rnpm` for altering the behaviour of the CLI, please check [documentation of the older CLI release](https://github.com/react-native-community/cli/blob/3.x/docs/projects.md#migrating-from-rnpm-configuration) for steps on how to migrate. diff --git a/packages/cli-types/src/android.ts b/packages/cli-types/src/android.ts index 54fd885b7..61c8856c8 100644 --- a/packages/cli-types/src/android.ts +++ b/packages/cli-types/src/android.ts @@ -1,13 +1,5 @@ export interface AndroidProjectConfig { sourceDir: string; - isFlat: boolean; - folder: string; - stringsPath: string; - manifestPath: string; - buildGradlePath: string; - settingsGradlePath: string; - assetsPath: string; - mainFilePath: string; packageName: string; } @@ -15,17 +7,12 @@ export interface AndroidProjectParams { sourceDir?: string; manifestPath?: string; packageName?: string; - packageFolder?: string; - mainFilePath?: string; - stringsPath?: string; - settingsGradlePath?: string; - assetsPath?: string; - buildGradlePath?: string; } export interface AndroidDependencyConfig { sourceDir: string; - folder: string; + packageName: string; + packageImportPath: string; packageInstance: string; } @@ -34,6 +21,7 @@ export interface AndroidDependencyParams { packageName?: string; sourceDir?: string; manifestPath?: string; + packageImportPath?: string; packageInstance?: string; } diff --git a/packages/cli-types/src/index.ts b/packages/cli-types/src/index.ts index e2dc9d394..f29efd725 100644 --- a/packages/cli-types/src/index.ts +++ b/packages/cli-types/src/index.ts @@ -66,32 +66,11 @@ interface PlatformConfig< projectConfig: ( projectRoot: string, projectParams: ProjectParams | void, - ) => ProjectConfig | void; + ) => ProjectConfig | null; dependencyConfig: ( dependency: string, params: DependencyParams, - ) => DependencyConfig | void; - linkConfig: () => { - isInstalled: ( - projectConfig: ProjectConfig, - packageName: string, - dependencyConfig: DependencyConfig, - ) => boolean; - register: ( - name: string, - dependencyConfig: DependencyConfig, - params: Object, - projectConfig: ProjectConfig, - ) => void; - unregister: ( - name: string, - dependencyConfig: DependencyConfig, - projectConfig: ProjectConfig, - otherDependencies: Array, - ) => void; - copyAssets: (assets: string[], projectConfig: ProjectConfig) => void; - unlinkAssets: (assets: string[], projectConfig: ProjectConfig) => void; - }; + ) => DependencyConfig | null; } export interface Dependency { @@ -102,14 +81,6 @@ export interface Dependency { ios?: IOSDependencyConfig | null; [key: string]: any; }; - assets: string[]; - hooks: { - prelink?: string; - postlink?: string; - preunlink?: string; - postunlink?: string; - }; - params: InquirerPrompt[]; } export type ProjectConfig = { @@ -132,7 +103,6 @@ export type Config = { root: string; reactNativePath: string; project: ProjectConfig; - assets: string[]; dependencies: {[key: string]: Dependency}; platforms: { android: PlatformConfig< @@ -178,11 +148,6 @@ export type UserDependencyConfig = { commands: Command[]; // An array of extra platforms to load platforms: Config['platforms']; - // Haste config defined by legacy `rnpm` - haste?: { - platforms: string[]; - providesModuleNodeModules: string[]; - }; }; export { diff --git a/packages/cli-types/src/ios.ts b/packages/cli-types/src/ios.ts index 7129dffd3..e5564016f 100644 --- a/packages/cli-types/src/ios.ts +++ b/packages/cli-types/src/ios.ts @@ -4,30 +4,36 @@ * * See UserDependencyConfigT and UserConfigT for details */ +type ScriptPhase = { + name: string; + path: string; + execution_position: string; +}; + export interface IOSProjectParams { project?: string; - podspecPath?: string; - sharedLibraries?: string[]; - libraryFolder?: string; - plist: Array; - scriptPhases?: Array; + scriptPhases?: Array; } -export interface IOSDependencyParams extends IOSProjectParams {} +export interface IOSDependencyParams { + project?: string; + podspecPath?: string; + scriptPhases?: Array; +} -// The following types are used in untyped-parts of the codebase, so I am leaving them -// until we actually need them. export interface IOSProjectConfig { sourceDir: string; - folder: string; - pbxprojPath: string; - podfile: string; - podspecPath: string; - projectPath: string; - projectName: string; - libraryFolder: string; - sharedLibraries: Array; - plist: Array; + scriptPhases: Array; + + podfile: string | null; } -export interface IOSDependencyConfig extends IOSProjectConfig {} +export interface IOSDependencyConfig { + sourceDir: string; + scriptPhases: Array<{ + name: string; + path: string; + execution_position: string; + }>; + podspecPath: string | null; +} diff --git a/packages/cli/src/commands/config/config.ts b/packages/cli/src/commands/config/config.ts index e841bcda0..990f479f9 100644 --- a/packages/cli/src/commands/config/config.ts +++ b/packages/cli/src/commands/config/config.ts @@ -1,19 +1,16 @@ import {Config, Dependency} from '@react-native-community/cli-types'; -function isValidRNDependency(config: Dependency) { +function targetsAnyPlatform(config: Dependency) { return ( Object.keys(config.platforms).filter(key => Boolean(config.platforms[key])) - .length !== 0 || - (config.hooks && Object.keys(config.hooks).length !== 0) || - (config.assets && config.assets.length !== 0) || - (config.params && config.params.length !== 0) + .length > 0 ); } function filterConfig(config: Config) { const filtered = {...config}; Object.keys(filtered.dependencies).forEach(item => { - if (!isValidRNDependency(filtered.dependencies[item])) { + if (!targetsAnyPlatform(filtered.dependencies[item])) { delete filtered.dependencies[item]; } }); diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 89e9feac2..dd790b21d 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -4,29 +4,45 @@ import {Command, DetachedCommand} from '@react-native-community/cli-types'; import server from './server/server'; import bundle from './bundle/bundle'; import ramBundle from './bundle/ramBundle'; -import link from './link/link'; -import unlink from './link/unlink'; -import install from './install/install'; -import uninstall from './install/uninstall'; import upgrade from './upgrade/upgrade'; import info from './info/info'; import config from './config/config'; import init from './init'; // @ts-ignore - JS file import doctor from './doctor'; +import {CLIError} from '@react-native-community/cli-tools'; + +const makeDeprecatedCommand = (name: string) => { + return { + name, + func: () => { + throw new CLIError(` + This command has been removed in favor of "autolinking" with this React Native release. + + Check https://github.com/react-native-community/cli/blob/master/docs/autolinking.md + for more details. + + If you still need to use "react-native ${name}" command, consider installing + React Native CLI 3.x. + `); + }, + }; +}; export const projectCommands = [ server, bundle, ramBundle, - link, - unlink, - install, - uninstall, upgrade, info, config, doctor, + + // Deprecated commands + makeDeprecatedCommand('link'), + makeDeprecatedCommand('unlink'), + makeDeprecatedCommand('install'), + makeDeprecatedCommand('uninstall'), ] as Command[]; export const detachedCommands = [init] as DetachedCommand[]; diff --git a/packages/cli/src/commands/install/install.ts b/packages/cli/src/commands/install/install.ts deleted file mode 100644 index a630247f7..000000000 --- a/packages/cli/src/commands/install/install.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ -import {logger} from '@react-native-community/cli-tools'; -import * as PackageManager from '../../tools/packageManager'; -import link from '../link/link'; -import loadConfig from '../../tools/config'; -import {Config} from '@react-native-community/cli-types'; - -async function install(args: Array, ctx: Config): Promise { - const name = args[0]; - - logger.info(`Installing "${name}"...`); - await PackageManager.install([name], {root: ctx.root}); - - // Reload configuration to see newly installed dependency - const newConfig = loadConfig(); - - logger.info(`Linking "${name}"...`); - await link.func([name], newConfig, {platforms: undefined}); - - logger.success(`Successfully installed and linked "${name}"`); -} - -export default { - func: install, - description: 'install and link native dependencies', - name: 'install ', -}; diff --git a/packages/cli/src/commands/install/uninstall.ts b/packages/cli/src/commands/install/uninstall.ts deleted file mode 100644 index f5c46bf1b..000000000 --- a/packages/cli/src/commands/install/uninstall.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ -import {Config} from '@react-native-community/cli-types'; -import {logger} from '@react-native-community/cli-tools'; -import * as PackageManager from '../../tools/packageManager'; -import unlink from '../link/unlink'; - -async function uninstall(args: Array, ctx: Config): Promise { - const name = args[0]; - - logger.info(`Unlinking "${name}"...`); - await unlink.func([name], ctx, {}); - - logger.info(`Uninstalling "${name}"...`); - await PackageManager.uninstall([name], {root: ctx.root}); - - logger.success(`Successfully uninstalled and unlinked "${name}"`); -} - -export default { - func: uninstall, - description: 'uninstall and unlink native dependencies', - name: 'uninstall ', -}; diff --git a/packages/cli/src/commands/link/__tests__/link.test.ts b/packages/cli/src/commands/link/__tests__/link.test.ts deleted file mode 100644 index bcb7021cc..000000000 --- a/packages/cli/src/commands/link/__tests__/link.test.ts +++ /dev/null @@ -1,257 +0,0 @@ -import {func as link} from '../link'; -import loadConfig from '../../../tools/config'; -import makeHook from '../makeHook'; -jest.mock('chalk', () => ({grey: str => str, bold: str => str})); -jest.mock('../../../tools/config'); -jest.mock('../makeHook', () => { - return jest.fn(() => { - return jest.fn(() => Promise.resolve()); - }); -}); - -const baseConfig = loadConfig(); - -const baseDependencyConfig = { - name: 'react-native-gradient', - assets: [], - hooks: {}, - params: [], - platforms: {ios: {}, android: {}}, -}; - -describe('link', () => { - beforeEach(() => { - jest.resetModules(); - }); - - it('should accept a name of a dependency to link', async () => { - const config = { - ...baseConfig, - dependencies: { - get ['react-native-gradient']() { - return baseDependencyConfig; - }, - }, - }; - - const spy = jest.spyOn(config.dependencies, 'react-native-gradient', 'get'); - - await link(['react-native-gradient'], config, {}); - - expect(spy).toHaveBeenCalled(); - }); - - it('should accept the name of a dependency with a scope / tag', async () => { - const config = { - ...baseConfig, - dependencies: { - get ['@scope/something']() { - return baseDependencyConfig; - }, - }, - }; - - const spy = jest.spyOn(config.dependencies, '@scope/something', 'get'); - - await link(['@scope/something@latest'], config, {}); - - expect(spy).toHaveBeenCalled(); - }); - - it('should register native module when android/ios projects are present', async () => { - const prelink = 'node prelink.js'; - const postlink = 'node postlink.js'; - const registerNativeModule = jest.fn(); - - const config = { - ...baseConfig, - project: { - ios: {}, - android: {}, - }, - platforms: { - ios: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - android: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - }, - dependencies: { - 'react-native-blur': { - ...baseDependencyConfig, - hooks: {prelink, postlink}, - }, - }, - }; - - await link(['react-native-blur'], config, {}); - expect(registerNativeModule.mock.calls).toHaveLength(2); - expect((makeHook as jest.Mock).mock.calls).toEqual([[prelink], [postlink]]); - }); - - it('should copy assets only from the specific dependency that we are linking', done => { - const dependencyAssets = ['Fonts/Font.ttf']; - const projectAssets = ['Fonts/FontC.ttf']; - - const copyAssets = jest.fn(); - const dependency = { - ...baseDependencyConfig, - assets: dependencyAssets, - }; - - const config = { - ...baseConfig, - project: { - ios: {}, - android: {}, - }, - platforms: { - ios: { - linkConfig: () => ({ - register: jest.fn(), - copyAssets, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - android: { - linkConfig: () => ({ - register: jest.fn(), - copyAssets, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - }, - dependencies: { - 'react-native-blur': dependency, - }, - assets: projectAssets, - }; - - link(['react-native-blur'], config, {}).then(() => { - expect(copyAssets.mock.calls).toHaveLength(2); - expect(copyAssets.mock.calls[0][0]).toEqual(dependencyAssets); - done(); - }); - }); - - it('should not register modules when they are already installed', done => { - const registerNativeModule = jest.fn(); - - const config = { - ...baseConfig, - project: { - ios: {}, - android: {}, - }, - platforms: { - ios: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(true), - }), - }, - android: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(true), - }), - }, - }, - dependencies: { - 'react-native-blur': baseDependencyConfig, - }, - }; - - link(['react-native-blur'], config, {}).then(() => { - expect(registerNativeModule.mock.calls).toHaveLength(0); - done(); - }); - }); - - it('should register native modules for additional platforms', done => { - const registerNativeModule = jest.fn(); - - const config = { - ...baseConfig, - project: { - ios: {}, - android: {}, - windows: {}, - }, - platforms: { - ios: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(true), - }), - }, - android: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(true), - }), - }, - windows: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - }, - dependencies: { - 'react-native-blur': { - ...baseDependencyConfig, - platforms: { - ...baseDependencyConfig.platforms, - windows: {}, - }, - }, - }, - }; - - link(['react-native-blur'], config, {}).then(() => { - expect(registerNativeModule.mock.calls).toHaveLength(1); - done(); - }); - }); - - it('should link only for specific platforms if --platforms is used', async () => { - const registerNativeModule = jest.fn(); - - const config = { - ...baseConfig, - project: { - ios: {}, - android: {}, - }, - platforms: { - ios: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - android: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - }, - dependencies: { - 'react-native-blur': baseDependencyConfig, - }, - }; - - await link(['react-native-blur'], config, {platforms: ['android']}); - - expect(registerNativeModule.mock.calls).toHaveLength(1); - }); -}); diff --git a/packages/cli/src/commands/link/__tests__/makeHook.test.ts b/packages/cli/src/commands/link/__tests__/makeHook.test.ts deleted file mode 100644 index 70982f359..000000000 --- a/packages/cli/src/commands/link/__tests__/makeHook.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import makeHook from '../makeHook'; - -afterAll(() => { - jest.restoreAllMocks(); -}); - -describe('makeHook', () => { - it('invokes the command', async () => { - const hook = makeHook('echo'); - const result = await hook(); - expect(result.cmd).toBe('echo'); - }); - - it('invokes the command with multiple arguments', async () => { - const hook = makeHook('node -p "1;"'); - const result = await hook(); - expect(result.cmd).toBe('node -p "1;"'); - }); -}); diff --git a/packages/cli/src/commands/link/getPlatformName.ts b/packages/cli/src/commands/link/getPlatformName.ts deleted file mode 100644 index f926cec61..000000000 --- a/packages/cli/src/commands/link/getPlatformName.ts +++ /dev/null @@ -1,8 +0,0 @@ -const names: {[key: string]: string} = { - ios: 'iOS', - android: 'Android', -}; - -export default function getPlatformName(name: string): string { - return names[name] || name; -} diff --git a/packages/cli/src/commands/link/link.ts b/packages/cli/src/commands/link/link.ts deleted file mode 100644 index a23d04340..000000000 --- a/packages/cli/src/commands/link/link.ts +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import chalk from 'chalk'; -import {pick} from 'lodash'; -import {logger, CLIError} from '@react-native-community/cli-tools'; -import {Config} from '@react-native-community/cli-types'; -import getPlatformName from './getPlatformName'; -import linkDependency from './linkDependency'; -import linkAssets from './linkAssets'; -import linkAll from './linkAll'; -import makeHook from './makeHook'; - -type FlagsType = { - platforms?: Array; - all?: boolean; -}; - -/** - * Updates project and links all dependencies to it. - * - * @param args If optional argument [packageName] is provided, - * only that package is processed. - */ -async function link( - [rawPackageName]: Array, - ctx: Config, - opts: FlagsType, -) { - let platforms = ctx.platforms; - let project = ctx.project; - - if (opts.platforms) { - // @ts-ignore - platforms = pick(platforms, opts.platforms); - logger.debug('Skipping selected platforms'); - } - - logger.debug( - 'Available platforms: ' + - `${Object.keys(platforms) - .map(getPlatformName) - .join(', ')}`, - ); - - if (rawPackageName === undefined) { - logger.debug('No package name provided, will linking all possible assets.'); - return linkAll(ctx, {linkDeps: opts.all, linkAssets: true}); - } - - // Trim the version / tag out of the package name (eg. package@latest) - const packageName = rawPackageName.replace(/^(.+?)(@.+?)$/gi, '$1'); - - if (!Object.keys(ctx.dependencies).includes(packageName)) { - throw new CLIError(` - Unknown dependency. Make sure that the package you are trying to link is - already installed in your "node_modules" and present in your "package.json" dependencies. - `); - } - - const {[packageName]: dependency} = ctx.dependencies; - - logger.debug(`Package to link: ${rawPackageName}`); - - try { - if (dependency.hooks.prelink) { - await makeHook(dependency.hooks.prelink)(); - } - await linkDependency(platforms, project, dependency); - if (dependency.hooks.postlink) { - await makeHook(dependency.hooks.postlink)(); - } - await linkAssets(platforms, project, dependency.assets); - } catch (error) { - throw new CLIError( - `Linking "${chalk.bold(dependency.name)}" failed.`, - error, - ); - } -} - -export const func = link; - -export default { - func: link, - description: 'links assets and optionally native modules', - name: 'link [packageName]', - options: [ - { - name: '--platforms [list]', - description: 'Scope linking to specified platforms', - parse: (val: string) => val.toLowerCase().split(','), - }, - { - name: '--all [boolean]', - description: 'Link all native modules and assets', - parse: (val: string) => val.toLowerCase().split(','), - }, - ], -}; diff --git a/packages/cli/src/commands/link/linkAll.ts b/packages/cli/src/commands/link/linkAll.ts deleted file mode 100644 index 48610253a..000000000 --- a/packages/cli/src/commands/link/linkAll.ts +++ /dev/null @@ -1,66 +0,0 @@ -import {uniqBy} from 'lodash'; -import * as path from 'path'; -import chalk from 'chalk'; -import {CLIError, logger} from '@react-native-community/cli-tools'; -import {Config} from '@react-native-community/cli-types'; -import linkAssets from './linkAssets'; -import linkDependency from './linkDependency'; -import makeHook from './makeHook'; - -const dedupeAssets = (assets: Array): Array => - uniqBy(assets, asset => path.basename(asset)); - -type Options = { - linkDeps?: boolean; - linkAssets?: boolean; -}; - -async function linkAll(config: Config, options: Options) { - if (options.linkDeps) { - logger.debug('Linking all dependencies'); - logger.info( - `Linking dependencies using "${chalk.bold( - 'link', - )}" command is now legacy and likely unnecessary. We encourage you to try ${chalk.bold( - 'autolinking', - )} that comes with React Native v0.60 default template. Autolinking happens at build time – during CocoaPods install or Gradle install phase. More information: ${chalk.dim.underline( - 'https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', - )}`, - ); - - for (let key in config.dependencies) { - const dependency = config.dependencies[key]; - try { - if (dependency.hooks.prelink) { - await makeHook(dependency.hooks.prelink)(); - } - await linkDependency(config.platforms, config.project, dependency); - if (dependency.hooks.postlink) { - await makeHook(dependency.hooks.postlink)(); - } - } catch (error) { - throw new CLIError( - `Linking "${chalk.bold(dependency.name)}" failed.`, - error, - ); - } - } - } - if (options.linkAssets) { - logger.debug('Linking all assets'); - const projectAssets = config.assets; - const assets = dedupeAssets( - Object.keys(config.dependencies).reduce( - (acc, dependency) => acc.concat(config.dependencies[dependency].assets), - projectAssets, - ), - ); - try { - linkAssets(config.platforms, config.project, assets); - } catch (error) { - throw new CLIError('Linking assets failed.', error); - } - } -} - -export default linkAll; diff --git a/packages/cli/src/commands/link/linkAssets.ts b/packages/cli/src/commands/link/linkAssets.ts deleted file mode 100644 index ad6c7e7e3..000000000 --- a/packages/cli/src/commands/link/linkAssets.ts +++ /dev/null @@ -1,30 +0,0 @@ -import {isEmpty} from 'lodash'; -import {Config} from '@react-native-community/cli-types'; -import {logger} from '@react-native-community/cli-tools'; - -export default function linkAssets( - platforms: Config['platforms'], - project: Config['project'], - assets: Array, -) { - if (isEmpty(assets)) { - return; - } - - Object.keys(platforms || {}).forEach(platform => { - const linkConfig = - platforms[platform] && - platforms[platform].linkConfig && - platforms[platform].linkConfig(); - - if (!linkConfig || !linkConfig.copyAssets || !project[platform]) { - return; - } - - logger.info(`Linking assets to ${platform} project`); - - linkConfig.copyAssets(assets, project[platform]); - }); - - logger.success('Assets have been successfully linked to your project'); -} diff --git a/packages/cli/src/commands/link/linkDependency.ts b/packages/cli/src/commands/link/linkDependency.ts deleted file mode 100644 index e23d4f9ee..000000000 --- a/packages/cli/src/commands/link/linkDependency.ts +++ /dev/null @@ -1,67 +0,0 @@ -import chalk from 'chalk'; -import { - Config, - Dependency, - AndroidDependencyConfig, - AndroidProjectConfig, - IOSDependencyConfig, - IOSProjectConfig, -} from '@react-native-community/cli-types'; -import {logger} from '@react-native-community/cli-tools'; -import pollParams from './pollParams'; -import getPlatformName from './getPlatformName'; - -export default async function linkDependency( - platforms: Config['platforms'], - project: Config['project'], - dependency: Dependency, -) { - const params = await pollParams(dependency.params); - - Object.keys(platforms || {}).forEach(platform => { - const projectConfig: AndroidProjectConfig | IOSProjectConfig = - project[platform]; - const dependencyConfig: AndroidDependencyConfig | IOSDependencyConfig = - dependency.platforms[platform]; - - if (!projectConfig || !dependencyConfig) { - return; - } - const {name} = dependency; - const linkConfig = - platforms[platform] && - platforms[platform].linkConfig && - platforms[platform].linkConfig(); - - if (!linkConfig || !linkConfig.isInstalled || !linkConfig.register) { - return; - } - - const isInstalled = linkConfig.isInstalled( - projectConfig, - name, - dependencyConfig, - ); - - if (isInstalled) { - logger.info( - `${getPlatformName(platform)} module "${chalk.bold( - name, - )}" is already linked`, - ); - return; - } - - logger.info( - `Linking "${chalk.bold(name)}" ${getPlatformName(platform)} dependency`, - ); - - linkConfig.register(name, dependencyConfig, params, projectConfig); - - logger.info( - `${getPlatformName(platform)} module "${chalk.bold( - dependency.name, - )}" has been successfully linked`, - ); - }); -} diff --git a/packages/cli/src/commands/link/makeHook.ts b/packages/cli/src/commands/link/makeHook.ts deleted file mode 100644 index 1cb435965..000000000 --- a/packages/cli/src/commands/link/makeHook.ts +++ /dev/null @@ -1,10 +0,0 @@ -import execa from 'execa'; - -export default function makeHook(command: string) { - return () => { - const args = command.split(' '); - const cmd = args.shift() as string; - - return execa(cmd, args, {stdio: 'inherit'}); - }; -} diff --git a/packages/cli/src/commands/link/pollParams.ts b/packages/cli/src/commands/link/pollParams.ts deleted file mode 100644 index 9e381d1c3..000000000 --- a/packages/cli/src/commands/link/pollParams.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// @ts-ignore untyped -import {prompt, QuestionCollection, Answers} from 'inquirer'; - -export default (questions: QuestionCollection) => - new Promise((resolve, reject) => { - if (!questions) { - resolve({}); - return; - } - - prompt(questions).then(resolve, reject); - }); diff --git a/packages/cli/src/commands/link/unlink.ts b/packages/cli/src/commands/link/unlink.ts deleted file mode 100644 index 59759d905..000000000 --- a/packages/cli/src/commands/link/unlink.ts +++ /dev/null @@ -1,176 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import {flatMap, values, difference, pick} from 'lodash'; -import {logger, CLIError} from '@react-native-community/cli-tools'; -import { - Config, - Dependency, - AndroidDependencyConfig, - AndroidProjectConfig, - IOSDependencyConfig, - IOSProjectConfig, -} from '@react-native-community/cli-types'; -import getPlatformName from './getPlatformName'; -import makeHook from './makeHook'; - -type Flags = { - platforms?: Array; -}; - -const unlinkDependency = ( - platforms: Config['platforms'], - project: Config['project'], - dependency: Dependency, - packageName: string, - otherDependencies: Array, -) => { - Object.keys(platforms || {}).forEach(platform => { - const projectConfig: AndroidProjectConfig | IOSProjectConfig = - project[platform]; - const dependencyConfig: AndroidDependencyConfig | IOSDependencyConfig = - dependency.platforms[platform]; - if (!projectConfig || !dependencyConfig) { - return; - } - - const linkConfig = - platforms[platform] && - platforms[platform].linkConfig && - platforms[platform].linkConfig(); - - if (!linkConfig || !linkConfig.isInstalled || !linkConfig.unregister) { - return; - } - - const isInstalled = linkConfig.isInstalled( - projectConfig, - packageName, - dependencyConfig, - ); - - if (!isInstalled) { - logger.info( - `${getPlatformName(platform)} module "${packageName}" is not installed`, - ); - return; - } - - logger.info( - `Unlinking "${packageName}" ${getPlatformName(platform)} dependency`, - ); - - linkConfig.unregister( - packageName, - dependencyConfig, - projectConfig, - otherDependencies, - ); - - logger.info( - `${getPlatformName(platform)} module "${ - dependency.name - }" has been successfully unlinked`, - ); - }); -}; - -/** - * Updates project and unlink specific dependency - * - * If optional argument [packageName] is provided, it's the only one - * that's checked - */ -async function unlink(args: Array, ctx: Config, opts: Flags) { - const packageName = args[0]; - let platforms = ctx.platforms; - - if (opts.platforms) { - // @ts-ignore - platforms = pick(platforms, opts.platforms); - logger.debug('Skipping selected platforms'); - } - - logger.debug( - `Available platforms: ${Object.keys(platforms) - .map(getPlatformName) - .join(', ')}`, - ); - - const {[packageName]: dependency, ...otherDependencies} = ctx.dependencies; - - if (!dependency) { - throw new CLIError(` - Failed to unlink "${packageName}". It appears that the project is not linked yet. - `); - } - - const dependencies = values(otherDependencies); - try { - if (dependency.hooks.preunlink) { - await makeHook(dependency.hooks.preunlink)(); - } - unlinkDependency( - platforms, - ctx.project, - dependency, - packageName, - dependencies, - ); - if (dependency.hooks.postunlink) { - await makeHook(dependency.hooks.postunlink)(); - } - } catch (error) { - throw new CLIError( - `Something went wrong while unlinking. Reason ${error.message}`, - error, - ); - } - - // @todo move all these to above try/catch - // @todo it is possible we could be unlinking some project assets in case of duplicate - const assets = difference( - dependency.assets, - flatMap(dependencies, d => d.assets), - ); - - if (assets.length === 0) { - return; - } - - Object.keys(platforms || {}).forEach(platform => { - const projectConfig = ctx.project[platform]; - const linkConfig = - platforms[platform] && - platforms[platform].linkConfig && - platforms[platform].linkConfig(); - if (!linkConfig || !linkConfig.unlinkAssets || !projectConfig) { - return; - } - - logger.info(`Unlinking assets from ${platform} project`); - - linkConfig.unlinkAssets(assets, projectConfig); - }); - - logger.info( - `${packageName} assets has been successfully unlinked from your project`, - ); -} - -export default { - func: unlink, - description: 'unlink native dependency', - name: 'unlink ', - options: [ - { - name: '--platforms [list]', - description: 'Scope unlinking to specified platforms', - parse: (val: string) => val.toLowerCase().split(','), - }, - ], -}; diff --git a/packages/cli/src/tools/config/__tests__/__snapshots__/index-test.ts.snap b/packages/cli/src/tools/config/__tests__/__snapshots__/index-test.ts.snap index 89f237697..2aed6b29a 100644 --- a/packages/cli/src/tools/config/__tests__/__snapshots__/index-test.ts.snap +++ b/packages/cli/src/tools/config/__tests__/__snapshots__/index-test.ts.snap @@ -12,24 +12,6 @@ Object { } `; -exports[`should handle deprecated "rnpm" in project root: returns valid config 1`] = ` -Object { - "assets": Array [ - "<>/fonts/SampleFont.ttf", - ], - "commands": Array [], - "dependencies": Object {}, - "haste": Object { - "platforms": Array [], - "providesModuleNodeModules": Array [], - }, - "platforms": Object {}, - "project": Object {}, - "reactNativePath": "<>/node_modules/react-native", - "root": "<>", -} -`; - exports[`should have a valid structure by default 1`] = ` Object { "assets": Array [], @@ -77,25 +59,12 @@ Array [ exports[`should merge project configuration with default values: snapshoting \`react-native-test\` config 1`] = ` Object { - "assets": Array [ - "foo", - ], - "hooks": Object {}, "name": "react-native-test", - "params": Array [], "platforms": Object { "android": null, "ios": Object { - "folder": "<>/node_modules/react-native-test", - "libraryFolder": "Libraries", - "pbxprojPath": "<>/node_modules/react-native-test/ios/HelloWorld.xcodeproj/project.pbxproj", - "plist": Array [], - "podfile": null, "podspecPath": null, - "projectName": "HelloWorld.xcodeproj", - "projectPath": "<>/node_modules/react-native-test/ios/HelloWorld.xcodeproj", "scriptPhases": Array [], - "sharedLibraries": Array [], "sourceDir": "./abc", }, }, @@ -112,65 +81,14 @@ Array [ ] `; -exports[`should read \`rnpm\` config from a dependency and transform it to a new format: foo config 1`] = ` -Object { - "assets": Array [], - "hooks": Object {}, - "name": "react-native-foo", - "params": Array [], - "platforms": Object { - "android": null, - "ios": Object { - "folder": "<>/node_modules/react-native-foo", - "libraryFolder": "Libraries", - "pbxprojPath": "<>/node_modules/react-native-foo/customLocation/customProject.xcodeproj/project.pbxproj", - "plist": Array [], - "podfile": null, - "podspecPath": null, - "projectName": "customProject.xcodeproj", - "projectPath": "<>/node_modules/react-native-foo/customLocation/customProject.xcodeproj", - "scriptPhases": Array [], - "sharedLibraries": Array [], - "sourceDir": "<>/node_modules/react-native-foo/customLocation", - }, - }, - "root": "<>/node_modules/react-native-foo", -} -`; - -exports[`should read \`rnpm\` config from a dependency and transform it to a new format: haste config 1`] = ` -Object { - "platforms": Array [ - "ios", - "android", - "dummy", - ], - "providesModuleNodeModules": Array [ - "react-native", - "react-native-dummy", - ], -} -`; - exports[`should read a config of a dependency and use it to load other settings 1`] = ` Object { - "assets": Array [], - "hooks": Object {}, "name": "react-native-test", - "params": Array [], "platforms": Object { "android": null, "ios": Object { - "folder": "<>/node_modules/react-native-test", - "libraryFolder": "Libraries", - "pbxprojPath": "<>/node_modules/react-native-test/customLocation/customProject.xcodeproj/project.pbxproj", - "plist": Array [], - "podfile": null, "podspecPath": "<>/node_modules/react-native-test/ReactNativeTest.podspec", - "projectName": "customProject.xcodeproj", - "projectPath": "<>/node_modules/react-native-test/customLocation/customProject.xcodeproj", "scriptPhases": Array [], - "sharedLibraries": Array [], "sourceDir": "<>/node_modules/react-native-test/customLocation", }, }, @@ -181,10 +99,7 @@ Object { exports[`should return dependencies from package.json 1`] = ` Object { "react-native": Object { - "assets": Array [], - "hooks": Object {}, "name": "react-native", - "params": Array [], "platforms": Object { "android": null, "ios": null, @@ -192,23 +107,12 @@ Object { "root": "<>/node_modules/react-native", }, "react-native-test": Object { - "assets": Array [], - "hooks": Object {}, "name": "react-native-test", - "params": Array [], "platforms": Object { "android": null, "ios": Object { - "folder": "<>/node_modules/react-native-test", - "libraryFolder": "Libraries", - "pbxprojPath": "<>/node_modules/react-native-test/ios/HelloWorld.xcodeproj/project.pbxproj", - "plist": Array [], - "podfile": null, "podspecPath": null, - "projectName": "HelloWorld.xcodeproj", - "projectPath": "<>/node_modules/react-native-test/ios/HelloWorld.xcodeproj", "scriptPhases": Array [], - "sharedLibraries": Array [], "sourceDir": "<>/node_modules/react-native-test/ios", }, }, diff --git a/packages/cli/src/tools/config/__tests__/findDependencies-test.ts b/packages/cli/src/tools/config/__tests__/findDependencies-test.ts index 2062a20ad..f4508d57e 100644 --- a/packages/cli/src/tools/config/__tests__/findDependencies-test.ts +++ b/packages/cli/src/tools/config/__tests__/findDependencies-test.ts @@ -20,8 +20,8 @@ test('returns plugins from both dependencies and dev dependencies', () => { writeFiles(DIR, { 'package.json': ` { - "dependencies": {"rnpm-plugin-test": "*"}, - "devDependencies": {"rnpm-plugin-test-2": "*"} + "dependencies": {"a-plugin-test": "*"}, + "devDependencies": {"b-plugin-test-2": "*"} } `, }); diff --git a/packages/cli/src/tools/config/__tests__/index-test.ts b/packages/cli/src/tools/config/__tests__/index-test.ts index 8ac8f66f2..2a590aa6a 100644 --- a/packages/cli/src/tools/config/__tests__/index-test.ts +++ b/packages/cli/src/tools/config/__tests__/index-test.ts @@ -40,23 +40,6 @@ test('should have a valid structure by default', () => { expect(removeString(config, DIR)).toMatchSnapshot(); }); -test('should handle deprecated "rnpm" in project root', () => { - writeFiles(DIR, { - 'package.json': `{ - "rnpm": { - "assets": ["./fonts"] - } - }`, - 'fonts/SampleFont.ttf': '', - }); - const config = loadConfig(DIR); - - expect(removeString(config, DIR)).toMatchSnapshot('returns valid config'); - expect(logger.warn).toBeCalledWith( - expect.stringMatching(/Your project is using deprecated/), - ); -}); - test('should return dependencies from package.json', () => { writeFiles(DIR, { 'node_modules/react-native/package.json': '{}', @@ -105,11 +88,6 @@ test('should merge project configuration with default values', () => { writeFiles(DIR, { 'node_modules/react-native/package.json': '{}', 'node_modules/react-native-test/package.json': '{}', - 'node_modules/react-native-test/react-native.config.js': `module.exports = { - dependency: { - assets: ["foo", "baz"] - } - }`, 'node_modules/react-native-test/ios/HelloWorld.xcodeproj/project.pbxproj': '', 'package.json': `{ @@ -127,7 +105,6 @@ test('should merge project configuration with default values', () => { sourceDir: "./abc" } }, - assets: ["foo"] } } }`, @@ -138,35 +115,6 @@ test('should merge project configuration with default values', () => { ); }); -test('should read `rnpm` config from a dependency and transform it to a new format', () => { - writeFiles(DIR, { - 'node_modules/react-native/package.json': '{}', - 'node_modules/react-native-foo/package.json': `{ - "name": "react-native-foo", - "rnpm": { - "ios": { - "project": "./customLocation/customProject.xcodeproj" - }, - "haste": { - "platforms": ["dummy"], - "providesModuleNodeModules": ["react-native-dummy"] - } - } - }`, - 'package.json': `{ - "dependencies": { - "react-native": "0.0.1", - "react-native-foo": "0.0.1" - } - }`, - }); - const {dependencies, haste} = loadConfig(DIR); - expect(removeString(dependencies['react-native-foo'], DIR)).toMatchSnapshot( - 'foo config', - ); - expect(haste).toMatchSnapshot('haste config'); -}); - test('should load commands from "react-native-foo" and "react-native-bar" packages', () => { writeFiles(DIR, { 'node_modules/react-native-foo/package.json': '{}', @@ -200,32 +148,22 @@ test('should load commands from "react-native-foo" and "react-native-bar" packag test('should load an out-of-tree "windows" platform that ships with a dependency', () => { writeFiles(DIR, { - 'node_modules/react-native-windows/platform.js': ` - module.exports = {"windows": {}}; - `, - 'node_modules/react-native-windows/plugin.js': ` - module.exports = []; - `, - 'node_modules/react-native-windows/package.json': `{ - "name": "react-native-windows", - "rnpm": { - "haste": { - "platforms": [ - "windows" - ], - "providesModuleNodeModules": [ - "react-native-windows" - ] - }, - "plugin": "./plugin.js", - "platform": "./platform.js" - } - }`, 'package.json': `{ "dependencies": { - "react-native-windows": "0.0.1" + "react-native-windows": "*" } }`, + 'node_modules/react-native-windows/package.json': '{}', + 'node_modules/react-native-windows/react-native.config.js': ` + module.exports = { + platforms: { + windows: { + projectConfig: () => {}, + dependencyConfig: () => {} + }, + }, + }; + `, }); const {haste, platforms} = loadConfig(DIR); expect(removeString({haste, platforms}, DIR)).toMatchSnapshot(); @@ -337,23 +275,12 @@ module.exports = { const {dependencies} = loadConfig(DIR); expect(removeString(dependencies['local-lib'], DIR)).toMatchInlineSnapshot(` Object { - "assets": Array [], - "hooks": Object {}, "name": "local-lib", - "params": Array [], "platforms": Object { "android": null, "ios": Object { - "folder": "<>/native-libs/local-lib", - "libraryFolder": "Libraries", - "pbxprojPath": "<>/native-libs/local-lib/ios/LocalRNLibrary.xcodeproj/project.pbxproj", - "plist": Array [], - "podfile": null, "podspecPath": "custom-path", - "projectName": "LocalRNLibrary.xcodeproj", - "projectPath": "<>/native-libs/local-lib/ios/LocalRNLibrary.xcodeproj", "scriptPhases": Array [], - "sharedLibraries": Array [], "sourceDir": "<>/native-libs/local-lib/ios", }, }, diff --git a/packages/cli/src/tools/config/index.ts b/packages/cli/src/tools/config/index.ts index 7420108b5..c9e53c29d 100644 --- a/packages/cli/src/tools/config/index.ts +++ b/packages/cli/src/tools/config/index.ts @@ -49,9 +49,6 @@ function getDependencyConfig( }, {} as Config['platforms'], ), - assets: findAssets(root, config.dependency.assets), - hooks: config.dependency.hooks, - params: config.dependency.params, }, userConfig.dependencies[dependencyName] || {}, ) as Dependency; @@ -101,8 +98,6 @@ function loadConfig(projectRoot: string = findProjectRoot()): Config { }, }; - let depsWithWarnings: Array<[string, string]> = []; - const finalConfig = Array.from( new Set([ ...Object.keys(userConfig.dependencies), @@ -118,15 +113,7 @@ function loadConfig(projectRoot: string = findProjectRoot()): Config { root = localDependencyRoot || resolveNodeModuleDir(projectRoot, dependencyName); - const output = readDependencyConfigFromDisk(root); - config = output.config; - - if (output.legacy && !localDependencyRoot) { - const pkg = require(path.join(root, 'package.json')); - const link = - pkg.homepage || `https://npmjs.com/package/${dependencyName}`; - depsWithWarnings.push([dependencyName, link]); - } + config = readDependencyConfigFromDisk(root); } catch (error) { logger.warn( inlineString(` @@ -156,13 +143,7 @@ function loadConfig(projectRoot: string = findProjectRoot()): Config { const isPlatform = Object.keys(config.platforms).length > 0; - /** - * Legacy `rnpm` config required `haste` to be defined. With new config, - * we do it automatically. - * - * @todo: Remove this once `rnpm` config is deprecated and all major RN libs are converted. - */ - const haste = config.haste || { + const haste = { providesModuleNodeModules: isPlatform ? [dependencyName] : [], platforms: Object.keys(config.platforms), }; @@ -195,21 +176,6 @@ function loadConfig(projectRoot: string = findProjectRoot()): Config { }) as Config; }, initialConfig); - if (depsWithWarnings.length) { - logger.warn( - `The following packages use deprecated "rnpm" config that will stop working from next release:\n${depsWithWarnings - .map( - ([name, link]) => - ` - ${chalk.bold(name)}: ${chalk.dim(chalk.underline(link))}`, - ) - .join( - '\n', - )}\nPlease notify their maintainers about it. You can find more details at ${chalk.dim.underline( - 'https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide', - )}.`, - ); - } - return finalConfig; } diff --git a/packages/cli/src/tools/config/readConfigFromDisk.ts b/packages/cli/src/tools/config/readConfigFromDisk.ts index 800c20864..2bda4093c 100644 --- a/packages/cli/src/tools/config/readConfigFromDisk.ts +++ b/packages/cli/src/tools/config/readConfigFromDisk.ts @@ -1,92 +1,17 @@ import Joi from '@hapi/joi'; import cosmiconfig from 'cosmiconfig'; -import path from 'path'; -import chalk from 'chalk'; import {JoiError} from './errors'; import * as schema from './schema'; -import {logger} from '@react-native-community/cli-tools'; -import resolveReactNativePath from './resolveReactNativePath'; import { UserConfig, - AndroidProjectConfig, - AndroidDependencyConfig, - IOSProjectConfig, - IOSDependencyConfig, - Command, - InquirerPrompt, UserDependencyConfig, } from '@react-native-community/cli-types'; -const MIGRATION_GUIDE = `Migration guide: ${chalk.dim.underline( - 'https://github.com/react-native-community/cli/blob/master/docs/configuration.md', -)}`; - -type LegacyConfig = { - ios: IOSProjectConfig; - android: AndroidProjectConfig; - assets: string[]; - reactNativePath: string; - hooks?: { - [key: string]: string; - }; -}; - -type LegacyDependencyConfig = { - platform: any; - ios: IOSDependencyConfig; - android: AndroidDependencyConfig; - assets: string[]; - plugin: Array; - params: InquirerPrompt[]; - haste: any; -}; /** * Places to look for the new configuration */ const searchPlaces = ['react-native.config.js']; -function readLegacyConfigFromDisk(rootFolder: string): UserConfig | void { - let config: LegacyConfig; - - try { - config = require(path.join(rootFolder, 'package.json')).rnpm; - } catch (error) { - // when `init` is running, there's no package.json yet - return undefined; - } - - if (!config) { - return undefined; - } - - const transformedConfig: UserConfig = { - project: { - ios: config.ios, - android: config.android, - }, - assets: config.assets, - commands: [], - dependencies: {}, - // @ts-ignore - TODO: platforms can be empty, adjust types - platforms: {}, - get reactNativePath() { - return config.reactNativePath - ? path.resolve(rootFolder, config.reactNativePath) - : resolveReactNativePath(rootFolder); - }, - }; - - logger.warn( - `Your project is using deprecated "${chalk.bold( - 'rnpm', - )}" config that will stop working from next release. Please use a "${chalk.bold( - 'react-native.config.js', - )}" file to configure the React Native CLI. ${MIGRATION_GUIDE}`, - ); - - return transformedConfig; -} - /** * Reads a project configuration as defined by the user in the current * workspace. @@ -97,9 +22,7 @@ export function readConfigFromDisk(rootFolder: string): UserConfig { stopDir: rootFolder, }); - const {config} = explorer.searchSync(rootFolder) || { - config: readLegacyConfigFromDisk(rootFolder), - }; + const {config} = explorer.searchSync(rootFolder) || {config: undefined}; const result = Joi.validate(config, schema.projectConfig); @@ -116,17 +39,13 @@ export function readConfigFromDisk(rootFolder: string): UserConfig { */ export function readDependencyConfigFromDisk( rootFolder: string, -): {config: UserDependencyConfig; legacy?: boolean} { +): UserDependencyConfig { const explorer = cosmiconfig('react-native', { stopDir: rootFolder, searchPlaces, }); - const searchResult = explorer.searchSync(rootFolder); - const legacy = !searchResult; - let config = searchResult - ? (searchResult.config as UserDependencyConfig) - : (readLegacyDependencyConfigFromDisk(rootFolder) as UserDependencyConfig); + const {config} = explorer.searchSync(rootFolder) || {config: undefined}; const result = Joi.validate(config, schema.dependencyConfig); @@ -134,74 +53,5 @@ export function readDependencyConfigFromDisk( throw new JoiError(result.error); } - return {config: result.value, legacy: legacy && config !== undefined}; -} - -/** - * Returns an array of commands that are defined in the project. - * - * `config.project` can be either an array of paths or a single string. - * Each of the files can export a commands (object) or an array of commands - */ -const loadProjectCommands = ( - root: string, - commands: Array | string | undefined, -): Array => { - return ([] as string[]) - .concat(commands || []) - .reduce((acc: Array, cmdPath: string) => { - const cmds: Array | Command = require(path.join(root, cmdPath)); - return acc.concat(cmds); - }, []); -}; - -/** - * Reads a legacy configuration from a `package.json` "rnpm" key. - */ -function readLegacyDependencyConfigFromDisk( - rootFolder: string, -): UserDependencyConfig | undefined { - let config = {} as LegacyDependencyConfig; - - try { - config = require(path.join(rootFolder, 'package.json')).rnpm; - } catch (error) { - // package.json is usually missing in local libraries that are not in - // project "dependencies", so we just return a bare config - // @ts-ignore - TODO: platforms can be empty, adjust types - return { - dependency: { - platforms: {}, - assets: [], - hooks: {}, - params: [], - }, - commands: [], - platforms: {}, - }; - } - - if (!config) { - return undefined; - } - - const transformedConfig: UserDependencyConfig = { - dependency: { - platforms: { - ios: config.ios, - android: config.android, - }, - assets: config.assets, - // @ts-ignore – likely a bug, but we don't care because legacy config is soon to be removed - hooks: config.commands, - params: config.params, - }, - haste: config.haste, - commands: loadProjectCommands(rootFolder, config.plugin), - platforms: config.platform - ? require(path.join(rootFolder, config.platform)) - : {}, - }; - - return transformedConfig; + return result.value as UserDependencyConfig; } diff --git a/packages/cli/src/tools/config/schema.ts b/packages/cli/src/tools/config/schema.ts index 79f53f36b..6b3e0a376 100644 --- a/packages/cli/src/tools/config/schema.ts +++ b/packages/cli/src/tools/config/schema.ts @@ -45,39 +45,25 @@ export const dependencyConfig = t platforms: map(t.string(), t.any()) .keys({ ios: t + // IOSDependencyParams .object({ project: t.string(), podspecPath: t.string(), - sharedLibraries: t.array().items(t.string()), - libraryFolder: t.string(), scriptPhases: t.array().items(t.object()), }) .default({}), android: t + // AndroidDependencyParams .object({ sourceDir: t.string(), manifestPath: t.string(), packageImportPath: t.string(), packageInstance: t.string(), + packageName: t.string(), }) .default({}), }) .default(), - assets: t - .array() - .items(t.string()) - .default([]), - hooks: map(t.string(), t.string()).default({}), - params: t - .array() - .items( - t.object({ - name: t.string(), - type: t.string(), - message: t.string(), - }), - ) - .default([]), }) .default(), platforms: map( @@ -85,7 +71,9 @@ export const dependencyConfig = t t.object({ dependencyConfig: t.func(), projectConfig: t.func(), - linkConfig: t.func(), + + // Leaving so that 3rd party platforms don't fail. To be removed in 5.x + linkConfig: t.any(), }), ).default({}), commands: t @@ -108,36 +96,23 @@ export const projectConfig = t root: t.string(), platforms: map(t.string(), t.any()).keys({ ios: t + // IOSDependencyConfig .object({ sourceDir: t.string(), - folder: t.string(), - pbxprojPath: t.string(), - podfile: t.string(), podspecPath: t.string(), - projectPath: t.string(), - projectName: t.string(), - libraryFolder: t.string(), - sharedLibraries: t.array().items(t.string()), + scriptPhases: t.array().items(t.object()), }) .allow(null), android: t + // AndroidDependencyConfig .object({ sourceDir: t.string(), - folder: t.string(), + packageName: t.string(), packageImportPath: t.string(), packageInstance: t.string(), }) .allow(null), }), - assets: t.array().items(t.string()), - hooks: map(t.string(), t.string()), - params: t.array().items( - t.object({ - name: t.string(), - type: t.string(), - message: t.string(), - }), - ), }) .allow(null), ).default({}), @@ -145,31 +120,22 @@ export const projectConfig = t project: map(t.string(), t.any()) .keys({ ios: t + // IOSProjectParams .object({ project: t.string(), - sharedLibraries: t.array().items(t.string()), - libraryFolder: t.string(), + scriptPhases: t.array().items(t.object()), }) .default({}), android: t + // AndroidProjectParams .object({ sourceDir: t.string(), manifestPath: t.string(), packageName: t.string(), - packageFolder: t.string(), - mainFilePath: t.string(), - stringsPath: t.string(), - settingsGradlePath: t.string(), - assetsPath: t.string(), - buildGradlePath: t.string(), }) .default({}), }) .default(), - assets: t - .array() - .items(t.string()) - .default([]), commands: t .array() .items(command) @@ -179,7 +145,6 @@ export const projectConfig = t t.object({ dependencyConfig: t.func(), projectConfig: t.func(), - linkConfig: t.func(), }), ).default({}), }) diff --git a/packages/platform-android/src/commands/runAndroid/index.ts b/packages/platform-android/src/commands/runAndroid/index.ts index a9fa9db00..2147df040 100644 --- a/packages/platform-android/src/commands/runAndroid/index.ts +++ b/packages/platform-android/src/commands/runAndroid/index.ts @@ -21,7 +21,6 @@ import { getDefaultUserTerminal, CLIError, } from '@react-native-community/cli-tools'; -import warnAboutManuallyLinkedLibs from '../../link/warnAboutManuallyLinkedLibs'; // Verifies this is an Android project function checkAndroid(root: string) { @@ -54,8 +53,6 @@ async function runAndroid(_argv: Array, config: Config, args: Flags) { return; } - warnAboutManuallyLinkedLibs(config); - if (args.jetifier) { logger.info( `Running ${chalk.bold( diff --git a/packages/platform-android/src/config/index.ts b/packages/platform-android/src/config/index.ts index db069bb2d..37c223b9a 100644 --- a/packages/platform-android/src/config/index.ts +++ b/packages/platform-android/src/config/index.ts @@ -19,10 +19,6 @@ import {XmlDocument} from 'xmldoc'; const getPackageName = (manifest: XmlDocument) => manifest.attr.package; -/** - * Gets android project config by analyzing given folder and taking some - * defaults specified by user into consideration - */ export function projectConfig( folder: string, userConfig: AndroidProjectParams = {}, @@ -34,7 +30,6 @@ export function projectConfig( } const sourceDir = path.join(folder, src); - const isFlat = sourceDir.indexOf('app') === -1; const manifestPath = userConfig.manifestPath ? path.join(sourceDir, userConfig.manifestPath) : findManifest(sourceDir); @@ -51,54 +46,12 @@ export function projectConfig( throw new Error(`Package name not found in ${manifestPath}`); } - const packageFolder = - userConfig.packageFolder || packageName.replace(/\./g, path.sep); - - const mainFilePath = path.join( - sourceDir, - userConfig.mainFilePath || - `src/main/java/${packageFolder}/MainApplication.java`, - ); - - const stringsPath = path.join( - sourceDir, - userConfig.stringsPath || 'src/main/res/values/strings.xml', - ); - - const settingsGradlePath = path.join( - folder, - 'android', - userConfig.settingsGradlePath || 'settings.gradle', - ); - - const assetsPath = path.join( - sourceDir, - userConfig.assetsPath || 'src/main/assets', - ); - - const buildGradlePath = path.join( - sourceDir, - userConfig.buildGradlePath || 'build.gradle', - ); - return { sourceDir, - isFlat, - folder, - stringsPath, - manifestPath, - buildGradlePath, - settingsGradlePath, - assetsPath, - mainFilePath, packageName, }; } -/** - * Same as projectConfigAndroid except it returns - * different config that applies to packages only - */ export function dependencyConfig( folder: string, userConfig: AndroidDependencyParams = {}, @@ -136,5 +89,5 @@ export function dependencyConfig( const packageInstance = userConfig.packageInstance || `new ${packageClassName}()`; - return {sourceDir, folder, packageImportPath, packageInstance}; + return {sourceDir, packageName, packageImportPath, packageInstance}; } diff --git a/packages/platform-android/src/index.ts b/packages/platform-android/src/index.ts index 828fcb43b..1197061a7 100644 --- a/packages/platform-android/src/index.ts +++ b/packages/platform-android/src/index.ts @@ -2,6 +2,5 @@ * Android platform files */ -export {default as linkConfig} from './link'; export {default as commands} from './commands'; export {projectConfig, dependencyConfig} from './config'; diff --git a/packages/platform-android/src/link/__fixtures__/patchedBuild.gradle b/packages/platform-android/src/link/__fixtures__/patchedBuild.gradle deleted file mode 100644 index fe66858c6..000000000 --- a/packages/platform-android/src/link/__fixtures__/patchedBuild.gradle +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -dependencies { - implementation project(':test-impl') - implementation(project(':test-impl-config')) { - exclude(group: 'org.unwanted', module: 'test10') - } - implementation (project(':test-impl-config-spaces')) { - exclude group: 'com.google.android.gms' - } -// Indentation being off for some entries is a part of the test, because -// Gradle doesn't care about indentation and neither should we -implementationDebug project(':test-impl-debug') -implementationAbc project(':test-impl-abc') - compile project(':test-compile') - compileDebug project(':test-compile-debug') - compileAbc project(':test-compile-abc') - - api project(':test-api') - apiDebug project(':test-api-debug') - apiAbc project(':test-api-abc') - - implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation "com.android.support:appcompat-v7:27.1.1" - implementation "com.facebook.react:react-native:+" -} diff --git a/packages/platform-android/src/link/__tests__/isInstalled.test.ts b/packages/platform-android/src/link/__tests__/isInstalled.test.ts deleted file mode 100644 index c783f969e..000000000 --- a/packages/platform-android/src/link/__tests__/isInstalled.test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import isInstalled from '../isInstalled'; - -const path = require('path'); - -const projectConfig = { - buildGradlePath: path.join(__dirname, '../__fixtures__/patchedBuild.gradle'), -}; - -describe('android::isInstalled', () => { - test.each([ - ['test-impl', true], - ['test-impl-config', true], - ['test-impl-config-spaces', true], - ['test-impl-debug', true], - ['test-impl-abc', true], - ['test-compile', true], - ['test-compile-debug', true], - ['test-compile-abc', true], - ['test-api', true], - ['test-api-debug', true], - ['test-api-abc', true], - ['test-not-there-yet', false], - ])( - 'properly detects if %p project is already in build.gradle', - (project: string, isPresent: boolean) => { - expect(isInstalled(projectConfig, project)).toBe(isPresent); - }, - ); -}); diff --git a/packages/platform-android/src/link/copyAssets.ts b/packages/platform-android/src/link/copyAssets.ts deleted file mode 100644 index 50351b40e..000000000 --- a/packages/platform-android/src/link/copyAssets.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs-extra'; -import path from 'path'; -import {logger, groupFilesByType} from '@react-native-community/cli-tools'; - -/** - * Copies each file from an array of assets provided to targetPath directory - * - * For now, the only types of files that are handled are: - * - Fonts (otf, ttf) - copied to targetPath/fonts under original name - */ -export default function copyAssetsAndroid( - files: Array, - project: {assetsPath: string}, -) { - const assets = groupFilesByType(files); - - logger.debug(`Assets path: ${project.assetsPath}`); - (assets.font || []).forEach(asset => { - const fontsDir = path.join(project.assetsPath, 'fonts'); - logger.debug(`Copying asset ${asset}`); - // @todo: replace with fs.mkdirSync(path, {recursive}) + fs.copyFileSync - // and get rid of fs-extra once we move to Node 10 - fs.copySync(asset, path.join(fontsDir, path.basename(asset))); - }); -} diff --git a/packages/platform-android/src/link/index.ts b/packages/platform-android/src/link/index.ts deleted file mode 100644 index f7a5f21f2..000000000 --- a/packages/platform-android/src/link/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import isInstalled from './isInstalled'; -import register from './registerNativeModule'; -import unregister from './unregisterNativeModule'; -import copyAssets from './copyAssets'; -import unlinkAssets from './unlinkAssets'; - -export function getAndroidLinkConfig() { - return {isInstalled, register, unregister, copyAssets, unlinkAssets}; -} - -export default getAndroidLinkConfig; diff --git a/packages/platform-android/src/link/isInstalled.ts b/packages/platform-android/src/link/isInstalled.ts deleted file mode 100644 index de53851e1..000000000 --- a/packages/platform-android/src/link/isInstalled.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import makeBuildPatch from './patches/makeBuildPatch'; - -export default function isInstalled( - config: {buildGradlePath: string}, - name: string, -) { - const buildGradle = fs.readFileSync(config.buildGradlePath, 'utf8'); - return makeBuildPatch(name).installPattern.test(buildGradle); -} diff --git a/packages/platform-android/src/link/patches/__tests__/applyParams.test.ts b/packages/platform-android/src/link/patches/__tests__/applyParams.test.ts deleted file mode 100644 index 35a26f8cc..000000000 --- a/packages/platform-android/src/link/patches/__tests__/applyParams.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import applyParams from '../applyParams'; - -describe('applyParams', () => { - it('apply params to the string', () => { - expect(applyParams('${foo}', {foo: 'foo'} as any, 'react-native')).toEqual( - 'getResources().getString(R.string.reactNative_foo)', - ); - }); - - it('use null if no params provided', () => { - expect(applyParams('${foo}', {}, 'react-native')).toEqual('null'); - }); -}); diff --git a/packages/platform-android/src/link/patches/__tests__/makeBuildPatch.test.ts b/packages/platform-android/src/link/patches/__tests__/makeBuildPatch.test.ts deleted file mode 100644 index 10e952d02..000000000 --- a/packages/platform-android/src/link/patches/__tests__/makeBuildPatch.test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import makeBuildPatch from '../makeBuildPatch'; -import normalizeProjectName from '../normalizeProjectName'; -import path from 'path'; - -const name = 'test'; -const scopedName = '@scoped/test'; -const normalizedScopedName = normalizeProjectName('@scoped/test'); -const buildGradlePath = path.join( - __dirname, - '../../__fixtures__/patchedBuild.gradle', -); - -describe('makeBuildPatch', () => { - it('should build a patch function', () => { - // @ts-ignore - expect(Object.prototype.toString(makeBuildPatch(name))).toBe( - '[object Object]', - ); - }); - - it('should make a correct patch', () => { - const {patch} = makeBuildPatch(name); - expect(patch).toBe(` implementation project(':${name}')\n`); - }); - - it('should make a correct install check pattern', () => { - const {installPattern} = makeBuildPatch(name); - expect(installPattern.toString()).toEqual(expect.stringContaining(name)); - }); - - test.each([ - ['test-impl', " implementation project(':test-impl')\n"], - ['test-compile', " compile project(':test-compile')\n"], - ['test-api', " api project(':test-api')\n"], - [ - 'test-not-there-yet', - " implementation project(':test-not-there-yet')\n", - ], - ])( - 'properly detects the patch string of project %p in build.gradle', - (project, projectPatchString) => { - expect(makeBuildPatch(project, buildGradlePath).patch).toBe( - projectPatchString, - ); - }, - ); -}); - -describe('makeBuildPatchWithScopedPackage', () => { - it('should make a correct patch', () => { - const {patch} = makeBuildPatch(scopedName); - expect(patch).toBe( - ` implementation project(':${normalizedScopedName}')\n`, - ); - }); - - it('should make a correct install check pattern', () => { - const {installPattern} = makeBuildPatch(scopedName); - expect(installPattern.toString()).toEqual( - expect.stringContaining(normalizedScopedName), - ); - }); -}); diff --git a/packages/platform-android/src/link/patches/__tests__/makeImportPatch.test.ts b/packages/platform-android/src/link/patches/__tests__/makeImportPatch.test.ts deleted file mode 100644 index 26f6e6f06..000000000 --- a/packages/platform-android/src/link/patches/__tests__/makeImportPatch.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import makeImportPatch from '../makeImportPatch'; - -const packageImportPath = 'import some.example.project'; - -describe('makeImportPatch', () => { - it('should build a patch', () => { - // @ts-ignore - expect(Object.prototype.toString(makeImportPatch(packageImportPath))).toBe( - '[object Object]', - ); - }); - - it('MainActivity contains a correct import patch', () => { - const {patch} = makeImportPatch(packageImportPath); - - expect(patch).toBe(`\n${packageImportPath}`); - }); -}); diff --git a/packages/platform-android/src/link/patches/__tests__/makePackagePatch.test.ts b/packages/platform-android/src/link/patches/__tests__/makePackagePatch.test.ts deleted file mode 100644 index d31c35153..000000000 --- a/packages/platform-android/src/link/patches/__tests__/makePackagePatch.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import makePackagePatch from '../makePackagePatch'; -import applyParams from '../applyParams'; - -const packageInstance = "new SomeLibrary(${foo}, ${bar}, 'something')"; -const name = 'some-library'; -const params: any = { - foo: 'foo', - bar: 'bar', -}; - -describe('makePackagePatch@0.20', () => { - it('should build a patch', () => { - const packagePatch = makePackagePatch(packageInstance, params, name); - // @ts-ignore - expect(Object.prototype.toString(packagePatch)).toBe('[object Object]'); - }); - - it('MainActivity contains a correct 0.20 import patch', () => { - const {patch} = makePackagePatch(packageInstance, params, name); - const processedInstance = applyParams(packageInstance, params, name); - - expect(patch).toBe(`,\n ${processedInstance}`); - }); -}); diff --git a/packages/platform-android/src/link/patches/__tests__/makeSettingsPatch.test.ts b/packages/platform-android/src/link/patches/__tests__/makeSettingsPatch.test.ts deleted file mode 100644 index 4b80cf7ae..000000000 --- a/packages/platform-android/src/link/patches/__tests__/makeSettingsPatch.test.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import makeSettingsPatch from '../makeSettingsPatch'; - -const projectConfig = { - sourceDir: '/home/project/android/app', - settingsGradlePath: '/home/project/android/settings.gradle', -}; - -describe('makeSettingsPatch with package "test"', () => { - const name = 'test'; - const dependencyConfig = { - sourceDir: `/home/project/node_modules/${name}/android`, - }; - - it('should build a patch function', () => { - expect( - makeSettingsPatch(name, dependencyConfig, projectConfig), - ).toMatchObject({ - pattern: '\n', - patch: expect.any(String), - }); - }); - - it('includes project with correct path', () => { - const {patch} = makeSettingsPatch(name, dependencyConfig, projectConfig); - - expect(patch).toMatchInlineSnapshot(` -"include ':test' -project(':test').projectDir = new File(rootProject.projectDir, '../node_modules/test/android') -" -`); - }); - - // Simulate Windows environment on POSIX filesystem - // TODO: scope this test to Windows-only once we setup CI on Windows - // as changing path to be windows-specific breaks global path mock - // eslint-disable-next-line jest/no-disabled-tests - it.skip('includes project with correct path on Windows', () => { - jest.resetModules(); - jest.doMock('path', () => { - const path = jest.requireActual('path'); - path.dirname = path.win32.dirname; - path.relative = path.win32.relative; - return path; - }); - // eslint-disable-next-line no-shadow - const makeSettingsPatch = require('../makeSettingsPatch').default; - const projectConfigWindows = { - sourceDir: 'C:\\home\\project\\android\\app', - settingsGradlePath: 'C:\\home\\project\\android\\settings.gradle', - }; - const dependencyConfigWindows = { - sourceDir: `C:\\home\\project\\node_modules\\${name}\\android`, - }; - const {patch} = makeSettingsPatch( - name, - dependencyConfigWindows, - projectConfigWindows, - ); - - jest.dontMock('path'); - - expect(patch).toMatchInlineSnapshot(` -"include ':test' -project(':test').projectDir = new File(rootProject.projectDir, '../node_modules/test/android') -" -`); - }); -}); - -describe('makeSettingsPatch with scoped package "@scoped/test"', () => { - const name = '@scoped/test'; - const dependencyConfig = { - sourceDir: `/home/project/node_modules/${name}/android`, - }; - - it('should build a patch function', () => { - expect( - makeSettingsPatch(name, dependencyConfig, projectConfig), - ).toMatchObject({ - pattern: '\n', - patch: expect.any(String), - }); - }); - - it('includes project with correct path', () => { - const {patch} = makeSettingsPatch(name, dependencyConfig, projectConfig); - - expect(patch).toMatchInlineSnapshot(` -"include ':@scoped_test' -project(':@scoped_test').projectDir = new File(rootProject.projectDir, '../node_modules/@scoped/test/android') -" -`); - }); -}); diff --git a/packages/platform-android/src/link/patches/__tests__/makeStringsPatch.test.ts b/packages/platform-android/src/link/patches/__tests__/makeStringsPatch.test.ts deleted file mode 100644 index bf5b21652..000000000 --- a/packages/platform-android/src/link/patches/__tests__/makeStringsPatch.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import makeStringsPatch from '../makeStringsPatch'; - -describe('makeStringsPatch', () => { - it('should export a patch with element', () => { - const params: any = { - keyA: 'valueA', - }; - - expect(makeStringsPatch(params, 'module').patch).toContain( - 'valueA', - ); - }); - - it('should export an empty patch if no params given', () => { - expect(makeStringsPatch({}, 'module').patch).toBe(''); - }); -}); diff --git a/packages/platform-android/src/link/patches/__tests__/normalizeProjectName.test.ts b/packages/platform-android/src/link/patches/__tests__/normalizeProjectName.test.ts deleted file mode 100644 index 16d149192..000000000 --- a/packages/platform-android/src/link/patches/__tests__/normalizeProjectName.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import normalizeProjectName from '../normalizeProjectName'; - -const name = 'test'; -const scopedName = '@scoped/test'; - -describe('normalizeProjectName', () => { - it('should replace slashes with underscores', () => { - expect(normalizeProjectName(name)).toBe('test'); - expect(normalizeProjectName(scopedName)).toBe('@scoped_test'); - }); -}); diff --git a/packages/platform-android/src/link/patches/applyParams.ts b/packages/platform-android/src/link/patches/applyParams.ts deleted file mode 100644 index aea97fe3c..000000000 --- a/packages/platform-android/src/link/patches/applyParams.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {camelCase as toCamelCase} from 'lodash'; -import {AndroidProjectParams} from '@react-native-community/cli-types'; - -export default function applyParams( - str: string, - params: AndroidProjectParams, - prefix: string, -) { - return str.replace(/\$\{(\w+)\}/g, (_pattern: string, param: string) => { - const name = `${toCamelCase(prefix)}_${param}`; - - // @ts-ignore - return params[param] - ? `getResources().getString(R.string.${name})` - : 'null'; - }); -} diff --git a/packages/platform-android/src/link/patches/applyPatch.ts b/packages/platform-android/src/link/patches/applyPatch.ts deleted file mode 100644 index d18c2d8d2..000000000 --- a/packages/platform-android/src/link/patches/applyPatch.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import {logger} from '@react-native-community/cli-tools'; - -export default function applyPatch( - file: string, - patch: {patch: string; pattern: string | RegExp}, -) { - if (file) { - logger.debug(`Patching ${file}`); - } - - fs.writeFileSync( - file, - fs - .readFileSync(file, 'utf8') - .replace(patch.pattern, match => `${match}${patch.patch}`), - ); -} diff --git a/packages/platform-android/src/link/patches/makeBuildPatch.ts b/packages/platform-android/src/link/patches/makeBuildPatch.ts deleted file mode 100644 index 74d8392be..000000000 --- a/packages/platform-android/src/link/patches/makeBuildPatch.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import normalizeProjectName from './normalizeProjectName'; - -const depConfigs = ['compile', 'api', 'implementation']; - -export default function makeBuildPatch(name: string, buildGradlePath?: string) { - const normalizedProjectName = normalizeProjectName(name); - const installPattern = new RegExp( - buildDepRegExp(normalizedProjectName, ...depConfigs), - ); - - return { - installPattern, - pattern: /[^ \t]dependencies {(\r\n|\n)/, - patch: makePatchString(normalizedProjectName, buildGradlePath), - }; -} - -function makePatchString( - normalizedProjectName: string, - buildGradlePath?: string, -) { - const defaultPatchString = ` implementation project(':${normalizedProjectName}')\n`; - if (!buildGradlePath) { - return defaultPatchString; - } - - const buildGradle = fs.readFileSync(buildGradlePath, 'utf8'); - - for (const config of depConfigs) { - const depPattern = new RegExp( - buildDepRegExp(normalizedProjectName, config), - ); - if (depPattern.test(buildGradle)) { - return ` ${config} project(':${normalizedProjectName}')\n`; - } - } - - return defaultPatchString; -} - -function buildDepRegExp( - normalizedProjectName: string, - ...configs: Array -) { - const orConfigs = configs.join('|'); - return `(${orConfigs})\\w*\\s*\\(*project\\s*\\(['"]:${normalizedProjectName}['"]\\)`; -} diff --git a/packages/platform-android/src/link/patches/makeImportPatch.ts b/packages/platform-android/src/link/patches/makeImportPatch.ts deleted file mode 100644 index a90d6a47b..000000000 --- a/packages/platform-android/src/link/patches/makeImportPatch.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export default function makeImportPatch(packageImportPath: string) { - return { - pattern: 'import com.facebook.react.ReactApplication;', - patch: `\n${packageImportPath}`, - }; -} diff --git a/packages/platform-android/src/link/patches/makePackagePatch.ts b/packages/platform-android/src/link/patches/makePackagePatch.ts deleted file mode 100644 index 3e983cab3..000000000 --- a/packages/platform-android/src/link/patches/makePackagePatch.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import applyParams from './applyParams'; -import {AndroidProjectParams} from '@react-native-community/cli-types'; - -export default function makePackagePatch( - packageInstance: string, - params: AndroidProjectParams, - prefix: string, -) { - const processedInstance = applyParams(packageInstance, params, prefix); - - return { - pattern: 'new MainReactPackage()', - patch: `,\n ${processedInstance}`, - }; -} diff --git a/packages/platform-android/src/link/patches/makeSettingsPatch.ts b/packages/platform-android/src/link/patches/makeSettingsPatch.ts deleted file mode 100644 index 6bd81ab4b..000000000 --- a/packages/platform-android/src/link/patches/makeSettingsPatch.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import path from 'path'; -import slash from 'slash'; -import normalizeProjectName from './normalizeProjectName'; - -export default function makeSettingsPatch( - name: string, - androidConfig: {sourceDir: string}, - projectConfig: {settingsGradlePath: string}, -) { - // Gradle expects paths to be posix even on Windows - const projectDir = slash( - path.relative( - path.dirname(projectConfig.settingsGradlePath), - androidConfig.sourceDir, - ), - ); - const normalizedProjectName = normalizeProjectName(name); - - return { - pattern: '\n', - patch: - `include ':${normalizedProjectName}'\n` + - `project(':${normalizedProjectName}').projectDir = ` + - `new File(rootProject.projectDir, '${projectDir}')\n`, - }; -} diff --git a/packages/platform-android/src/link/patches/makeStringsPatch.ts b/packages/platform-android/src/link/patches/makeStringsPatch.ts deleted file mode 100644 index 817c005f1..000000000 --- a/packages/platform-android/src/link/patches/makeStringsPatch.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {camelCase as toCamelCase} from 'lodash'; -import {AndroidProjectParams} from '@react-native-community/cli-types'; - -export default function makeStringsPatch( - params: AndroidProjectParams, - prefix: string, -) { - const values = Object.keys(params).map(param => { - const name = `${toCamelCase(prefix)}_${param}`; - return ( - ' ' + - // @ts-ignore - `${params[param]}` - ); - }); - - const patch = values.length > 0 ? `${values.join('\n')}\n` : ''; - - return { - pattern: '\n', - patch, - }; -} diff --git a/packages/platform-android/src/link/patches/normalizeProjectName.ts b/packages/platform-android/src/link/patches/normalizeProjectName.ts deleted file mode 100644 index e905cc371..000000000 --- a/packages/platform-android/src/link/patches/normalizeProjectName.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export default function normalizeProjectName(name: string) { - return name.replace(/\//g, '_'); -} diff --git a/packages/platform-android/src/link/patches/revokePatch.ts b/packages/platform-android/src/link/patches/revokePatch.ts deleted file mode 100644 index 474a6287b..000000000 --- a/packages/platform-android/src/link/patches/revokePatch.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import {logger} from '@react-native-community/cli-tools'; - -export default function revokePatch(file: string, patch: {patch: string}) { - if (file) { - logger.debug(`Patching ${file}`); - } - - fs.writeFileSync( - file, - fs.readFileSync(file, 'utf8').replace(patch.patch, ''), - ); -} diff --git a/packages/platform-android/src/link/registerNativeModule.ts b/packages/platform-android/src/link/registerNativeModule.ts deleted file mode 100644 index e02a03583..000000000 --- a/packages/platform-android/src/link/registerNativeModule.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import applyPatch from './patches/applyPatch'; -import makeStringsPatch from './patches/makeStringsPatch'; -import makeSettingsPatch from './patches/makeSettingsPatch'; -import makeBuildPatch from './patches/makeBuildPatch'; -import makeImportPatch from './patches/makeImportPatch'; -import makePackagePatch from './patches/makePackagePatch'; -import { - AndroidProjectConfig, - AndroidDependencyConfig, - AndroidProjectParams, -} from '@react-native-community/cli-types'; - -export default function registerNativeAndroidModule( - name: string, - androidConfig: AndroidDependencyConfig, - params: AndroidProjectParams, - projectConfig: AndroidProjectConfig, -) { - const buildPatch = makeBuildPatch(name); - - applyPatch( - projectConfig.settingsGradlePath, - makeSettingsPatch(name, androidConfig, projectConfig), - ); - - applyPatch(projectConfig.buildGradlePath, buildPatch); - applyPatch(projectConfig.stringsPath, makeStringsPatch(params, name)); - - applyPatch( - projectConfig.mainFilePath, - makePackagePatch(androidConfig.packageInstance, params, name), - ); - - applyPatch( - projectConfig.mainFilePath, - makeImportPatch(androidConfig.packageImportPath), - ); -} diff --git a/packages/platform-android/src/link/unlinkAssets.ts b/packages/platform-android/src/link/unlinkAssets.ts deleted file mode 100644 index f340c8924..000000000 --- a/packages/platform-android/src/link/unlinkAssets.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import path from 'path'; -import {logger, groupFilesByType} from '@react-native-community/cli-tools'; - -/** - * Copies each file from an array of assets provided to targetPath directory - * - * For now, the only types of files that are handled are: - * - Fonts (otf, ttf) - copied to targetPath/fonts under original name - */ -export default function unlinkAssetsAndroid( - files: Array, - project: {assetsPath: string}, -) { - const assets = groupFilesByType(files); - - logger.debug(`Assets path: ${project.assetsPath}`); - (assets.font || []).forEach(file => { - const filePath = path.join( - project.assetsPath, - 'fonts', - path.basename(file), - ); - if (fs.existsSync(filePath)) { - logger.debug(`Removing asset ${filePath}`); - fs.unlinkSync(filePath); - } - }); -} diff --git a/packages/platform-android/src/link/unregisterNativeModule.ts b/packages/platform-android/src/link/unregisterNativeModule.ts deleted file mode 100644 index 457e28aeb..000000000 --- a/packages/platform-android/src/link/unregisterNativeModule.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import {camelCase as toCamelCase} from 'lodash'; - -import revokePatch from './patches/revokePatch'; -import makeSettingsPatch from './patches/makeSettingsPatch'; -import makeBuildPatch from './patches/makeBuildPatch'; -import makeStringsPatch from './patches/makeStringsPatch'; -import makeImportPatch from './patches/makeImportPatch'; -import makePackagePatch from './patches/makePackagePatch'; -import { - AndroidProjectConfig, - AndroidDependencyConfig, -} from '@react-native-community/cli-types'; - -export default function unregisterNativeAndroidModule( - name: string, - androidConfig: AndroidDependencyConfig, - projectConfig: AndroidProjectConfig, -) { - const buildPatch = makeBuildPatch(name, projectConfig.buildGradlePath); - const strings = fs.readFileSync(projectConfig.stringsPath, 'utf8'); - const params = {}; - - strings.replace( - /moduleConfig="true" name="(\w+)">(.*) { - // @ts-ignore - params[param.slice(toCamelCase(name).length + 1)] = value; - }, - ); - - revokePatch( - projectConfig.settingsGradlePath, - makeSettingsPatch(name, androidConfig, projectConfig), - ); - - revokePatch(projectConfig.buildGradlePath, buildPatch); - revokePatch(projectConfig.stringsPath, makeStringsPatch(params, name)); - - revokePatch( - projectConfig.mainFilePath, - makePackagePatch(androidConfig.packageInstance, params, name), - ); - - revokePatch( - projectConfig.mainFilePath, - makeImportPatch(androidConfig.packageImportPath), - ); -} diff --git a/packages/platform-android/src/link/warnAboutManuallyLinkedLibs.ts b/packages/platform-android/src/link/warnAboutManuallyLinkedLibs.ts deleted file mode 100644 index 57d02c727..000000000 --- a/packages/platform-android/src/link/warnAboutManuallyLinkedLibs.ts +++ /dev/null @@ -1,53 +0,0 @@ -import chalk from 'chalk'; -import {logger} from '@react-native-community/cli-tools'; -import getLinkConfig from './index'; -import {Config} from '@react-native-community/cli-types'; - -// TODO: move to cli-tools once platform-ios and platform-android are migrated -// to TS and unify with iOS implementation -export default function warnAboutManuallyLinkedLibs( - config: Config, - platform: string = 'android', - linkConfig: ReturnType< - Config['platforms']['android']['linkConfig'] - > = getLinkConfig(), -) { - let deps: Array = []; - - for (let key in config.dependencies) { - const dependency = config.dependencies[key]; - try { - const projectConfig = config.project[platform]; - const dependencyConfig = dependency.platforms[platform]; - if (projectConfig && dependencyConfig) { - const x = linkConfig.isInstalled( - projectConfig, - dependency.name, - dependencyConfig, - ); - deps = deps.concat(x ? dependency.name : []); - } - } catch (error) { - logger.debug('Checking manually linked modules failed.', error); - } - } - - const installedModules = [...new Set(deps)]; - - if (installedModules.length) { - logger.error( - `React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: \n${installedModules - .map( - x => - ` - ${chalk.bold(x)} ${chalk.dim( - `(to unlink run: "react-native unlink ${x}")`, - )}`, - ) - .join( - '\n', - )}\nThis is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink " and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.\nRead more about autolinking: ${chalk.dim.underline( - 'https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', - )}`, - ); - } -} diff --git a/packages/platform-ios/package.json b/packages/platform-ios/package.json index cdcda6a82..fca150894 100644 --- a/packages/platform-ios/package.json +++ b/packages/platform-ios/package.json @@ -6,8 +6,7 @@ "dependencies": { "@react-native-community/cli-tools": "^2.8.3", "chalk": "^2.4.2", - "js-yaml": "^3.13.1", - "xcode": "^2.0.0" + "js-yaml": "^3.13.1" }, "devDependencies": { "@react-native-community/cli-types": "^3.0.0-alpha.2", diff --git a/packages/platform-ios/src/link-pods/getDependenciesFromPodfileLock.ts b/packages/platform-ios/src/commands/runIOS/getDependenciesFromPodfileLock.ts similarity index 100% rename from packages/platform-ios/src/link-pods/getDependenciesFromPodfileLock.ts rename to packages/platform-ios/src/commands/runIOS/getDependenciesFromPodfileLock.ts diff --git a/packages/platform-ios/src/commands/runIOS/index.ts b/packages/platform-ios/src/commands/runIOS/index.ts index 3d8d12e48..9df8f5cff 100644 --- a/packages/platform-ios/src/commands/runIOS/index.ts +++ b/packages/platform-ios/src/commands/runIOS/index.ts @@ -17,8 +17,7 @@ import {Config} from '@react-native-community/cli-types'; import findXcodeProject, {ProjectInfo} from './findXcodeProject'; import parseIOSDevicesList from './parseIOSDevicesList'; import findMatchingSimulator from './findMatchingSimulator'; -import warnAboutManuallyLinkedLibs from '../../link/warnAboutManuallyLinkedLibs'; -import warnAboutPodInstall from '../../link/warnAboutPodInstall'; +import warnAboutPodInstall from './warnAboutPodInstall'; import { logger, CLIError, @@ -46,7 +45,6 @@ function runIOS(_: Array, ctx: Config, args: FlagsT) { ); } - warnAboutManuallyLinkedLibs(ctx); warnAboutPodInstall(ctx); process.chdir(args.projectPath); diff --git a/packages/platform-ios/src/link/warnAboutPodInstall.ts b/packages/platform-ios/src/commands/runIOS/warnAboutPodInstall.ts similarity index 77% rename from packages/platform-ios/src/link/warnAboutPodInstall.ts rename to packages/platform-ios/src/commands/runIOS/warnAboutPodInstall.ts index de826afdb..743b22d54 100644 --- a/packages/platform-ios/src/link/warnAboutPodInstall.ts +++ b/packages/platform-ios/src/commands/runIOS/warnAboutPodInstall.ts @@ -2,16 +2,20 @@ import path from 'path'; import chalk from 'chalk'; import {logger} from '@react-native-community/cli-tools'; import {Config} from '@react-native-community/cli-types'; -import getDependenciesFromPodfileLock from '../link-pods/getDependenciesFromPodfileLock'; +import getDependenciesFromPodfileLock from './getDependenciesFromPodfileLock'; export default function warnAboutPodInstall(config: Config) { + if (!config.project.ios || !config.project.ios.podfile) { + return; + } + const podLockDeps = getDependenciesFromPodfileLock( - `${config.project.ios!.podfile}.lock`, + `${config.project.ios.podfile}.lock`, ); const podDeps = Object.keys(config.dependencies) .map(depName => { const dependency = config.dependencies[depName].platforms.ios; - return dependency + return dependency && dependency.podspecPath ? path.basename(dependency.podspecPath).replace(/\.podspec/, '') : ''; }) diff --git a/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts b/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts deleted file mode 100644 index f3da6da8e..000000000 --- a/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import findPodfilePath from '../findPodfilePath'; -import * as projects from '../__fixtures__/projects'; - -jest.mock('path'); -jest.mock('fs'); - -const fs = require('fs'); - -describe('ios::findPodfilePath', () => { - it('returns null if there is no Podfile', () => { - fs.__setMockFilesystem(projects.withoutPods); - expect(findPodfilePath('')).toBeNull(); - }); - - it('returns Podfile path if it exists', () => { - fs.__setMockFilesystem(projects.withPods); - expect(findPodfilePath('/ios')).toContain('Podfile'); - }); -}); diff --git a/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts b/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts index cfe0cc9b0..90e03733b 100644 --- a/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts +++ b/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts @@ -34,17 +34,4 @@ describe('ios::getProjectConfig', () => { expect(getProjectConfig(folder, userConfig)).toBeNull(); }); - - it('returns normalized shared library names', () => { - const projectConfig = getProjectConfig('/testDir/nested', { - sharedLibraries: ['libc++', 'libz.tbd', 'HealthKit', 'HomeKit.framework'], - }); - - expect(projectConfig.sharedLibraries).toEqual([ - 'libc++.tbd', - 'libz.tbd', - 'HealthKit.framework', - 'HomeKit.framework', - ]); - }); }); diff --git a/packages/platform-ios/src/config/findPodfilePath.ts b/packages/platform-ios/src/config/findPodfilePath.ts deleted file mode 100644 index 695be0888..000000000 --- a/packages/platform-ios/src/config/findPodfilePath.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import path from 'path'; - -export default function findPodfilePath(projectFolder: string) { - const podFilePath = path.join(projectFolder, '..', 'Podfile'); - const podFileExists = fs.existsSync(podFilePath); - - return podFileExists ? podFilePath : null; -} diff --git a/packages/platform-ios/src/config/getPodspecName.ts b/packages/platform-ios/src/config/getPodspecName.ts deleted file mode 100644 index 923eb5be6..000000000 --- a/packages/platform-ios/src/config/getPodspecName.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ -import path from 'path'; - -export default function getPodspecName(podspecFile: string) { - return path.basename(podspecFile).replace(/\.podspec$/, ''); -} diff --git a/packages/platform-ios/src/config/index.ts b/packages/platform-ios/src/config/index.ts index 27f9cdfa8..346e04994 100644 --- a/packages/platform-ios/src/config/index.ts +++ b/packages/platform-ios/src/config/index.ts @@ -9,37 +9,52 @@ import path from 'path'; import {memoize} from 'lodash'; import findProject from './findProject'; -import findPodfilePath from './findPodfilePath'; import findPodspec from './findPodspec'; -import {IOSProjectParams} from '@react-native-community/cli-types'; +import { + IOSProjectParams, + IOSProjectConfig, + IOSDependencyConfig, + IOSDependencyParams, +} from '@react-native-community/cli-types'; +import fs from 'fs'; const memoizedFindProject = memoize(findProject); -/** - * For libraries specified without an extension, add '.tbd' for those that - * start with 'lib' and '.framework' to the rest. - */ -const mapSharedLibaries = (libraries: Array) => - libraries.map(name => { - if (path.extname(name)) { - return name; - } - return name + (name.indexOf('lib') === 0 ? '.tbd' : '.framework'); - }); +export function projectConfig( + folder: string, + userConfig: IOSProjectParams | null, +): IOSProjectConfig | null { + if (!userConfig) { + return null; + } -/** - * Returns project config by analyzing given folder and applying some user defaults - * when constructing final object - */ -export function projectConfig(folder: string, userConfig: IOSProjectParams) { + const project = userConfig.project || memoizedFindProject(folder); + + if (!project) { + return null; + } + + const projectPath = path.join(folder, project); + const sourceDir = path.dirname(projectPath); + const podfile = path.join(sourceDir, 'Podfile'); + + return { + sourceDir, + podfile: fs.existsSync(podfile) ? podfile : null, + scriptPhases: userConfig.scriptPhases || [], + }; +} + +export function dependencyConfig( + folder: string, + userConfig: IOSDependencyParams | null, +): IOSDependencyConfig | null { if (!userConfig) { - return; + return null; } + const project = userConfig.project || memoizedFindProject(folder); - /** - * No iOS config found here - */ if (!project) { return null; } @@ -49,22 +64,12 @@ export function projectConfig(folder: string, userConfig: IOSProjectParams) { return { sourceDir, - folder, - pbxprojPath: path.join(projectPath, 'project.pbxproj'), - podfile: findPodfilePath(projectPath), podspecPath: userConfig.podspecPath || // podspecs are usually placed in the root dir of the library or in the // iOS project path findPodspec(folder) || findPodspec(sourceDir), - projectPath, - projectName: path.basename(projectPath), - libraryFolder: userConfig.libraryFolder || 'Libraries', - sharedLibraries: mapSharedLibaries(userConfig.sharedLibraries || []), - plist: userConfig.plist || [], scriptPhases: userConfig.scriptPhases || [], }; } - -export const dependencyConfig = projectConfig; diff --git a/packages/platform-ios/src/index.ts b/packages/platform-ios/src/index.ts index 389b3a219..59589860d 100644 --- a/packages/platform-ios/src/index.ts +++ b/packages/platform-ios/src/index.ts @@ -2,6 +2,5 @@ * iOS platform files */ -export {default as linkConfig} from './link'; export {default as commands} from './commands'; export {projectConfig, dependencyConfig} from './config'; diff --git a/packages/platform-ios/src/link-pods/__fixtures__/Info.plist b/packages/platform-ios/src/link-pods/__fixtures__/Info.plist deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/platform-ios/src/link-pods/__fixtures__/PodfileSimple b/packages/platform-ios/src/link-pods/__fixtures__/PodfileSimple deleted file mode 100644 index 3e42c2527..000000000 --- a/packages/platform-ios/src/link-pods/__fixtures__/PodfileSimple +++ /dev/null @@ -1,8 +0,0 @@ -source 'https://github.com/CocoaPods/Specs.git' -platform :ios, '9.0' - -target 'Testing' do - pod 'TestPod', '~> 3.1' - - # test should point to this line -end diff --git a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithFunction b/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithFunction deleted file mode 100644 index 13b70fb0a..000000000 --- a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithFunction +++ /dev/null @@ -1,30 +0,0 @@ -source 'https://github.com/CocoaPods/Specs.git' -platform :ios, '9.0' - -target 'none' do - pod 'React', - :path => "../node_modules/react-native", - :subspecs => [ - "Core", - "ART", - "RCTActionSheet", - "RCTAnimation", - "RCTCameraRoll", - "RCTGeolocation", - "RCTImage", - "RCTNetwork", - "RCTText", - "RCTVibration", - "RCTWebSocket", - "DevSupport", - "BatchedBridge" - ] - - pod 'Yoga', - :path => "../node_modules/react-native/ReactCommon/yoga" - - # test should point to this line - post_install do |installer| - - end -end diff --git a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithMarkers b/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithMarkers deleted file mode 100644 index bf27d3368..000000000 --- a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithMarkers +++ /dev/null @@ -1,34 +0,0 @@ -source 'https://github.com/CocoaPods/Specs.git' -# platform :ios, '9.0' - -target 'None' do - # Uncomment the next line if you're using Swift or would like to use dynamic frameworks - # use_frameworks! - # Your 'node_modules' directory is probably in the root of your project, # but if not, adjust the `:path` accordingly - pod 'React', :path => '../node_modules/react-native', :subspecs => [ - 'Core', - 'RCTText', - 'RCTNetwork', - 'BatchedBridge', - 'RCTImage', - 'RCTWebSocket', # needed for debugging - # Add any other subspecs you want to use in your project - ] - - # Add new pods below this line - - # test should point to this line - target 'NoneTests' do - inherit! :search_paths - # Pods for testing - end -end - -target 'Second' do - - target 'NoneUITests' do - inherit! :search_paths - # Add new pods below this line - end - -end \ No newline at end of file diff --git a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithTarget b/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithTarget deleted file mode 100644 index 5887ababe..000000000 --- a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithTarget +++ /dev/null @@ -1,32 +0,0 @@ -source 'https://github.com/CocoaPods/Specs.git' -# platform :ios, '9.0' - -target 'None' do - # Uncomment the next line if you're using Swift or would like to use dynamic frameworks - # use_frameworks! - # Your 'node_modules' directory is probably in the root of your project, # but if not, adjust the `:path` accordingly - pod 'React', :path => '../node_modules/react-native', :subspecs => [ - 'Core', - 'RCTText', - 'RCTNetwork', - 'BatchedBridge', - 'RCTImage', - 'RCTWebSocket', # needed for debugging - # Add any other subspecs you want to use in your project - ] - - # Explicitly include Yoga if you are using RN >= 0.42.0 - pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga" - - # test should point to this line - target 'NoneTests' do - inherit! :search_paths - # Pods for testing - end - - target 'NoneUITests' do - inherit! :search_paths - # Pods for testing - end - -end \ No newline at end of file diff --git a/packages/platform-ios/src/link-pods/__tests__/findLineToAddPod.test.ts b/packages/platform-ios/src/link-pods/__tests__/findLineToAddPod.test.ts deleted file mode 100644 index a4e3b6f6a..000000000 --- a/packages/platform-ios/src/link-pods/__tests__/findLineToAddPod.test.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import findLineToAddPod from '../findLineToAddPod'; -import readPodfile from '../readPodfile'; - -const path = require('path'); - -const PODFILES_PATH = path.join(__dirname, '../__fixtures__/'); -const LINE_AFTER_TARGET_IN_TEST_PODFILE = 4; - -describe('pods::findLineToAddPod', () => { - it('returns null if file is not Podfile', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'Info.plist')); - expect( - findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), - ).toBeNull(); - }); - - it('returns correct line number for Simple Podfile', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileSimple')); - expect( - findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), - ).toEqual({line: 7, indentation: 2}); - }); - - it('returns correct line number for Podfile with target', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileWithTarget')); - expect( - findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), - ).toEqual({line: 21, indentation: 2}); - }); - - it('returns correct line number for Podfile with function', () => { - const podfile = readPodfile( - path.join(PODFILES_PATH, 'PodfileWithFunction'), - ); - expect( - findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), - ).toEqual({line: 26, indentation: 2}); - }); -}); diff --git a/packages/platform-ios/src/link-pods/__tests__/findMarkedLinesInPodfile.test.ts b/packages/platform-ios/src/link-pods/__tests__/findMarkedLinesInPodfile.test.ts deleted file mode 100644 index 5f2951f83..000000000 --- a/packages/platform-ios/src/link-pods/__tests__/findMarkedLinesInPodfile.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import readPodfile from '../readPodfile'; -import findMarkedLinesInPodfile from '../findMarkedLinesInPodfile'; - -const path = require('path'); - -const PODFILES_PATH = path.join(__dirname, '../__fixtures__'); - -describe('pods::findMarkedLinesInPodfile', () => { - it('returns empty array if file is not Podfile', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'Info.plist')); - expect(findMarkedLinesInPodfile(podfile)).toEqual([]); - }); - - it('returns empty array for Simple Podfile', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileSimple')); - expect(findMarkedLinesInPodfile(podfile)).toEqual([]); - }); - - it('returns correct line numbers for Podfile with marker', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileWithMarkers')); - const expectedObject = [ - {line: 18, indentation: 2}, - {line: 31, indentation: 4}, - ]; - expect(findMarkedLinesInPodfile(podfile)).toEqual(expectedObject); - }); -}); diff --git a/packages/platform-ios/src/link-pods/__tests__/findPodTargetLine.test.ts b/packages/platform-ios/src/link-pods/__tests__/findPodTargetLine.test.ts deleted file mode 100644 index e8fdd24ce..000000000 --- a/packages/platform-ios/src/link-pods/__tests__/findPodTargetLine.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import findPodTargetLine from '../findPodTargetLine'; -import readPodfile from '../readPodfile'; - -const path = require('path'); - -const PODFILES_PATH = path.join(__dirname, '../__fixtures__'); - -describe('pods::findPodTargetLine', () => { - it('returns null if file is not Podfile', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'Info.plist')); - expect(findPodTargetLine(podfile, 'name')).toBeNull(); - }); - - it('returns null if there is not matching project name', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileSimple')); - expect(findPodTargetLine(podfile, 'invalidName')).toBeNull(); - }); - - it('returns correct line if there is a matching project', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileSimple')); - expect(findPodTargetLine(podfile, 'Testing')).toBe(4); - }); -}); diff --git a/packages/platform-ios/src/link-pods/__tests__/isInstalled.test.ts b/packages/platform-ios/src/link-pods/__tests__/isInstalled.test.ts deleted file mode 100644 index 13621191e..000000000 --- a/packages/platform-ios/src/link-pods/__tests__/isInstalled.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import isInstalled from '../isInstalled'; - -const path = require('path'); - -const PODFILES_PATH = path.join(__dirname, '../__fixtures__/'); - -describe('pods::isInstalled', () => { - it('returns false if pod is missing', () => { - const project = {podfile: path.join(PODFILES_PATH, 'PodfileSimple')}; - const podspecName = {podspecPath: '/path/NotExisting'}; - // @ts-ignore FIXME: Improve types - expect(isInstalled(project, podspecName)).toBe(false); - }); - - it('returns true for existing pod with version number', () => { - const project = {podfile: path.join(PODFILES_PATH, 'PodfileSimple')}; - const podspecName = {podspecPath: '/path/TestPod.podspec'}; - // @ts-ignore FIXME: Improve types - expect(isInstalled(project, podspecName)).toBe(true); - }); - - it('returns true for existing pod with path', () => { - const project = {podfile: path.join(PODFILES_PATH, 'PodfileWithTarget')}; - const podspecName = {podspecPath: '/path/Yoga.podspec'}; - // @ts-ignore FIXME: Improve types - expect(isInstalled(project, podspecName)).toBe(true); - }); - - it('returns true for existing pod with multiline definition', () => { - const project = { - podfile: path.join(PODFILES_PATH, 'PodfileWithFunction'), - }; - const podspecName = {podspecPath: '/path/React.podspec'}; - // @ts-ignore FIXME: Improve types - expect(isInstalled(project, podspecName)).toBe(true); - }); -}); diff --git a/packages/platform-ios/src/link-pods/__tests__/removePodEntry.test.ts b/packages/platform-ios/src/link-pods/__tests__/removePodEntry.test.ts deleted file mode 100644 index 5e9e25472..000000000 --- a/packages/platform-ios/src/link-pods/__tests__/removePodEntry.test.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import removePodEntry from '../removePodEntry'; -import readPodfile from '../readPodfile'; - -const path = require('path'); - -const PODFILES_PATH = path.join(__dirname, '../__fixtures__/'); - -describe('pods::removePodEntry', () => { - it('should remove one line from Podfile with TestPod', () => { - const {podfileContent, podLinesCount} = readTestPodFile('PodfileSimple'); - const podFileWithRemoved = removePodEntry(podfileContent, 'TestPod'); - const newLineCount = podFileWithRemoved.split('\n').length; - expect(newLineCount).toBe(podLinesCount - 1); - }); - - it('should remove one line from Podfile with Yoga', () => { - const {podfileContent, podLinesCount} = readTestPodFile( - 'PodfileWithTarget', - ); - const podFileWithRemoved = removePodEntry(podfileContent, 'Yoga'); - const newLineCount = podFileWithRemoved.split('\n').length; - expect(newLineCount).toBe(podLinesCount - 1); - }); - - it('should remove whole reference to React pod from Podfile', () => { - const {podfileContent, podLinesCount} = readTestPodFile( - 'PodfileWithTarget', - ); - const podFileWithRemoved = removePodEntry(podfileContent, 'React'); - const newLineCount = podFileWithRemoved.split('\n').length; - expect(newLineCount).toBe(podLinesCount - 9); - }); -}); - -function readTestPodFile(fileName) { - const podfileLines = readPodfile(path.join(PODFILES_PATH, fileName)); - return { - podfileContent: podfileLines.join('\n'), - podLinesCount: podfileLines.length, - }; -} diff --git a/packages/platform-ios/src/link-pods/addPodEntry.ts b/packages/platform-ios/src/link-pods/addPodEntry.ts deleted file mode 100644 index 2a76cb889..000000000 --- a/packages/platform-ios/src/link-pods/addPodEntry.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {logger} from '@react-native-community/cli-tools'; -import getPodspecName from '../config/getPodspecName'; - -export default function addPodEntry( - podLines: Array, - linesToAddEntry: - | Array<{line: number; indentation: number}> - | {line: number; indentation: number} - | null - | undefined, - podspecPath: string, - nodeModulePath: string, -) { - const podName = getPodspecName(podspecPath); - const newEntry = `pod '${podName}', :path => '../node_modules/${nodeModulePath}'\n`; - - if (!linesToAddEntry) { - return; - } - - if (Array.isArray(linesToAddEntry)) { - linesToAddEntry.map(({line, indentation}, idx) => { - logger.debug(`Adding ${podName} to Pod file"`); - podLines.splice(line + idx, 0, getLineToAdd(newEntry, indentation)); - }); - } else { - const {line, indentation} = linesToAddEntry; - logger.debug(`Adding ${podName} to Pod file"`); - podLines.splice(line, 0, getLineToAdd(newEntry, indentation)); - } -} - -function getLineToAdd(newEntry: string, indentation: number) { - const spaces = Array(indentation + 1).join(' '); - return spaces + newEntry; -} diff --git a/packages/platform-ios/src/link-pods/findLineToAddPod.ts b/packages/platform-ios/src/link-pods/findLineToAddPod.ts deleted file mode 100644 index 8a35d730b..000000000 --- a/packages/platform-ios/src/link-pods/findLineToAddPod.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export default function findLineToAddPod( - podLines: Array, - firstTargetLine: number, -) { - // match line with new target: target 'project_name' do (most likely target inside podfile main target) - const nextTarget = /target ('|")\w+('|") do/g; - // match line that has only 'end' (if we don't catch new target or function, this would mean this is end of current target) - const endOfCurrentTarget = /^\s*end\s*$/g; - // match function definition, like: post_install do |installer| (some Podfiles have function defined inside main target - const functionDefinition = /^\s*[a-z_]+\s+do(\s+\|[a-z]+\|)?/g; - - for (let i = firstTargetLine; i < podLines.length - 1; i++) { - const matchNextConstruct = - podLines[i].match(nextTarget) || podLines[i].match(functionDefinition); - const matchEnd = podLines[i].match(endOfCurrentTarget); - - if (matchNextConstruct || matchEnd) { - const firstNonSpaceCharacter = podLines[i].search(/\S/); - return { - indentation: firstNonSpaceCharacter + (matchEnd ? 2 : 0), - line: i, - }; - } - } - return null; -} diff --git a/packages/platform-ios/src/link-pods/findMarkedLinesInPodfile.ts b/packages/platform-ios/src/link-pods/findMarkedLinesInPodfile.ts deleted file mode 100644 index 1e9551025..000000000 --- a/packages/platform-ios/src/link-pods/findMarkedLinesInPodfile.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export const MARKER_TEXT = '# Add new pods below this line'; - -export default function findMarkedLinesInPodfile(podLines: Array) { - const result = []; - for (let i = 0, len = podLines.length; i < len; i++) { - if (podLines[i].includes(MARKER_TEXT)) { - result.push({line: i + 1, indentation: podLines[i].indexOf('#')}); - } - } - return result; -} diff --git a/packages/platform-ios/src/link-pods/findPodTargetLine.ts b/packages/platform-ios/src/link-pods/findPodTargetLine.ts deleted file mode 100644 index f18e41bba..000000000 --- a/packages/platform-ios/src/link-pods/findPodTargetLine.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export default function findPodTargetLine( - podLines: Array, - projectName: string, -) { - const targetName = projectName.replace('.xcodeproj', ''); - // match first target definition in file: target 'target_name' do - const targetRegex = new RegExp(`target ('|")${targetName}('|") do`, 'g'); - for (let i = 0, len = podLines.length; i < len; i++) { - const match = podLines[i].match(targetRegex); - if (match) { - return i + 1; - } - } - return null; -} diff --git a/packages/platform-ios/src/link-pods/isInstalled.ts b/packages/platform-ios/src/link-pods/isInstalled.ts deleted file mode 100644 index 6972cd4c7..000000000 --- a/packages/platform-ios/src/link-pods/isInstalled.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import readPodfile from './readPodfile'; -import getPodspecName from '../config/getPodspecName'; -import { - IOSProjectConfig, - IOSDependencyConfig, -} from '@react-native-community/cli-types'; - -export default function isInstalled( - iOSProject: IOSProjectConfig, - dependencyConfig: IOSDependencyConfig, -) { - if (!iOSProject.podfile || !dependencyConfig.podspecPath) { - return false; - } - // match line with pod declaration: pod 'dependencyPodName' (other possible parameters of pod are ignored) - const dependencyRegExp = new RegExp( - `pod\\s+('|")${getPodspecName(dependencyConfig.podspecPath)}('|")`, - 'g', - ); - const podLines = readPodfile(iOSProject.podfile); - for (let i = 0, len = podLines.length; i < len; i++) { - const match = podLines[i].match(dependencyRegExp); - if (match) { - return true; - } - } - return false; -} diff --git a/packages/platform-ios/src/link-pods/readPodfile.ts b/packages/platform-ios/src/link-pods/readPodfile.ts deleted file mode 100644 index cfbccf020..000000000 --- a/packages/platform-ios/src/link-pods/readPodfile.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import {logger} from '@react-native-community/cli-tools'; - -export default function readPodfile(podfilePath: string) { - logger.debug(`Reading ${podfilePath}`); - const podContent = fs.readFileSync(podfilePath, 'utf8'); - return podContent.split(/\r?\n/g); -} diff --git a/packages/platform-ios/src/link-pods/registerNativeModule.ts b/packages/platform-ios/src/link-pods/registerNativeModule.ts deleted file mode 100644 index ab8e6b909..000000000 --- a/packages/platform-ios/src/link-pods/registerNativeModule.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ -import chalk from 'chalk'; -import {CLIError} from '@react-native-community/cli-tools'; -import {IOSProjectConfig} from '@react-native-community/cli-types'; -import readPodfile from './readPodfile'; -import findPodTargetLine from './findPodTargetLine'; -import findLineToAddPod from './findLineToAddPod'; -import findMarkedLinesInPodfile, { - MARKER_TEXT, -} from './findMarkedLinesInPodfile'; -import addPodEntry from './addPodEntry'; -import savePodFile from './savePodFile'; - -export default function registerNativeModulePods( - name: string, - podspecPath: string, - iOSProject: IOSProjectConfig, -) { - const podLines = readPodfile(iOSProject.podfile); - const linesToAddEntry = getLinesToAddEntry(podLines, iOSProject); - addPodEntry(podLines, linesToAddEntry, podspecPath, name); - savePodFile(iOSProject.podfile, podLines); -} - -function getLinesToAddEntry( - podLines: Array, - {projectName}: IOSProjectConfig, -) { - const linesToAddPodWithMarker = findMarkedLinesInPodfile(podLines); - if (linesToAddPodWithMarker.length > 0) { - return linesToAddPodWithMarker; - } - const firstTargetLined = findPodTargetLine(podLines, projectName); - if (firstTargetLined === null) { - throw new CLIError(` - We couldn't find a target to add a CocoaPods dependency. - - Make sure that you have a "${chalk.dim( - `target '${projectName.replace('.xcodeproj', '')}' do`, - )}" line in your Podfile. - - Alternatively, include "${chalk.dim( - MARKER_TEXT, - )}" in a Podfile where we should add - linked dependencies. - `); - } - return findLineToAddPod(podLines, firstTargetLined); -} diff --git a/packages/platform-ios/src/link-pods/removePodEntry.ts b/packages/platform-ios/src/link-pods/removePodEntry.ts deleted file mode 100644 index a9339cf36..000000000 --- a/packages/platform-ios/src/link-pods/removePodEntry.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {logger} from '@react-native-community/cli-tools'; -import getPodspecName from '../config/getPodspecName'; - -export default function removePodEntry( - podfileContent: string, - podspecPath: string, -) { - const podName = getPodspecName(podspecPath); - // this regex should catch line(s) with full pod definition, like: pod 'podname', :path => '../node_modules/podname', :subspecs => ['Sub2', 'Sub1'] - const podRegex = new RegExp( - `\\n( |\\t)*pod\\s+("|')${podName}("|')(,\\s*(:[a-z]+\\s*=>)?\\s*(("|').*?("|')|\\[[\\s\\S]*?\\]))*\\n`, - 'g', - ); - logger.debug(`Removing ${podName} from Pod file`); - return podfileContent.replace(podRegex, '\n'); -} diff --git a/packages/platform-ios/src/link-pods/savePodFile.ts b/packages/platform-ios/src/link-pods/savePodFile.ts deleted file mode 100644 index a26cdf438..000000000 --- a/packages/platform-ios/src/link-pods/savePodFile.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import {logger} from '@react-native-community/cli-tools'; - -export default function savePodFile( - podfilePath: string, - podLines: Array, -) { - const newPodfile = podLines.join('\n'); - logger.debug(`Writing changes to ${podfilePath}`); - fs.writeFileSync(podfilePath, newPodfile); -} diff --git a/packages/platform-ios/src/link-pods/unregisterNativeModule.ts b/packages/platform-ios/src/link-pods/unregisterNativeModule.ts deleted file mode 100644 index 18d0acdde..000000000 --- a/packages/platform-ios/src/link-pods/unregisterNativeModule.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import removePodEntry from './removePodEntry'; -import {logger} from '@react-native-community/cli-tools'; -import { - IOSDependencyConfig, - IOSProjectConfig, -} from '@react-native-community/cli-types'; - -/** - * Unregister native module IOS with CocoaPods - */ -export default function unregisterNativeModule( - dependencyConfig: IOSDependencyConfig, - iOSProject: IOSProjectConfig, -) { - const podContent = fs.readFileSync(iOSProject.podfile, 'utf8'); - const removed = removePodEntry(podContent, dependencyConfig.podspecPath); - logger.debug(`Writing changes to ${iOSProject.podfile}`); - fs.writeFileSync(iOSProject.podfile, removed); -} diff --git a/packages/platform-ios/src/link/__fixtures__/Info.plist b/packages/platform-ios/src/link/__fixtures__/Info.plist deleted file mode 100644 index b2e7b96ea..000000000 --- a/packages/platform-ios/src/link/__fixtures__/Info.plist +++ /dev/null @@ -1,12 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - - - diff --git a/packages/platform-ios/src/link/__fixtures__/linearGradient.pbxproj b/packages/platform-ios/src/link/__fixtures__/linearGradient.pbxproj deleted file mode 100644 index ca87c2e43..000000000 --- a/packages/platform-ios/src/link/__fixtures__/linearGradient.pbxproj +++ /dev/null @@ -1,258 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - BBD49E3F1AC8DEF000610F8E /* BVLinearGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = BBD49E3A1AC8DEF000610F8E /* BVLinearGradient.m */; }; - BBD49E401AC8DEF000610F8E /* BVLinearGradientManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BBD49E3C1AC8DEF000610F8E /* BVLinearGradientManager.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 58B511D91A9E6C8500147676 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 134814201AA4EA6300B7C361 /* libBVLinearGradient.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBVLinearGradient.a; sourceTree = BUILT_PRODUCTS_DIR; }; - BBD49E391AC8DEF000610F8E /* BVLinearGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BVLinearGradient.h; sourceTree = ""; }; - BBD49E3A1AC8DEF000610F8E /* BVLinearGradient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BVLinearGradient.m; sourceTree = ""; }; - BBD49E3B1AC8DEF000610F8E /* BVLinearGradientManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BVLinearGradientManager.h; sourceTree = ""; }; - BBD49E3C1AC8DEF000610F8E /* BVLinearGradientManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BVLinearGradientManager.m; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 58B511D81A9E6C8500147676 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 134814211AA4EA7D00B7C361 /* Products */ = { - isa = PBXGroup; - children = ( - 134814201AA4EA6300B7C361 /* libBVLinearGradient.a */, - ); - name = Products; - sourceTree = ""; - }; - 58B511D21A9E6C8500147676 = { - isa = PBXGroup; - children = ( - BBD49E391AC8DEF000610F8E /* BVLinearGradient.h */, - BBD49E3A1AC8DEF000610F8E /* BVLinearGradient.m */, - BBD49E3B1AC8DEF000610F8E /* BVLinearGradientManager.h */, - BBD49E3C1AC8DEF000610F8E /* BVLinearGradientManager.m */, - 134814211AA4EA7D00B7C361 /* Products */, - ); - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 58B511DA1A9E6C8500147676 /* BVLinearGradient */ = { - isa = PBXNativeTarget; - buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "BVLinearGradient" */; - buildPhases = ( - 58B511D71A9E6C8500147676 /* Sources */, - 58B511D81A9E6C8500147676 /* Frameworks */, - 58B511D91A9E6C8500147676 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = BVLinearGradient; - productName = RCTDataManager; - productReference = 134814201AA4EA6300B7C361 /* libBVLinearGradient.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 58B511D31A9E6C8500147676 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0610; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 58B511DA1A9E6C8500147676 = { - CreatedOnToolsVersion = 6.1.1; - }; - }; - }; - buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "BVLinearGradient" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 58B511D21A9E6C8500147676; - productRefGroup = 58B511D21A9E6C8500147676; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 58B511DA1A9E6C8500147676 /* BVLinearGradient */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 58B511D71A9E6C8500147676 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BBD49E3F1AC8DEF000610F8E /* BVLinearGradient.m in Sources */, - BBD49E401AC8DEF000610F8E /* BVLinearGradientManager.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 58B511ED1A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - 58B511EE1A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 58B511F01A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - "$(SRCROOT)/../react-native/React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = BVLinearGradient; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 58B511F11A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - "$(SRCROOT)/../react-native/React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = BVLinearGradient; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "BVLinearGradient" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511ED1A9E6C8500147676 /* Debug */, - 58B511EE1A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "BVLinearGradient" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511F01A9E6C8500147676 /* Debug */, - 58B511F11A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 58B511D31A9E6C8500147676 /* Project object */; -} diff --git a/packages/platform-ios/src/link/__fixtures__/project.pbxproj b/packages/platform-ios/src/link/__fixtures__/project.pbxproj deleted file mode 100644 index 428aa40c9..000000000 --- a/packages/platform-ios/src/link/__fixtures__/project.pbxproj +++ /dev/null @@ -1,1011 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { -/* Begin PBXBuildFile section */ - 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; - 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; - 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; }; - 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; }; - 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; }; - 00E356F31AD99517003FC87E /* BasicTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* BasicTests.m */; }; - 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; }; - 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; }; - 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; }; - 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; }; - 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; }; - 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; - 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; - 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; - 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; - 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; }; - 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTActionSheet; - }; - 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTGeolocation; - }; - 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 58B5115D1A9E6B3D00147676; - remoteInfo = RCTImage; - }; - 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 58B511DB1A9E6C8500147676; - remoteInfo = RCTNetwork; - }; - 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 832C81801AAF6DEF007FA2F7; - remoteInfo = RCTVibration; - }; - 00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 13B07F861A680F5B00A75B9A; - remoteInfo = Basic; - }; - 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTSettings; - }; - 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3C86DF461ADF2C930047B81A; - remoteInfo = RCTWebSocket; - }; - 146834031AC3E56700842450 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; - remoteInfo = React; - }; - 3DAD3E831DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A283A1D9B042B00D4039D; - remoteInfo = "RCTImage-tvOS"; - }; - 3DAD3E871DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28471D9B043800D4039D; - remoteInfo = "RCTLinking-tvOS"; - }; - 3DAD3E8B1DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28541D9B044C00D4039D; - remoteInfo = "RCTNetwork-tvOS"; - }; - 3DAD3E8F1DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28611D9B046600D4039D; - remoteInfo = "RCTSettings-tvOS"; - }; - 3DAD3E931DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A287B1D9B048500D4039D; - remoteInfo = "RCTText-tvOS"; - }; - 3DAD3E981DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28881D9B049200D4039D; - remoteInfo = "RCTWebSocket-tvOS"; - }; - 3DAD3EA21DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28131D9B038B00D4039D; - remoteInfo = "React-tvOS"; - }; - 3DAD3EA41DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3D3C059A1DE3340900C268FA; - remoteInfo = yoga; - }; - 3DAD3EA61DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3D3C06751DE3340C00C268FA; - remoteInfo = "yoga-tvOS"; - }; - 3DAD3EA81DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3D3CD9251DE5FBEC00167DC4; - remoteInfo = cxxreact; - }; - 3DAD3EAA1DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3D3CD9321DE5FBEE00167DC4; - remoteInfo = "cxxreact-tvOS"; - }; - 3DAD3EAC1DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3D3CD90B1DE5FBD600167DC4; - remoteInfo = jschelpers; - }; - 3DAD3EAE1DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3D3CD9181DE5FBD800167DC4; - remoteInfo = "jschelpers-tvOS"; - }; - 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTAnimation; - }; - 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28201D9B03D100D4039D; - remoteInfo = "RCTAnimation-tvOS"; - }; - 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTLinking; - }; - 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 58B5119B1A9E6C1200147676; - remoteInfo = RCTText; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = ""; }; - 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = ""; }; - 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = "../node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj"; sourceTree = ""; }; - 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj"; sourceTree = ""; }; - 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = ""; }; - 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = ""; }; - 00E356EE1AD99517003FC87E /* BasicTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BasicTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 00E356F21AD99517003FC87E /* BasicTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BasicTests.m; sourceTree = ""; }; - 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = ""; }; - 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = ""; }; - 13B07F961A680F5B00A75B9A /* Basic.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Basic.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = Basic/AppDelegate.h; sourceTree = ""; }; - 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = Basic/AppDelegate.m; sourceTree = ""; }; - 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; - 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = Basic/Images.xcassets; sourceTree = ""; }; - 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Basic/Info.plist; sourceTree = ""; }; - 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Basic/main.m; sourceTree = ""; }; - 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; - 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = ""; }; - 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; - 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 00E356EB1AD99517003FC87E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 13B07F8C1A680F5B00A75B9A /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */, - 146834051AC3E58100842450 /* libReact.a in Frameworks */, - 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */, - 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */, - 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */, - 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */, - 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */, - 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */, - 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */, - 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, - 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 00C302A81ABCB8CE00DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */, - ); - name = Products; - sourceTree = ""; - }; - 00C302B61ABCB90400DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */, - ); - name = Products; - sourceTree = ""; - }; - 00C302BC1ABCB91800DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */, - 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 00C302D41ABCB9D200DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */, - 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 00C302E01ABCB9EE00DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */, - ); - name = Products; - sourceTree = ""; - }; - 00E356EF1AD99517003FC87E /* BasicTests */ = { - isa = PBXGroup; - children = ( - 00E356F21AD99517003FC87E /* BasicTests.m */, - 00E356F01AD99517003FC87E /* Supporting Files */, - ); - path = BasicTests; - sourceTree = ""; - }; - 00E356F01AD99517003FC87E /* Supporting Files */ = { - isa = PBXGroup; - children = ( - 00E356F11AD99517003FC87E /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; - 139105B71AF99BAD00B5F7CC /* Products */ = { - isa = PBXGroup; - children = ( - 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */, - 3DAD3E901DF850E9000B6D8A /* libRCTSettings-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 139FDEE71B06529A00C62182 /* Products */ = { - isa = PBXGroup; - children = ( - 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */, - 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 13B07FAE1A68108700A75B9A /* Basic */ = { - isa = PBXGroup; - children = ( - 008F07F21AC5B25A0029DE68 /* main.jsbundle */, - 13B07FAF1A68108700A75B9A /* AppDelegate.h */, - 13B07FB01A68108700A75B9A /* AppDelegate.m */, - 13B07FB51A68108700A75B9A /* Images.xcassets */, - 13B07FB61A68108700A75B9A /* Info.plist */, - 13B07FB11A68108700A75B9A /* LaunchScreen.xib */, - 13B07FB71A68108700A75B9A /* main.m */, - ); - name = Basic; - sourceTree = ""; - }; - 146834001AC3E56700842450 /* Products */ = { - isa = PBXGroup; - children = ( - 146834041AC3E56700842450 /* libReact.a */, - 3DAD3EA31DF850E9000B6D8A /* libReact.a */, - 3DAD3EA51DF850E9000B6D8A /* libyoga.a */, - 3DAD3EA71DF850E9000B6D8A /* libyoga.a */, - 3DAD3EA91DF850E9000B6D8A /* libcxxreact.a */, - 3DAD3EAB1DF850E9000B6D8A /* libcxxreact.a */, - 3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */, - 3DAD3EAF1DF850E9000B6D8A /* libjschelpers.a */, - ); - name = Products; - sourceTree = ""; - }; - 5E91572E1DD0AC6500FF2AA8 /* Products */ = { - isa = PBXGroup; - children = ( - 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */, - 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 78C398B11ACF4ADC00677621 /* Products */ = { - isa = PBXGroup; - children = ( - 78C398B91ACF4ADC00677621 /* libRCTLinking.a */, - 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 832341AE1AAA6A7D00B99B32 /* Libraries */ = { - isa = PBXGroup; - children = ( - 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */, - 146833FF1AC3E56700842450 /* React.xcodeproj */, - 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */, - 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */, - 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */, - 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */, - 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */, - 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */, - 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, - 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, - 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, - ); - name = Libraries; - sourceTree = ""; - }; - 832341B11AAA6A8300B99B32 /* Products */ = { - isa = PBXGroup; - children = ( - 832341B51AAA6A8300B99B32 /* libRCTText.a */, - 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 83CBB9F61A601CBA00E9B192 = { - isa = PBXGroup; - children = ( - AD9196DA1CABA83E000E8D91 /* NestedGroup */, - 13B07FAE1A68108700A75B9A /* Basic */, - 832341AE1AAA6A7D00B99B32 /* Libraries */, - 00E356EF1AD99517003FC87E /* BasicTests */, - 83CBBA001A601CBA00E9B192 /* Products */, - ); - indentWidth = 2; - sourceTree = ""; - tabWidth = 2; - }; - 83CBBA001A601CBA00E9B192 /* Products */ = { - isa = PBXGroup; - children = ( - 13B07F961A680F5B00A75B9A /* Basic.app */, - 00E356EE1AD99517003FC87E /* BasicTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - AD9196DA1CABA83E000E8D91 /* NestedGroup */ = { - isa = PBXGroup; - children = ( - AD9196DB1CABA844000E8D91 /* Libraries */, - ); - name = NestedGroup; - sourceTree = ""; - }; - AD9196DB1CABA844000E8D91 /* Libraries */ = { - isa = PBXGroup; - children = ( - ); - name = Libraries; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 00E356ED1AD99517003FC87E /* BasicTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "BasicTests" */; - buildPhases = ( - 00E356EA1AD99517003FC87E /* Sources */, - 00E356EB1AD99517003FC87E /* Frameworks */, - 00E356EC1AD99517003FC87E /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 00E356F51AD99517003FC87E /* PBXTargetDependency */, - ); - name = BasicTests; - productName = BasicTests; - productReference = 00E356EE1AD99517003FC87E /* BasicTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 13B07F861A680F5B00A75B9A /* Basic */ = { - isa = PBXNativeTarget; - buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "Basic" */; - buildPhases = ( - 13B07F871A680F5B00A75B9A /* Sources */, - 13B07F8C1A680F5B00A75B9A /* Frameworks */, - 13B07F8E1A680F5B00A75B9A /* Resources */, - 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Basic; - productName = "Hello World"; - productReference = 13B07F961A680F5B00A75B9A /* Basic.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 83CBB9F71A601CBA00E9B192 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 610; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 00E356ED1AD99517003FC87E = { - CreatedOnToolsVersion = 6.2; - TestTargetID = 13B07F861A680F5B00A75B9A; - }; - }; - }; - buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "Basic" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 83CBB9F61A601CBA00E9B192; - productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; - projectDirPath = ""; - projectReferences = ( - { - ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */; - ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; - }, - { - ProductGroup = 5E91572E1DD0AC6500FF2AA8 /* Products */; - ProjectRef = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; - }, - { - ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */; - ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; - }, - { - ProductGroup = 00C302BC1ABCB91800DB3ED1 /* Products */; - ProjectRef = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; - }, - { - ProductGroup = 78C398B11ACF4ADC00677621 /* Products */; - ProjectRef = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; - }, - { - ProductGroup = 00C302D41ABCB9D200DB3ED1 /* Products */; - ProjectRef = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; - }, - { - ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */; - ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; - }, - { - ProductGroup = 832341B11AAA6A8300B99B32 /* Products */; - ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; - }, - { - ProductGroup = 00C302E01ABCB9EE00DB3ED1 /* Products */; - ProjectRef = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; - }, - { - ProductGroup = 139FDEE71B06529A00C62182 /* Products */; - ProjectRef = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; - }, - { - ProductGroup = 146834001AC3E56700842450 /* Products */; - ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; - }, - ); - projectRoot = ""; - targets = ( - 13B07F861A680F5B00A75B9A /* Basic */, - 00E356ED1AD99517003FC87E /* BasicTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXReferenceProxy section */ - 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTActionSheet.a; - remoteRef = 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTGeolocation.a; - remoteRef = 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTImage.a; - remoteRef = 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTNetwork.a; - remoteRef = 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTVibration.a; - remoteRef = 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTSettings.a; - remoteRef = 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTWebSocket.a; - remoteRef = 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 146834041AC3E56700842450 /* libReact.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libReact.a; - remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTImage-tvOS.a"; - remoteRef = 3DAD3E831DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTLinking-tvOS.a"; - remoteRef = 3DAD3E871DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTNetwork-tvOS.a"; - remoteRef = 3DAD3E8B1DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3E901DF850E9000B6D8A /* libRCTSettings-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTSettings-tvOS.a"; - remoteRef = 3DAD3E8F1DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTText-tvOS.a"; - remoteRef = 3DAD3E931DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTWebSocket-tvOS.a"; - remoteRef = 3DAD3E981DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EA31DF850E9000B6D8A /* libReact.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libReact.a; - remoteRef = 3DAD3EA21DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EA51DF850E9000B6D8A /* libyoga.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libyoga.a; - remoteRef = 3DAD3EA41DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EA71DF850E9000B6D8A /* libyoga.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libyoga.a; - remoteRef = 3DAD3EA61DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EA91DF850E9000B6D8A /* libcxxreact.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libcxxreact.a; - remoteRef = 3DAD3EA81DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EAB1DF850E9000B6D8A /* libcxxreact.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libcxxreact.a; - remoteRef = 3DAD3EAA1DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libjschelpers.a; - remoteRef = 3DAD3EAC1DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EAF1DF850E9000B6D8A /* libjschelpers.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libjschelpers.a; - remoteRef = 3DAD3EAE1DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTAnimation.a; - remoteRef = 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTAnimation-tvOS.a"; - remoteRef = 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTLinking.a; - remoteRef = 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 832341B51AAA6A8300B99B32 /* libRCTText.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTText.a; - remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - -/* Begin PBXResourcesBuildPhase section */ - 00E356EC1AD99517003FC87E /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 13B07F8E1A680F5B00A75B9A /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, - 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Bundle React Native code and images"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 00E356EA1AD99517003FC87E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 00E356F31AD99517003FC87E /* BasicTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 13B07F871A680F5B00A75B9A /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */, - 13B07FC11A68108700A75B9A /* main.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 00E356F51AD99517003FC87E /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 13B07F861A680F5B00A75B9A /* Basic */; - targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin PBXVariantGroup section */ - 13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = { - isa = PBXVariantGroup; - children = ( - 13B07FB21A68108700A75B9A /* Base */, - ); - name = LaunchScreen.xib; - path = Basic; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 00E356F61AD99517003FC87E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - INFOPLIST_FILE = BasicTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Basic.app/Basic"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - ); - }; - name = Debug; - }; - 00E356F71AD99517003FC87E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - COPY_PHASE_STRIP = NO; - INFOPLIST_FILE = BasicTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Basic.app/Basic"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - ); - }; - name = Release; - }; - 13B07F941A680F5B00A75B9A /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CURRENT_PROJECT_VERSION = 1; - DEAD_CODE_STRIPPING = NO; - INFOPLIST_FILE = Basic/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - OTHER_LDFLAGS = ( - "$(inherited)", - "-ObjC", - "-lc++", - ); - PRODUCT_NAME = Basic; - VERSIONING_SYSTEM = "apple-generic"; - HEADER_SEARCH_PATHS = "$(inherited)"; - }; - name = Debug; - }; - 13B07F951A680F5B00A75B9A /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CURRENT_PROJECT_VERSION = 1; - INFOPLIST_FILE = Basic/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - OTHER_LDFLAGS = ( - "$(inherited)", - "-ObjC", - "-lc++", - ); - PRODUCT_NAME = Basic; - VERSIONING_SYSTEM = "apple-generic"; - HEADER_SEARCH_PATHS = "$(inherited)"; - }; - name = Release; - }; - 83CBBA201A601CBA00E9B192 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - 83CBBA211A601CBA00E9B192 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "BasicTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 00E356F61AD99517003FC87E /* Debug */, - 00E356F71AD99517003FC87E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "Basic" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 13B07F941A680F5B00A75B9A /* Debug */, - 13B07F951A680F5B00A75B9A /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "Basic" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 83CBBA201A601CBA00E9B192 /* Debug */, - 83CBBA211A601CBA00E9B192 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; -} diff --git a/packages/platform-ios/src/link/__tests__/addFileToProject.test.ts b/packages/platform-ios/src/link/__tests__/addFileToProject.test.ts deleted file mode 100644 index c429f0918..000000000 --- a/packages/platform-ios/src/link/__tests__/addFileToProject.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import addFileToProject from '../addFileToProject'; - -const xcode = require('xcode'); -const path = require('path'); -const _ = require('lodash'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::addFileToProject', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should add file to a project', () => { - const {fileRef} = addFileToProject( - project, - '../__fixtures__/linearGradient.pbxproj', - ); - expect( - _.includes(Object.keys(project.pbxFileReferenceSection()), fileRef), - ).toBeTruthy(); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/addProjectToLibraries.test.ts b/packages/platform-ios/src/link/__tests__/addProjectToLibraries.test.ts deleted file mode 100644 index e520f8026..000000000 --- a/packages/platform-ios/src/link/__tests__/addProjectToLibraries.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import addProjectToLibraries from '../addProjectToLibraries'; - -const xcode = require('xcode'); -const path = require('path'); -const PbxFile = require('xcode/lib/pbxFile'); -const {last} = require('lodash'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::addProjectToLibraries', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should append file to Libraries group', () => { - const file = new PbxFile('fakePath'); - const libraries = project.pbxGroupByName('Libraries'); - - addProjectToLibraries(libraries, file); - - const child = last(libraries.children); - - expect(child.comment).toBe(file.basename); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/addSharedLibraries.test.ts b/packages/platform-ios/src/link/__tests__/addSharedLibraries.test.ts deleted file mode 100644 index 49a14d879..000000000 --- a/packages/platform-ios/src/link/__tests__/addSharedLibraries.test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import addSharedLibraries from '../addSharedLibraries'; -import getGroup from '../getGroup'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::addSharedLibraries', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should automatically create Frameworks group', () => { - expect(getGroup(project, 'Frameworks')).toBeNull(); - addSharedLibraries(project, ['libz.tbd']); - expect(getGroup(project, 'Frameworks')).not.toBeNull(); - }); - - it('should add shared libraries to project', () => { - addSharedLibraries(project, ['libz.tbd']); - - const frameworksGroup = getGroup(project, 'Frameworks'); - expect(frameworksGroup.children).toHaveLength(1); - expect(frameworksGroup.children[0].comment).toEqual('libz.tbd'); - - addSharedLibraries(project, ['MessageUI.framework']); - expect(frameworksGroup.children).toHaveLength(2); - }); - - it('should not add duplicate libraries to project', () => { - addSharedLibraries(project, ['libz.tbd']); - addSharedLibraries(project, ['libz.tbd']); - - const frameworksGroup = getGroup(project, 'Frameworks'); - expect(frameworksGroup.children).toHaveLength(1); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/createGroup.test.ts b/packages/platform-ios/src/link/__tests__/createGroup.test.ts deleted file mode 100644 index a2d38ad06..000000000 --- a/packages/platform-ios/src/link/__tests__/createGroup.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import createGroup from '../createGroup'; -import getGroup from '../getGroup'; - -const xcode = require('xcode'); -const path = require('path'); -const {last} = require('lodash'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::createGroup', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should create a group with given name', () => { - const createdGroup = createGroup(project, 'Resources'); - expect(createdGroup.name).toBe('Resources'); - }); - - it('should attach group to main project group', () => { - const createdGroup = createGroup(project, 'Resources'); - const mainGroup = getGroup(project); - - expect(last(mainGroup.children).comment).toBe(createdGroup.name); - }); - - it('should create a nested group with given path', () => { - const createdGroup = createGroup(project, 'NewGroup/NewNestedGroup'); - const outerGroup = getGroup(project, 'NewGroup'); - - expect(last(outerGroup.children).comment).toBe(createdGroup.name); - }); - - it('should-not create already created groups', () => { - const createdGroup = createGroup(project, 'Libraries/NewNestedGroup'); - const outerGroup = getGroup(project, 'Libraries'); - const mainGroup = getGroup(project); - - expect( - mainGroup.children.filter(group => group.comment === 'Libraries'), - ).toHaveLength(1); - expect(last(outerGroup.children).comment).toBe(createdGroup.name); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/getBuildProperty.test.ts b/packages/platform-ios/src/link/__tests__/getBuildProperty.test.ts deleted file mode 100644 index 672c31bd6..000000000 --- a/packages/platform-ios/src/link/__tests__/getBuildProperty.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getBuildProperty from '../getBuildProperty'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::getBuildProperty', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should return build property from main target', () => { - const plistPath = getBuildProperty(project, 'INFOPLIST_FILE'); - expect(plistPath).toEqual('Basic/Info.plist'); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/getGroup.test.ts b/packages/platform-ios/src/link/__tests__/getGroup.test.ts deleted file mode 100644 index 9c8f0dd0f..000000000 --- a/packages/platform-ios/src/link/__tests__/getGroup.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getGroup from '../getGroup'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::getGroup', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should return a top-level group', () => { - const group = getGroup(project, 'Libraries'); - expect(group.children.length > 0).toBeTruthy(); - expect(group.name).toBe('Libraries'); - }); - - it('should return nested group when specified', () => { - const group = getGroup(project, 'NestedGroup/Libraries'); - expect(group.children).toHaveLength(0); // our test nested Libraries is empty - expect(group.name).toBe('Libraries'); - }); - - it('should return null when no group found', () => { - const group = getGroup(project, 'I-Dont-Exist'); - expect(group).toBeNull(); - }); - - it('should return top-level group when name not specified', () => { - const mainGroupId = project.getFirstProject().firstProject.mainGroup; - const mainGroup = project.getPBXGroupByKey(mainGroupId); - const group = getGroup(project); - expect(group).toEqual(mainGroup); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/getHeaderSearchPath.test.ts b/packages/platform-ios/src/link/__tests__/getHeaderSearchPath.test.ts deleted file mode 100644 index c0103da5a..000000000 --- a/packages/platform-ios/src/link/__tests__/getHeaderSearchPath.test.ts +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getHeaderSearchPath from '../getHeaderSearchPath'; -import {posix as path} from 'path'; - -const SRC_DIR = path.join('react-native-project', 'ios'); - -describe('ios::getHeaderSearchPath', () => { - /** - * See https://github.com/Microsoft/react-native-code-push - */ - it('should return correct path when all headers are in root folder', () => { - const files = [ - path.join( - 'react-native-project', - 'node_modules', - 'package', - 'Gradient.h', - ), - path.join('react-native-project', 'node_modules', 'package', 'Manager.h'), - ]; - - const searchPath = getHeaderSearchPath(SRC_DIR, files); - - expect(searchPath).toBe( - `"${['$(SRCROOT)', '..', 'node_modules', 'package'].join(path.sep)}"`, - ); - }); - - /** - * See https://github.com/facebook/react-native/tree/master/React - */ - it('should return correct path when headers are in multiple folders', () => { - const files = [ - path.join( - 'react-native-project', - 'node_modules', - 'package', - 'src', - 'folderA', - 'Gradient.h', - ), - path.join( - 'react-native-project', - 'node_modules', - 'package', - 'src', - 'folderB', - 'Manager.h', - ), - ]; - - const searchPath = getHeaderSearchPath(SRC_DIR, files); - - expect(searchPath).toBe( - `"${['$(SRCROOT)', '..', 'node_modules', 'package', 'src'].join( - path.sep, - )}/**"`, - ); - }); - - /** - * This is just to make sure the above two does not collide with each other - */ - it('should return correct path when headers are in root and nested folders', () => { - const files = [ - path.join( - 'react-native-project', - 'node_modules', - 'package', - 'src', - 'folderA', - 'Gradient.h', - ), - path.join( - 'react-native-project', - 'node_modules', - 'package', - 'src', - 'folderB', - 'Manager.h', - ), - path.join( - 'react-native-project', - 'node_modules', - 'package', - 'src', - 'Manager.h', - ), - ]; - - const searchPath = getHeaderSearchPath(SRC_DIR, files); - - expect(searchPath).toBe( - `"${['$(SRCROOT)', '..', 'node_modules', 'package', 'src'].join( - path.sep, - )}/**"`, - ); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/getHeadersInFolder.test.ts b/packages/platform-ios/src/link/__tests__/getHeadersInFolder.test.ts deleted file mode 100644 index 2b0ef8970..000000000 --- a/packages/platform-ios/src/link/__tests__/getHeadersInFolder.test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getHeadersInFolder from '../getHeadersInFolder'; - -jest.mock('fs'); -jest.mock('path'); - -const fs = require('fs'); - -const ROOT_DIR = '/'; - -describe('ios::getHeadersInFolder', () => { - it('should return an array of all headers in given folder', () => { - fs.__setMockFilesystem({ - 'FileA.h': '', - 'FileB.h': '', - }); - - const foundHeaders = getHeadersInFolder(ROOT_DIR); - - expect(foundHeaders).toHaveLength(2); - - getHeadersInFolder(process.cwd()).forEach(headerPath => { - expect(headerPath.includes(process.cwd())).toBe(true); - }); - }); - - it('should ignore all headers in Pods, Examples & node_modules', () => { - fs.__setMockFilesystem({ - 'FileA.h': '', - 'FileB.h': '', - Pods: { - 'FileC.h': '', - }, - Examples: { - 'FileD.h': '', - }, - node_modules: { - 'FileE.h': '', - }, - }); - - expect(getHeadersInFolder(ROOT_DIR)).toHaveLength(2); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/getPlist.test.ts b/packages/platform-ios/src/link/__tests__/getPlist.test.ts deleted file mode 100644 index c2ddbaa58..000000000 --- a/packages/platform-ios/src/link/__tests__/getPlist.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getPlist from '../getPlist'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::getPlist', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should return null when `.plist` file missing', () => { - const plistPath = getPlist(project, process.cwd()); - expect(plistPath).toBeNull(); - }); - - // @todo - Happy scenario -}); diff --git a/packages/platform-ios/src/link/__tests__/getPlistPath.test.ts b/packages/platform-ios/src/link/__tests__/getPlistPath.test.ts deleted file mode 100644 index 8f33048e6..000000000 --- a/packages/platform-ios/src/link/__tests__/getPlistPath.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getPlistPath from '../getPlistPath'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::getPlistPath', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should return path without Xcode $(SRCROOT)', () => { - const plistPath = getPlistPath(project, '/'); - expect(plistPath).toBe(path.normalize('/Basic/Info.plist')); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/getTargets.test.ts b/packages/platform-ios/src/link/__tests__/getTargets.test.ts deleted file mode 100644 index 547806896..000000000 --- a/packages/platform-ios/src/link/__tests__/getTargets.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getTargets from '../getTargets'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::getTargets', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should return an array of project targets', () => { - const targets = getTargets(project); - expect(targets).toHaveLength(2); - expect(targets[0].name).toContain('Basic.app'); - expect(targets[1].name).toContain('BasicTests.xctest'); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/hasLibraryImported.test.ts b/packages/platform-ios/src/link/__tests__/hasLibraryImported.test.ts deleted file mode 100644 index 6b2b2159d..000000000 --- a/packages/platform-ios/src/link/__tests__/hasLibraryImported.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import hasLibraryImported from '../hasLibraryImported'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::hasLibraryImported', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should return true if project has been already imported', () => { - const libraries = project.pbxGroupByName('Libraries'); - expect(hasLibraryImported(libraries, 'React.xcodeproj')).toBeTruthy(); - }); - - it('should return false if project is not imported', () => { - const libraries = project.pbxGroupByName('Libraries'); - expect(hasLibraryImported(libraries, 'ACME.xcodeproj')).toBeFalsy(); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/isInstalled.test.ts b/packages/platform-ios/src/link/__tests__/isInstalled.test.ts deleted file mode 100644 index 340aa3f99..000000000 --- a/packages/platform-ios/src/link/__tests__/isInstalled.test.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import isInstalled from '../isInstalled'; - -const path = require('path'); - -const baseProjectConfig = { - pbxprojPath: path.join(__dirname, '../__fixtures__/project.pbxproj'), - libraryFolder: 'Libraries', -}; - -describe('ios::isInstalled', () => { - it('should return true when .xcodeproj in Libraries', () => { - const dependencyConfig = {projectName: 'React.xcodeproj'}; - // @ts-ignore FIXME: Improve types - expect(isInstalled(baseProjectConfig, dependencyConfig)).toBeTruthy(); - }); - - it('should return false when .xcodeproj not in Libraries', () => { - const dependencyConfig = {projectName: 'Missing.xcodeproj'}; - // @ts-ignore FIXME: Improve types - expect(isInstalled(baseProjectConfig, dependencyConfig)).toBeFalsy(); - }); - - it('should return false when `LibraryFolder` is missing', () => { - const dependencyConfig = {projectName: 'React.xcodeproj'}; - const projectConfig = Object.assign({}, baseProjectConfig, { - libraryFolder: 'Missing', - }); - // @ts-ignore FIXME: Improve types - expect(isInstalled(projectConfig, dependencyConfig)).toBeFalsy(); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/mapHeaderSearchPaths.test.ts b/packages/platform-ios/src/link/__tests__/mapHeaderSearchPaths.test.ts deleted file mode 100644 index 0ced635c5..000000000 --- a/packages/platform-ios/src/link/__tests__/mapHeaderSearchPaths.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import mapHeaderSearchPaths from '../mapHeaderSearchPaths'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::mapHeaderSearchPaths', () => { - beforeEach(() => { - project.parseSync(); - }); - - /** - * Based on the fixtures, our assumption is that this function - * has to be executed two times. - */ - it('should be called twice', () => { - const callback = jest.fn(); - mapHeaderSearchPaths(project, callback); - - expect(callback.mock.calls).toHaveLength(2); - }); - - it('calls the function with an array of paths, given a project with one', () => { - const callback = jest.fn(); - mapHeaderSearchPaths(project, callback); - - const paths = callback.mock.calls[0][0]; - - expect(paths instanceof Array).toBe(true); - expect(paths).toHaveLength(1); - expect(paths[0]).toBe('"$(inherited)"'); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/removeProjectFromLibraries.test.ts b/packages/platform-ios/src/link/__tests__/removeProjectFromLibraries.test.ts deleted file mode 100644 index 3308e83a1..000000000 --- a/packages/platform-ios/src/link/__tests__/removeProjectFromLibraries.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import addProjectToLibraries from '../addProjectToLibraries'; -import removeProjectFromLibraries from '../removeProjectFromLibraries'; - -const xcode = require('xcode'); -const PbxFile = require('xcode/lib/pbxFile'); -const path = require('path'); -const {last} = require('lodash'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::removeProjectFromLibraries', () => { - beforeEach(() => { - project.parseSync(); - - addProjectToLibraries( - project.pbxGroupByName('Libraries'), - new PbxFile('fakePath'), - ); - }); - - it('should remove file from Libraries group', () => { - const file = new PbxFile('fakePath'); - const libraries = project.pbxGroupByName('Libraries'); - - removeProjectFromLibraries(libraries, file); - - const child = last(libraries.children); - - expect(child.comment).not.toBe(file.basename); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/removeProjectFromProject.test.ts b/packages/platform-ios/src/link/__tests__/removeProjectFromProject.test.ts deleted file mode 100644 index 7ea04df4f..000000000 --- a/packages/platform-ios/src/link/__tests__/removeProjectFromProject.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import addFileToProject from '../addFileToProject'; -import removeProjectFromProject from '../removeProjectFromProject'; - -const xcode = require('xcode'); -const pbxFile = require('xcode/lib/pbxFile'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); -const filePath = '../__fixtures__/linearGradient.pbxproj'; - -describe('ios::addFileToProject', () => { - beforeEach(() => { - project.parseSync(); - addFileToProject(project, filePath); - }); - - it('should return removed file', () => { - expect( - removeProjectFromProject(project, filePath) instanceof pbxFile, - ).toBeTruthy(); - }); - - it('should remove file from a project', () => { - const file = removeProjectFromProject(project, filePath); - expect(project.pbxFileReferenceSection()[file.fileRef]).not.toBeDefined(); - }); - - // todo(mike): add in .xcodeproj after Xcode modifications so we can test extra - // removals later. - it.todo('should remove file from PBXContainerProxy'); -}); diff --git a/packages/platform-ios/src/link/__tests__/removeSharedLibrary.test.ts b/packages/platform-ios/src/link/__tests__/removeSharedLibrary.test.ts deleted file mode 100644 index f48da6480..000000000 --- a/packages/platform-ios/src/link/__tests__/removeSharedLibrary.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import addSharedLibraries from '../addSharedLibraries'; -import removeSharedLibraries from '../removeSharedLibraries'; -import getGroup from '../getGroup'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::removeSharedLibraries', () => { - beforeEach(() => { - project.parseSync(); - addSharedLibraries(project, ['libc++.tbd', 'libz.tbd']); - }); - - it('should remove only the specified shared library', () => { - removeSharedLibraries(project, ['libc++.tbd']); - - const frameworksGroup = getGroup(project, 'Frameworks'); - expect(frameworksGroup.children).toHaveLength(1); - expect(frameworksGroup.children[0].comment).toEqual('libz.tbd'); - }); - - it('should ignore missing shared libraries', () => { - removeSharedLibraries(project, ['libxml2.tbd']); - - const frameworksGroup = getGroup(project, 'Frameworks'); - expect(frameworksGroup.children).toHaveLength(2); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/writePlist.test.ts b/packages/platform-ios/src/link/__tests__/writePlist.test.ts deleted file mode 100644 index 7393ee39c..000000000 --- a/packages/platform-ios/src/link/__tests__/writePlist.test.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getPlistPath from '../getPlistPath'; -import writePlist from '../writePlist'; - -jest.mock('path'); -jest.mock('fs'); -jest.mock('../getPlistPath', () => jest.fn(() => null)); - -const {readFileSync} = jest.requireActual('fs'); -const fs = require('fs'); - -const xcode = require('xcode'); - -const realPath = jest.requireActual('path'); -const projectPath = realPath.join(__dirname, '../__fixtures__/project.pbxproj'); -const infoPlistPath = realPath.join(__dirname, '../__fixtures__/Info.plist'); - -fs.readFileSync = jest.fn(() => readFileSync(projectPath).toString()); - -const {writeFileSync} = fs; -fs.writeFileSync = jest.fn(writeFileSync); - -const project = xcode.project('/Basic/project.pbxproj'); - -const plist = { - CFBundleDevelopmentRegion: 'en', - UISupportedInterfaceOrientations: ['UIInterfaceOrientationPortrait'], -}; - -describe('ios::writePlist', () => { - beforeEach(() => { - project.parseSync(); - fs.writeFileSync.mockReset(); - }); - - it('should write a `.plist` file', () => { - // @ts-ignore - getPlistPath.mockImplementation(() => '/Basic/Info.plist'); - writePlist(project, '/', plist); - const infoPlist = readFileSync(infoPlistPath).toString(); - expect(fs.writeFileSync).toHaveBeenCalledWith( - '/Basic/Info.plist', - infoPlist, - ); - }); - - it('when plistPath is null it should return null', () => { - // @ts-ignore - getPlistPath.mockImplementation(() => null); - expect(writePlist(project, '/', plist)).toBeNull(); - expect(fs.writeFileSync).not.toHaveBeenCalled(); - }); -}); diff --git a/packages/platform-ios/src/link/addFileToProject.ts b/packages/platform-ios/src/link/addFileToProject.ts deleted file mode 100644 index 6d5162c10..000000000 --- a/packages/platform-ios/src/link/addFileToProject.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import PbxFile from 'xcode/lib/pbxFile'; - -/** - * Given xcodeproj and filePath, it creates new file - * from path provided, adds it to the project - * and returns newly created instance of a file - */ -export default function addFileToProject(project: any, filePath: string) { - const file = new PbxFile(filePath); - file.uuid = project.generateUuid(); - file.fileRef = project.generateUuid(); - project.addToPbxFileReferenceSection(file); - return file; -} diff --git a/packages/platform-ios/src/link/addProjectToLibraries.ts b/packages/platform-ios/src/link/addProjectToLibraries.ts deleted file mode 100644 index 8c7af5fd8..000000000 --- a/packages/platform-ios/src/link/addProjectToLibraries.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * Given an array of xcodeproj libraries and pbxFile, - * it appends it to that group - * - * Important: That function mutates `libraries` and it's not pure. - * It's mainly due to limitations of `xcode` library. - */ -export default function addProjectToLibraries( - libraries: {children: Array<{value: string; comment: string}>}, - file: {fileRef: string; basename: string}, -) { - return libraries.children.push({ - value: file.fileRef, - comment: file.basename, - }); -} diff --git a/packages/platform-ios/src/link/addSharedLibraries.ts b/packages/platform-ios/src/link/addSharedLibraries.ts deleted file mode 100644 index 652243125..000000000 --- a/packages/platform-ios/src/link/addSharedLibraries.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import createGroupWithMessage from './createGroupWithMessage'; - -export default function addSharedLibraries( - project: any, - libraries: Array, -) { - if (!libraries.length) { - return; - } - - // Create a Frameworks group if necessary. - createGroupWithMessage(project, 'Frameworks'); - - const target = project.getFirstTarget().uuid; - - for (const name of libraries) { - project.addFramework(name, {target}); - } -} diff --git a/packages/platform-ios/src/link/addToHeaderSearchPaths.ts b/packages/platform-ios/src/link/addToHeaderSearchPaths.ts deleted file mode 100644 index 896ec3148..000000000 --- a/packages/platform-ios/src/link/addToHeaderSearchPaths.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import mapHeaderSearchPaths from './mapHeaderSearchPaths'; -import {logger} from '@react-native-community/cli-tools'; - -export default function addToHeaderSearchPaths(project: any, path: string) { - logger.debug(`Adding ${path} to header search paths`); - mapHeaderSearchPaths(project, searchPaths => searchPaths.concat(path)); -} diff --git a/packages/platform-ios/src/link/common/isInstalled.ts b/packages/platform-ios/src/link/common/isInstalled.ts deleted file mode 100644 index 9afd3c660..000000000 --- a/packages/platform-ios/src/link/common/isInstalled.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import isInstalledIOS from '../isInstalled'; -import isInstalledPods from '../../link-pods/isInstalled'; -import { - IOSProjectConfig, - IOSDependencyConfig, -} from '@react-native-community/cli-types'; - -export default function isInstalled( - projectConfig: IOSProjectConfig, - // FIXME: name is never used - _name: string | undefined, - dependencyConfig: IOSDependencyConfig, -) { - return ( - isInstalledIOS(projectConfig, dependencyConfig) || - isInstalledPods(projectConfig, dependencyConfig) - ); -} diff --git a/packages/platform-ios/src/link/common/registerNativeModule.ts b/packages/platform-ios/src/link/common/registerNativeModule.ts deleted file mode 100644 index 8b2d21b94..000000000 --- a/packages/platform-ios/src/link/common/registerNativeModule.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import { - IOSDependencyConfig, - IOSProjectConfig, -} from '@react-native-community/cli-types'; -import registerDependencyIOS from '../registerNativeModule'; -import registerDependencyPods from '../../link-pods/registerNativeModule'; - -export default function registerNativeModule( - name: string, - dependencyConfig: IOSDependencyConfig, - // FIXME: Params is never used - _params: any | undefined, - projectConfig: IOSProjectConfig, -) { - if (projectConfig.podfile && dependencyConfig.podspecPath) { - registerDependencyPods(name, dependencyConfig.podspecPath, projectConfig); - } else { - registerDependencyIOS(dependencyConfig, projectConfig); - } -} diff --git a/packages/platform-ios/src/link/common/unregisterNativeModule.ts b/packages/platform-ios/src/link/common/unregisterNativeModule.ts deleted file mode 100644 index ff2b20470..000000000 --- a/packages/platform-ios/src/link/common/unregisterNativeModule.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {compact} from 'lodash'; -import isInstalledIOS from '../isInstalled'; -import isInstalledPods from '../../link-pods/isInstalled'; -import unregisterDependencyIOS from '../unregisterNativeModule'; -import unregisterDependencyPods from '../../link-pods/unregisterNativeModule'; -import { - IOSDependencyConfig, - IOSProjectConfig, -} from '@react-native-community/cli-types'; - -export default function unregisterNativeModule( - _name: string, - dependencyConfig: IOSDependencyConfig, - projectConfig: IOSProjectConfig, - // FIXME: Add type signature here - otherDependencies: Array, -) { - const isIosInstalled = isInstalledIOS(projectConfig, dependencyConfig); - const isPodInstalled = isInstalledPods(projectConfig, dependencyConfig); - if (isIosInstalled) { - const iOSDependencies = compact( - otherDependencies.map(d => d.platforms.ios), - ); - unregisterDependencyIOS(dependencyConfig, projectConfig, iOSDependencies); - } else if (isPodInstalled) { - unregisterDependencyPods(dependencyConfig, projectConfig); - } -} diff --git a/packages/platform-ios/src/link/copyAssets.ts b/packages/platform-ios/src/link/copyAssets.ts deleted file mode 100644 index 37987bf28..000000000 --- a/packages/platform-ios/src/link/copyAssets.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import path from 'path'; -import xcode from 'xcode'; -import createGroupWithMessage from './createGroupWithMessage'; -import getPlist from './getPlist'; -import writePlist from './writePlist'; -import {logger, groupFilesByType} from '@react-native-community/cli-tools'; -import {IOSProjectConfig} from '@react-native-community/cli-types'; - -/** - * This function works in a similar manner to its Android version, - * except it does not copy fonts but creates Xcode Group references - */ -export default function linkAssetsIOS( - files: Array, - projectConfig: IOSProjectConfig, -) { - const project = xcode.project(projectConfig.pbxprojPath).parseSync(); - const assets = groupFilesByType(files); - const plist = getPlist(project, projectConfig.sourceDir); - - createGroupWithMessage(project, 'Resources'); - - function addResourceFile(f: Array) { - return (f || []) - .map(asset => { - logger.debug(`Linking asset ${asset}`); - return project.addResourceFile( - path.relative(projectConfig.sourceDir, asset), - {target: project.getFirstTarget().uuid}, - ); - }) - .filter(Boolean) // xcode returns false if file is already there - .map(file => file.basename); - } - - addResourceFile(assets.image); - - const fonts = addResourceFile(assets.font); - - // @ts-ignore Type mismatch with the lib - const existingFonts = plist.UIAppFonts || []; - const allFonts = [...existingFonts, ...fonts]; - // @ts-ignore Type mismatch with the lib - plist.UIAppFonts = Array.from(new Set(allFonts)); // use Set to dedupe w/existing - - fs.writeFileSync(projectConfig.pbxprojPath, project.writeSync()); - - writePlist(project, projectConfig.sourceDir, plist); -} diff --git a/packages/platform-ios/src/link/createGroup.ts b/packages/platform-ios/src/link/createGroup.ts deleted file mode 100644 index 44aac1faa..000000000 --- a/packages/platform-ios/src/link/createGroup.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getGroup from './getGroup'; - -const hasGroup = ( - pbxGroup: {children: Array<{comment: string}>}, - name: string, -) => pbxGroup.children.find(group => group.comment === name); - -/** - * Given project and path of the group, it deeply creates a given group - * making all outer groups if necessary - * - * Returns newly created group - */ -export default function createGroup(project: any, path: string) { - return path.split('/').reduce((group, name) => { - if (!hasGroup(group, name)) { - const uuid = project.pbxCreateGroup(name, '""'); - - group.children.push({ - value: uuid, - comment: name, - }); - } - - return project.pbxGroupByName(name); - }, getGroup(project)); -} diff --git a/packages/platform-ios/src/link/createGroupWithMessage.ts b/packages/platform-ios/src/link/createGroupWithMessage.ts deleted file mode 100644 index c569e6783..000000000 --- a/packages/platform-ios/src/link/createGroupWithMessage.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {logger} from '@react-native-community/cli-tools'; -import createGroup from './createGroup'; -import getGroup from './getGroup'; - -/** - * Given project and path of the group, it checks if a group exists at that path, - * and deeply creates a group for that path if its does not already exist. - * - * Returns the existing or newly created group - */ -export default function createGroupWithMessage(project: any, path: string) { - let group = getGroup(project, path); - - if (!group) { - group = createGroup(project, path); - - logger.warn( - `Group '${path}' does not exist in your Xcode project. We have created it automatically for you.`, - ); - } - - return group; -} diff --git a/packages/platform-ios/src/link/getBuildProperty.ts b/packages/platform-ios/src/link/getBuildProperty.ts deleted file mode 100644 index 3eb7e9c6a..000000000 --- a/packages/platform-ios/src/link/getBuildProperty.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * Gets build property from the main target build section - * - * It differs from the project.getBuildProperty exposed by xcode in the way that: - * - it only checks for build property in the main target `Debug` section - * - `xcode` library iterates over all build sections and because it misses - * an early return when property is found, it will return undefined/wrong value - * when there's another build section typically after the one you want to access - * without the property defined (e.g. CocoaPods sections appended to project - * miss INFOPLIST_FILE), see: https://github.com/alunny/node-xcode/blob/master/lib/pbxProject.js#L1765 - */ -export default function getBuildProperty(project: any, prop: string) { - const target = project.getFirstTarget().firstTarget; - const config = project.pbxXCConfigurationList()[ - target.buildConfigurationList - ]; - const buildSection = project.pbxXCBuildConfigurationSection()[ - config.buildConfigurations[0].value - ]; - - return buildSection.buildSettings[prop]; -} diff --git a/packages/platform-ios/src/link/getGroup.ts b/packages/platform-ios/src/link/getGroup.ts deleted file mode 100644 index 37acfc708..000000000 --- a/packages/platform-ios/src/link/getGroup.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -const getFirstProject = (project: any) => - project.getFirstProject().firstProject; - -const findGroup = ( - groups: {children: Array<{comment: string; value: string}>}, - name: string, -) => groups.children.find(group => group.comment === name); - -/** - * Returns group from .xcodeproj if one exists, null otherwise - * - * Unlike node-xcode `pbxGroupByName` - it does not return `first-matching` - * group if multiple groups with the same name exist - * - * If path is not provided, it returns top-level group - */ -export default function getGroup(project: any, path?: string) { - const firstProject = getFirstProject(project); - - let groups = project.getPBXGroupByKey(firstProject.mainGroup); - - if (!path) { - return groups; - } - - for (const name of path.split('/')) { - const foundGroup = findGroup(groups, name); - - if (foundGroup) { - groups = project.getPBXGroupByKey(foundGroup.value); - } else { - groups = null; - break; - } - } - - return groups; -} diff --git a/packages/platform-ios/src/link/getHeaderSearchPath.ts b/packages/platform-ios/src/link/getHeaderSearchPath.ts deleted file mode 100644 index 119450e59..000000000 --- a/packages/platform-ios/src/link/getHeaderSearchPath.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {posix as path} from 'path'; -import {last, union} from 'lodash'; - -/** - * Given an array of directories, it returns the one that contains - * all the other directories in a given array inside it. - * - * Example: - * Given an array of directories: ['/Users/Kureev/a', '/Users/Kureev/b'] - * the returned folder is `/Users/Kureev` - * - * Check `getHeaderSearchPath.spec.js` for more use-cases. - */ -const getOuterDirectory = (directories: Array) => - directories.reduce((topDir, currentDir) => { - const currentFolders = currentDir.split(path.sep); - const topMostFolders = topDir.split(path.sep); - - if ( - currentFolders.length === topMostFolders.length && - last(currentFolders) !== last(topMostFolders) - ) { - return currentFolders.slice(0, -1).join(path.sep); - } - - return currentFolders.length < topMostFolders.length ? currentDir : topDir; - }); - -/** - * Given an array of headers it returns search path so Xcode can resolve - * headers when referenced like below: - * ``` - * #import "CodePush.h" - * ``` - * If all files are located in one directory (directories.length === 1), - * we simply return a relative path to that location. - * - * Otherwise, we loop through them all to find the outer one that contains - * all the headers inside. That location is then returned with /** appended at - * the end so Xcode marks that location as `recursive` and will look inside - * every folder of it to locate correct headers. - */ -export default function getHeaderSearchPath( - sourceDir: string, - headers: Array, -) { - const directories = union(headers.map(path.dirname)); - - return directories.length === 1 - ? `"$(SRCROOT)/${path.relative(sourceDir, directories[0])}"` - : `"$(SRCROOT)/${path.relative( - sourceDir, - getOuterDirectory(directories), - )}/**"`; -} diff --git a/packages/platform-ios/src/link/getHeadersInFolder.ts b/packages/platform-ios/src/link/getHeadersInFolder.ts deleted file mode 100644 index 90bdd7a44..000000000 --- a/packages/platform-ios/src/link/getHeadersInFolder.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import glob from 'glob'; -import path from 'path'; - -const GLOB_EXCLUDE_PATTERN = [ - 'node_modules/**', - 'Pods/**', - 'Examples/**', - 'examples/**', -]; - -/** - * Given folder, it returns an array of all header files - * inside it, ignoring node_modules and examples - */ -export default function getHeadersInFolder(folder: string) { - return glob - .sync('**/*.h', { - cwd: folder, - nodir: true, - ignore: GLOB_EXCLUDE_PATTERN, - }) - .map(file => path.join(folder, file)); -} diff --git a/packages/platform-ios/src/link/getPlist.ts b/packages/platform-ios/src/link/getPlist.ts deleted file mode 100644 index f7bb3c497..000000000 --- a/packages/platform-ios/src/link/getPlist.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import plistParser from 'plist'; -import fs from 'fs'; -import getPlistPath from './getPlistPath'; - -/** - * Returns Info.plist located in the iOS project - * - * Returns `null` if INFOPLIST_FILE is not specified. - */ -export default function getPlist(project: any, sourceDir: string) { - const plistPath = getPlistPath(project, sourceDir); - - if (!plistPath || !fs.existsSync(plistPath)) { - return null; - } - - return plistParser.parse(fs.readFileSync(plistPath, 'utf-8')); -} diff --git a/packages/platform-ios/src/link/getPlistPath.ts b/packages/platform-ios/src/link/getPlistPath.ts deleted file mode 100644 index ce8cafd7d..000000000 --- a/packages/platform-ios/src/link/getPlistPath.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import path from 'path'; -import getBuildProperty from './getBuildProperty'; - -export default function getPlistPath(project: string, sourceDir: string) { - const plistFile = getBuildProperty(project, 'INFOPLIST_FILE'); - - if (!plistFile) { - return null; - } - - return path.join( - sourceDir, - plistFile.replace(/"/g, '').replace('$(SRCROOT)', ''), - ); -} diff --git a/packages/platform-ios/src/link/getTargets.ts b/packages/platform-ios/src/link/getTargets.ts deleted file mode 100644 index 784c3803d..000000000 --- a/packages/platform-ios/src/link/getTargets.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -interface Target { - value: string; -} - -/** - * Given xcodeproj it returns list of targets - */ -export default function getTargets(project: any) { - const { - firstProject: {targets}, - } = project.getFirstProject(); - const nativeTargetSection = project.pbxNativeTargetSection(); - return targets - .filter((target: Target) => nativeTargetSection[target.value] !== undefined) - .map((target: Target) => { - const key = target.value; - const configurationListId = - nativeTargetSection[key].buildConfigurationList; - const configurationList = project.pbxXCConfigurationList()[ - configurationListId - ]; - const buildConfigurationId = - configurationList.buildConfigurations[0].value; - const buildConfiguration = project.pbxXCBuildConfigurationSection()[ - buildConfigurationId - ]; - return { - uuid: key, - target: nativeTargetSection[key], - name: nativeTargetSection[key].productReference_comment, - isTVOS: - (buildConfiguration.buildSettings.SDKROOT && - buildConfiguration.buildSettings.SDKROOT.indexOf('appletv') !== - -1) || - false, - }; - }); -} diff --git a/packages/platform-ios/src/link/hasLibraryImported.ts b/packages/platform-ios/src/link/hasLibraryImported.ts deleted file mode 100644 index e99d9d72b..000000000 --- a/packages/platform-ios/src/link/hasLibraryImported.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * Given an array of libraries already imported and packageName that will be - * added, returns true or false depending on whether the library is already linked - * or not - */ -export default function hasLibraryImported( - libraries: {children: Array<{comment: string}>}, - packageName: string, -) { - return ( - libraries.children.filter(library => library.comment === packageName) - .length > 0 - ); -} diff --git a/packages/platform-ios/src/link/index.ts b/packages/platform-ios/src/link/index.ts deleted file mode 100644 index 4b38b1556..000000000 --- a/packages/platform-ios/src/link/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import isInstalled from './common/isInstalled'; -import register from './common/registerNativeModule'; -import unregister from './common/unregisterNativeModule'; -import copyAssets from './copyAssets'; -import unlinkAssets from './unlinkAssets'; - -export function getIOSLinkConfig() { - return {isInstalled, register, unregister, copyAssets, unlinkAssets}; -} - -export default getIOSLinkConfig; diff --git a/packages/platform-ios/src/link/isInstalled.ts b/packages/platform-ios/src/link/isInstalled.ts deleted file mode 100644 index 3e9ac3812..000000000 --- a/packages/platform-ios/src/link/isInstalled.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import xcode from 'xcode'; -import getGroup from './getGroup'; -import hasLibraryImported from './hasLibraryImported'; -import { - IOSProjectConfig, - IOSDependencyConfig, -} from '@react-native-community/cli-types'; - -const memo = new Map(); - -/** - * Returns true if `xcodeproj` specified by dependencyConfig is present - * in a top level `libraryFolder` - */ -export default function isInstalled( - projectConfig: IOSProjectConfig, - dependencyConfig: IOSDependencyConfig, -) { - let project; - - if (memo.has(projectConfig.pbxprojPath)) { - project = memo.get(projectConfig.pbxprojPath); - } else { - project = xcode.project(projectConfig.pbxprojPath).parseSync(); - memo.set(projectConfig.pbxprojPath, project); - } - - const libraries = getGroup(project, projectConfig.libraryFolder); - - if (!libraries) { - return false; - } - - return hasLibraryImported(libraries, dependencyConfig.projectName); -} diff --git a/packages/platform-ios/src/link/mapHeaderSearchPaths.ts b/packages/platform-ios/src/link/mapHeaderSearchPaths.ts deleted file mode 100644 index af8976fb0..000000000 --- a/packages/platform-ios/src/link/mapHeaderSearchPaths.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * Given Xcode project and path, iterate over all build configurations - * and execute func with HEADER_SEARCH_PATHS from current section - * - * We cannot use builtin addToHeaderSearchPaths method since react-native init does not - * use $(TARGET_NAME) for PRODUCT_NAME, but sets it manually so that method will skip - * that target. - * - * To workaround that issue and make it more bullet-proof for different names, - * we iterate over all configurations and look for `lc++` linker flag to detect - * React Native target. - * - * Important: That function mutates `buildSettings` and it's not pure thus you should - * not rely on its return value - */ -const defaultHeaderPaths = ['"$(inherited)"']; - -export default function headerSearchPathIter( - project: any, - func: (searchPaths: Array) => Array, -) { - const config = project.pbxXCBuildConfigurationSection(); - - Object.keys(config) - .filter(ref => ref.indexOf('_comment') === -1) - .forEach(ref => { - const {buildSettings} = config[ref]; - const shouldVisitBuildSettings = - (Array.isArray(buildSettings.OTHER_LDFLAGS) - ? buildSettings.OTHER_LDFLAGS - : [] - ).indexOf('"-lc++"') >= 0; - - if (shouldVisitBuildSettings) { - const searchPaths = buildSettings.HEADER_SEARCH_PATHS - ? [].concat(buildSettings.HEADER_SEARCH_PATHS) - : defaultHeaderPaths; - - buildSettings.HEADER_SEARCH_PATHS = func(searchPaths); - } - }); -} diff --git a/packages/platform-ios/src/link/registerNativeModule.ts b/packages/platform-ios/src/link/registerNativeModule.ts deleted file mode 100644 index e86bc56d3..000000000 --- a/packages/platform-ios/src/link/registerNativeModule.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import xcode from 'xcode'; -import fs from 'fs'; -import path from 'path'; -import {isEmpty} from 'lodash'; -import { - IOSDependencyConfig, - IOSProjectConfig, -} from '@react-native-community/cli-types'; -import addToHeaderSearchPaths from './addToHeaderSearchPaths'; -import getHeadersInFolder from './getHeadersInFolder'; -import getHeaderSearchPath from './getHeaderSearchPath'; -import getTargets from './getTargets'; -import createGroupWithMessage from './createGroupWithMessage'; -import addFileToProject from './addFileToProject'; -import addProjectToLibraries from './addProjectToLibraries'; -import addSharedLibraries from './addSharedLibraries'; -import {logger} from '@react-native-community/cli-tools'; - -/** - * Register native module IOS adds given dependency to project by adding - * its xcodeproj to project libraries as well as attaching static library - * to the first target (the main one) - * - * If library is already linked, this action is a no-op. - */ -export default function registerNativeModuleIOS( - dependencyConfig: IOSDependencyConfig, - projectConfig: IOSProjectConfig, -) { - logger.debug(`Reading ${projectConfig.pbxprojPath}`); - const project = xcode.project(projectConfig.pbxprojPath).parseSync(); - const dependencyProject = xcode - .project(dependencyConfig.pbxprojPath) - .parseSync(); - - const libraries = createGroupWithMessage( - project, - projectConfig.libraryFolder, - ); - const file = addFileToProject( - project, - path.relative(projectConfig.sourceDir, dependencyConfig.projectPath), - ); - - const targets = getTargets(project); - - addProjectToLibraries(libraries, file); - - getTargets(dependencyProject).forEach((product: any) => { - let i; - if (!product.isTVOS) { - for (i = 0; i < targets.length; i++) { - if (!targets[i].isTVOS) { - logger.debug(`Adding ${product.name} to ${targets[i].target.name}`); - project.addStaticLibrary(product.name, { - target: targets[i].uuid, - }); - } - } - } - - if (product.isTVOS) { - for (i = 0; i < targets.length; i++) { - if (targets[i].isTVOS) { - logger.debug(`Adding ${product.name} to ${targets[i].target.name}`); - project.addStaticLibrary(product.name, { - target: targets[i].uuid, - }); - } - } - } - }); - - addSharedLibraries(project, dependencyConfig.sharedLibraries); - - const headers = getHeadersInFolder(dependencyConfig.folder); - if (!isEmpty(headers)) { - addToHeaderSearchPaths( - project, - getHeaderSearchPath(projectConfig.sourceDir, headers), - ); - } - - logger.debug(`Writing changes to ${projectConfig.pbxprojPath}`); - fs.writeFileSync(projectConfig.pbxprojPath, project.writeSync()); -} diff --git a/packages/platform-ios/src/link/removeFromHeaderSearchPaths.ts b/packages/platform-ios/src/link/removeFromHeaderSearchPaths.ts deleted file mode 100644 index 27266de1f..000000000 --- a/packages/platform-ios/src/link/removeFromHeaderSearchPaths.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import mapHeaderSearchPaths from './mapHeaderSearchPaths'; -import {logger} from '@react-native-community/cli-tools'; - -/** - * Given Xcode project and absolute path, it makes sure there are no headers referring to it - */ -export default function addToHeaderSearchPaths(project: any, path: string) { - logger.debug(`Removing ${path} from header search paths`); - mapHeaderSearchPaths(project, searchPaths => - searchPaths.filter(searchPath => searchPath !== path), - ); -} diff --git a/packages/platform-ios/src/link/removeFromPbxItemContainerProxySection.ts b/packages/platform-ios/src/link/removeFromPbxItemContainerProxySection.ts deleted file mode 100644 index 6ca7e4356..000000000 --- a/packages/platform-ios/src/link/removeFromPbxItemContainerProxySection.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * For all files that are created and referenced from another `.xcodeproj` - - * a new PBXItemContainerProxy is created that contains `containerPortal` value - * which equals to xcodeproj file.uuid from PBXFileReference section. - */ -export default function removeFromPbxItemContainerProxySection( - project: any, - file: any, -) { - const section = project.hash.project.objects.PBXContainerItemProxy; - - for (const key of Object.keys(section)) { - if (section[key].containerPortal === file.uuid) { - delete section[key]; - } - } -} diff --git a/packages/platform-ios/src/link/removeFromPbxReferenceProxySection.ts b/packages/platform-ios/src/link/removeFromPbxReferenceProxySection.ts deleted file mode 100644 index 214cb98de..000000000 --- a/packages/platform-ios/src/link/removeFromPbxReferenceProxySection.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * Every file added to the project from another project is attached to - * `PBXItemContainerProxy` through `PBXReferenceProxy`. - */ -export default function removeFromPbxReferenceProxySection( - project: any, - file: any, -) { - const section = project.hash.project.objects.PBXReferenceProxy; - - for (const key of Object.keys(section)) { - if (section[key].path === file.basename) { - delete section[key]; - } - } -} diff --git a/packages/platform-ios/src/link/removeFromProjectReferences.ts b/packages/platform-ios/src/link/removeFromProjectReferences.ts deleted file mode 100644 index f2ba588e9..000000000 --- a/packages/platform-ios/src/link/removeFromProjectReferences.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * For each file (.xcodeproj), there's an entry in `projectReferences` created - * that has two entries - `ProjectRef` - reference to a file.uuid and - * `ProductGroup` - uuid of a Products group. - * - * When projectReference is found - it's deleted and the removed value is returned - * so that ProductGroup in PBXGroup section can be removed as well. - * - * Otherwise returns null - */ -export default function removeFromProjectReferences(project: any, file: any) { - const {firstProject} = project.getFirstProject(); - - const projectRef = firstProject.projectReferences.find( - (item: any) => item.ProjectRef === file.uuid, - ); - - if (!projectRef) { - return null; - } - - firstProject.projectReferences.splice( - firstProject.projectReferences.indexOf(projectRef), - 1, - ); - - return projectRef; -} diff --git a/packages/platform-ios/src/link/removeFromStaticLibraries.ts b/packages/platform-ios/src/link/removeFromStaticLibraries.ts deleted file mode 100644 index 264ec34f2..000000000 --- a/packages/platform-ios/src/link/removeFromStaticLibraries.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import PbxFile from 'xcode/lib/pbxFile'; -import removeFromPbxReferenceProxySection from './removeFromPbxReferenceProxySection'; - -/** - * Removes file from static libraries - * - * Similar to `node-xcode` addStaticLibrary - */ -export default function removeFromStaticLibraries( - project: any, - path: string, - opts: {[key: string]: any}, -) { - const file = new PbxFile(path); - - file.target = opts ? opts.target : undefined; - - project.removeFromPbxFileReferenceSection(file); - project.removeFromPbxBuildFileSection(file); - project.removeFromPbxFrameworksBuildPhase(file); - project.removeFromLibrarySearchPaths(file); - removeFromPbxReferenceProxySection(project, file); - - return file; -} diff --git a/packages/platform-ios/src/link/removeProductGroup.ts b/packages/platform-ios/src/link/removeProductGroup.ts deleted file mode 100644 index 75cfd52e5..000000000 --- a/packages/platform-ios/src/link/removeProductGroup.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export default function removeProductGroup(project: any, productGroupId: any) { - const section = project.hash.project.objects.PBXGroup; - - for (const key of Object.keys(section)) { - if (key === productGroupId) { - delete section[key]; - } - } -} diff --git a/packages/platform-ios/src/link/removeProjectFromLibraries.ts b/packages/platform-ios/src/link/removeProjectFromLibraries.ts deleted file mode 100644 index 9630c149c..000000000 --- a/packages/platform-ios/src/link/removeProjectFromLibraries.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/** - * Given an array of xcodeproj libraries and pbxFile, - * it removes it from that group by comparing basenames - * - * Important: That function mutates `libraries` and it's not pure. - * It's mainly due to limitations of `xcode` library. - */ -export default function removeProjectFromLibraries( - libraries: {children: Array<{comment: string}>}, - file: {basename: string}, -) { - libraries.children = libraries.children.filter( - library => library.comment !== file.basename, - ); -} diff --git a/packages/platform-ios/src/link/removeProjectFromProject.ts b/packages/platform-ios/src/link/removeProjectFromProject.ts deleted file mode 100644 index a22c311c1..000000000 --- a/packages/platform-ios/src/link/removeProjectFromProject.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import PbxFile from 'xcode/lib/pbxFile'; -import removeFromPbxItemContainerProxySection from './removeFromPbxItemContainerProxySection'; -import removeFromProjectReferences from './removeFromProjectReferences'; -import removeProductGroup from './removeProductGroup'; - -/** - * Given xcodeproj and filePath, it creates new file - * from path provided and removes it. That operation is required since - * underlying method requires PbxFile instance to be passed (it does not - * have to have uuid or fileRef defined since it will do equality check - * by path) - * - * Returns removed file (that one will have UUID) - */ -export default function removeProjectFromProject( - project: any, - filePath: string, -) { - const file = project.removeFromPbxFileReferenceSection(new PbxFile(filePath)); - const projectRef = removeFromProjectReferences(project, file); - - if (projectRef) { - removeProductGroup(project, projectRef.ProductGroup); - } - - removeFromPbxItemContainerProxySection(project, file); - - return file; -} diff --git a/packages/platform-ios/src/link/removeSharedLibraries.ts b/packages/platform-ios/src/link/removeSharedLibraries.ts deleted file mode 100644 index 540f2cf35..000000000 --- a/packages/platform-ios/src/link/removeSharedLibraries.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export default function removeSharedLibraries( - project: any, - libraries: Array, -) { - if (!libraries.length) { - return; - } - - const target = project.getFirstTarget().uuid; - - for (const name of libraries) { - project.removeFramework(name, {target}); - } -} diff --git a/packages/platform-ios/src/link/unlinkAssets.ts b/packages/platform-ios/src/link/unlinkAssets.ts deleted file mode 100644 index 55323baf3..000000000 --- a/packages/platform-ios/src/link/unlinkAssets.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import path from 'path'; -import xcode from 'xcode'; -import {difference} from 'lodash'; - -import getPlist from './getPlist'; -import writePlist from './writePlist'; -import {logger, groupFilesByType} from '@react-native-community/cli-tools'; -import {IOSProjectConfig} from '@react-native-community/cli-types'; - -/** - * Unlinks assets from iOS project. Removes references for fonts from `Info.plist` - * fonts provided by application and from `Resources` group - */ -export default function unlinkAssetsIOS( - files: any, - projectConfig: IOSProjectConfig, -) { - const project = xcode.project(projectConfig.pbxprojPath).parseSync(); - const assets = groupFilesByType(files); - const plist = getPlist(project, projectConfig.sourceDir); - - if (!plist) { - logger.error( - 'Could not locate "Info.plist" file. Check if your project has "INFOPLIST_FILE" set properly', - ); - return; - } - - if (!project.pbxGroupByName('Resources')) { - logger.error( - 'Group "Resources" does not exist in your Xcode project. There is nothing to unlink.', - ); - return; - } - - const removeResourceFiles = (f: Array = []) => - (f || []) - .map(asset => { - logger.debug(`Unlinking asset ${asset}`); - return project.removeResourceFile( - path.relative(projectConfig.sourceDir, asset), - {target: project.getFirstTarget().uuid}, - ); - }) - .map(file => file.basename); - - removeResourceFiles(assets.image); - - const fonts = removeResourceFiles(assets.font); - - // @ts-ignore Type mismatch - plist.UIAppFonts = difference(plist.UIAppFonts || [], fonts); - - fs.writeFileSync(projectConfig.pbxprojPath, project.writeSync()); - - writePlist(project, projectConfig.sourceDir, plist); -} diff --git a/packages/platform-ios/src/link/unregisterNativeModule.ts b/packages/platform-ios/src/link/unregisterNativeModule.ts deleted file mode 100644 index 57192354f..000000000 --- a/packages/platform-ios/src/link/unregisterNativeModule.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import xcode from 'xcode'; -import path from 'path'; -import fs from 'fs'; -import {difference, isEmpty} from 'lodash'; - -import getGroup from './getGroup'; -import getTargets from './getTargets'; -import getHeadersInFolder from './getHeadersInFolder'; -import getHeaderSearchPath from './getHeaderSearchPath'; -import removeProjectFromProject from './removeProjectFromProject'; -import removeProjectFromLibraries from './removeProjectFromLibraries'; -import removeFromStaticLibraries from './removeFromStaticLibraries'; -import removeFromHeaderSearchPaths from './removeFromHeaderSearchPaths'; -import removeSharedLibraries from './removeSharedLibraries'; -import {logger} from '@react-native-community/cli-tools'; -import { - IOSDependencyConfig, - IOSProjectConfig, - IOSProjectParams, -} from '@react-native-community/cli-types'; - -/** - * Unregister native module IOS - * - * If library is already unlinked, this action is a no-op. - */ -export default function unregisterNativeModule( - dependencyConfig: IOSDependencyConfig, - projectConfig: IOSProjectConfig, - iOSDependencies: Array, -) { - logger.debug(`Reading ${projectConfig.pbxprojPath}`); - const project = xcode.project(projectConfig.pbxprojPath).parseSync(); - const dependencyProject = xcode - .project(dependencyConfig.pbxprojPath) - .parseSync(); - - const libraries = getGroup(project, projectConfig.libraryFolder); - - const file = removeProjectFromProject( - project, - path.relative(projectConfig.sourceDir, dependencyConfig.projectPath), - ); - - removeProjectFromLibraries(libraries, file); - - getTargets(dependencyProject).forEach((target: any) => { - logger.debug( - `Removing ${target.name} from ${ - project.getFirstTarget().firstTarget.name - }`, - ); - removeFromStaticLibraries(project, target.name, { - target: project.getFirstTarget().uuid, - }); - }); - - const sharedLibraries = difference( - dependencyConfig.sharedLibraries, - iOSDependencies.reduce( - (libs, dependency) => libs.concat(dependency.sharedLibraries), - projectConfig.sharedLibraries, - ), - ); - - removeSharedLibraries(project, sharedLibraries); - - const headers = getHeadersInFolder(dependencyConfig.folder); - if (!isEmpty(headers)) { - removeFromHeaderSearchPaths( - project, - getHeaderSearchPath(projectConfig.sourceDir, headers), - ); - } - - logger.debug(`Writing changes to ${projectConfig.pbxprojPath}`); - fs.writeFileSync(projectConfig.pbxprojPath, project.writeSync()); -} diff --git a/packages/platform-ios/src/link/warnAboutManuallyLinkedLibs.ts b/packages/platform-ios/src/link/warnAboutManuallyLinkedLibs.ts deleted file mode 100644 index ce3cac2cf..000000000 --- a/packages/platform-ios/src/link/warnAboutManuallyLinkedLibs.ts +++ /dev/null @@ -1,53 +0,0 @@ -import chalk from 'chalk'; -import {logger} from '@react-native-community/cli-tools'; -import {Config} from '@react-native-community/cli-types'; -import getLinkConfig from './index'; - -// TODO: move to cli-tools once platform-ios and platform-android are migrated -// to TS and unify with Android implementation -export default function warnAboutManuallyLinkedLibs( - config: Config, - platform: string = 'ios', - linkConfig: ReturnType< - Config['platforms']['ios']['linkConfig'] - > = getLinkConfig(), -) { - let deps: Array = []; - - for (let key in config.dependencies) { - const dependency = config.dependencies[key]; - try { - const projectConfig = config.project[platform]; - const dependencyConfig = dependency.platforms[platform]; - if (projectConfig && dependencyConfig) { - const x = linkConfig.isInstalled( - projectConfig, - dependency.name, - dependencyConfig, - ); - deps = deps.concat(x ? dependency.name : []); - } - } catch (error) { - logger.debug('Checking manually linked modules failed.', error); - } - } - - const installedModules = [...new Set(deps)]; - - if (installedModules.length) { - logger.error( - `React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: \n${installedModules - .map( - x => - ` - ${chalk.bold(x)} ${chalk.dim( - `(to unlink run: "react-native unlink ${x}")`, - )}`, - ) - .join( - '\n', - )}\nThis is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink " and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.\nRead more about autolinking: ${chalk.dim.underline( - 'https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', - )}`, - ); - } -} diff --git a/packages/platform-ios/src/link/writePlist.ts b/packages/platform-ios/src/link/writePlist.ts deleted file mode 100644 index 52b002d55..000000000 --- a/packages/platform-ios/src/link/writePlist.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import plistParser, {PlistValue} from 'plist'; -import fs from 'fs'; -import getPlistPath from './getPlistPath'; - -/** - * Writes to Info.plist located in the iOS project - * - * Returns `null` if INFOPLIST_FILE is not specified or file is non-existent. - */ -export default function writePlist( - project: any, - sourceDir: string, - plist: PlistValue | null, -) { - const plistPath = getPlistPath(project, sourceDir); - - if (!plistPath) { - return null; - } - - // We start with an offset of -1, because Xcode maintains a custom - // indentation of the plist. - // Ref: https://github.com/facebook/react-native/issues/11668 - return fs.writeFileSync( - plistPath, - // @ts-ignore Type mismatch - `${plistParser.build(plist, {indent: '\t', offset: -1})}\n`, - ); -}