Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy non-font assets as well [iOS] #84

Merged
merged 3 commits into from
May 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/ios/copyAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const getPlistPath = require('./getPlistPath');
*/
module.exports = function linkAssetsIOS(files, projectConfig) {
const project = xcode.project(projectConfig.pbxprojPath).parseSync();
const assets = groupFilesByType(files);
const plist = getPlist(project, projectConfig.sourceDir);

if (!plist) {
Expand All @@ -33,7 +32,7 @@ module.exports = function linkAssetsIOS(files, projectConfig) {
);
}

const fonts = (assets.font || [])
const assets = files
.map(asset =>
project.addResourceFile(
path.relative(projectConfig.sourceDir, asset),
Expand All @@ -43,7 +42,9 @@ module.exports = function linkAssetsIOS(files, projectConfig) {
.filter(file => file) // xcode returns false if file is already there
.map(file => file.basename);

plist.UIAppFonts = (plist.UIAppFonts || []).concat(fonts);
const assetsByType = groupFilesByType(assets);

plist.UIAppFonts = (plist.UIAppFonts || []).concat(assetsByType.font || []);

fs.writeFileSync(
projectConfig.pbxprojPath,
Expand Down
7 changes: 4 additions & 3 deletions src/ios/unlinkAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const difference = require('lodash').difference;
*/
module.exports = function unlinkAssetsIOS(files, projectConfig) {
const project = xcode.project(projectConfig.pbxprojPath).parseSync();
const assets = groupFilesByType(files);
const plist = getPlist(project, projectConfig.sourceDir);

if (!plist) {
Expand All @@ -31,7 +30,7 @@ module.exports = function unlinkAssetsIOS(files, projectConfig) {
);
}

const fonts = (assets.font || [])
const assets = files
.map(asset =>
project.removeResourceFile(
path.relative(projectConfig.sourceDir, asset),
Expand All @@ -40,7 +39,9 @@ module.exports = function unlinkAssetsIOS(files, projectConfig) {
)
.map(file => file.basename);

plist.UIAppFonts = difference(plist.UIAppFonts || [], fonts);
const assetsByType = groupFilesByType(assets);

plist.UIAppFonts = difference(plist.UIAppFonts || [], assetsByType.font);

fs.writeFileSync(
projectConfig.pbxprojPath,
Expand Down