mirror of
https://github.com/status-im/react-native.git
synced 2025-02-23 22:58:19 +00:00
Summary: Fixes lots of ESLint warnings. Many of them where in PR #20877 by janicduplessis which requested to split the linting fixes from configuration and package changes. I solved only the issues that I was most certain about but I would love to get hands on all of them with a little bit of input. Pull Request resolved: https://github.com/facebook/react-native/pull/22062 Differential Revision: D12889447 Pulled By: TheSavior fbshipit-source-id: 35f7a08104a5b859c860afdde4af2b32c0685c50
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
/**
|
|
* 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.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
const fs = require('fs-extra');
|
|
const path = require('path');
|
|
const xcode = require('xcode');
|
|
const groupFilesByType = require('../groupFilesByType');
|
|
const createGroupWithMessage = require('./createGroupWithMessage');
|
|
const getPlist = require('./getPlist');
|
|
const writePlist = require('./writePlist');
|
|
|
|
/**
|
|
* This function works in a similar manner to its Android version,
|
|
* except it does not copy fonts but creates Xcode Group references
|
|
*/
|
|
module.exports = function linkAssetsIOS(files, projectConfig) {
|
|
const project = xcode.project(projectConfig.pbxprojPath).parseSync();
|
|
const assets = groupFilesByType(files);
|
|
const plist = getPlist(project, projectConfig.sourceDir);
|
|
|
|
createGroupWithMessage(project, 'Resources');
|
|
|
|
function addResourceFile(f) {
|
|
return (f || [])
|
|
.map(asset =>
|
|
project.addResourceFile(path.relative(projectConfig.sourceDir, asset), {
|
|
target: project.getFirstTarget().uuid,
|
|
}),
|
|
)
|
|
.filter(file => file) // xcode returns false if file is already there
|
|
.map(file => file.basename);
|
|
}
|
|
|
|
addResourceFile(assets.image);
|
|
|
|
const fonts = addResourceFile(assets.font);
|
|
|
|
const existingFonts = plist.UIAppFonts || [];
|
|
const allFonts = [...existingFonts, ...fonts];
|
|
plist.UIAppFonts = Array.from(new Set(allFonts)); // use Set to dedupe w/existing
|
|
|
|
fs.writeFileSync(projectConfig.pbxprojPath, project.writeSync());
|
|
|
|
writePlist(project, projectConfig.sourceDir, plist);
|
|
};
|