mirror of
https://github.com/status-im/react-native.git
synced 2025-01-17 04:50:59 +00:00
74146cb315
Summary: The core React Native codebase already has full support for CocoaPods. However, `react-native link` doesn’t play nicely with CocoaPods, so installing third-party libs from the RN ecosystem is really hard. This change will allow to link projects that contains its own `.podspec` file to CocoaPods-based projects. In case `link` detect `Podfile` in `iOS` directory, it will look for related `.podspec` file in linked project directory, and add it to `Podfile`. If `Podfile` and `.podspec` files are not present, it will fall back to previous implementation. **Test Plan** 1. Build a React Native project where the iOS part uses CocoaPods to manage its dependencies. The most common scenario here is to have React Native be a Pod dependency, among others. 2. Install a RN-related library, that contains `.podspec` file, with `react-native link` (as an example it could be: [react-native-maps](https://github.com/airbnb/react-native-maps) 3. Building the resulting iOS workspace should succeed (and there should be new entry in `Podfile`) Closes https://github.com/facebook/react-native/pull/15460 Differential Revision: D6078649 Pulled By: hramos fbshipit-source-id: 9651085875892fd66299563ca0e42fb2bcc00825
60 lines
1.7 KiB
JavaScript
60 lines
1.7 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
'use strict';
|
|
|
|
const findProject = require('./findProject');
|
|
const findPodfilePath = require('./findPodfilePath');
|
|
const findPodspecName = require('./findPodspecName');
|
|
const path = require('path');
|
|
|
|
/**
|
|
* For libraries specified without an extension, add '.tbd' for those that
|
|
* start with 'lib' and '.framework' to the rest.
|
|
*/
|
|
const mapSharedLibaries = (libraries) => {
|
|
return libraries.map(name => {
|
|
if (path.extname(name)) {
|
|
return name;
|
|
}
|
|
return name + (name.indexOf('lib') === 0 ? '.tbd' : '.framework');
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Returns project config by analyzing given folder and applying some user defaults
|
|
* when constructing final object
|
|
*/
|
|
exports.projectConfig = function projectConfigIOS(folder, userConfig) {
|
|
const project = userConfig.project || findProject(folder);
|
|
|
|
/**
|
|
* No iOS config found here
|
|
*/
|
|
if (!project) {
|
|
return null;
|
|
}
|
|
|
|
const projectPath = path.join(folder, project);
|
|
|
|
return {
|
|
sourceDir: path.dirname(projectPath),
|
|
folder: folder,
|
|
pbxprojPath: path.join(projectPath, 'project.pbxproj'),
|
|
podfile: findPodfilePath(projectPath),
|
|
podspec: findPodspecName(folder),
|
|
projectPath: projectPath,
|
|
projectName: path.basename(projectPath),
|
|
libraryFolder: userConfig.libraryFolder || 'Libraries',
|
|
sharedLibraries: mapSharedLibaries(userConfig.sharedLibraries || []),
|
|
plist: userConfig.plist || [],
|
|
};
|
|
};
|
|
|
|
exports.dependencyConfig = exports.projectConfig;
|