Skip to content

Commit

Permalink
Fix case when Libraries group is missing or custom provided does not …
Browse files Browse the repository at this point in the history
…exist
  • Loading branch information
grabbou committed Feb 28, 2016
1 parent 1ff232c commit 5964386
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/ios/registerNativeModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const addToHeaderSearchPaths = require('./addToHeaderSearchPaths');
const getHeadersInFolder = require('./getHeadersInFolder');
const getHeaderSearchPath = require('./getHeaderSearchPath');
const getProducts = require('./getProducts');
const createGroup = require('./createGroup');
const hasLibraryImported = require('./hasLibraryImported');
const addFileToProject = require('./addFileToProject');
const addProjectToLibraries = require('./addProjectToLibraries');
Expand All @@ -23,10 +24,19 @@ module.exports = function registerNativeModuleIOS(dependencyConfig, projectConfi
const dependencyProject = xcode.project(dependencyConfig.pbxprojPath).parseSync();

const libraries = project.pbxGroupByName(projectConfig.libraryFolder);
if (hasLibraryImported(libraries, dependencyConfig.projectName)) {
if (libraries && hasLibraryImported(libraries, dependencyConfig.projectName)) {
return false;
}

if (!libraries) {
createGroup(project, projectConfig.libraryFolder);

log.warn(
'ERRGROUP',
`Group ${projectConfig.libraryFolder} does not exist in your XCode project. We have created it automatically for you.`
);
}

const file = addFileToProject(
project,
path.relative(projectConfig.sourceDir, dependencyConfig.projectPath)
Expand Down
2 changes: 1 addition & 1 deletion src/ios/unregisterNativeModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function unregisterNativeModule(dependencyConfig, projectConfig
const dependencyProject = xcode.project(dependencyConfig.pbxprojPath).parseSync();

const libraries = project.pbxGroupByName(projectConfig.libraryFolder);
if (!hasLibraryImported(libraries, dependencyConfig.projectName)) {
if (!libraries || !hasLibraryImported(libraries, dependencyConfig.projectName)) {
return false;
}

Expand Down

0 comments on commit 5964386

Please sign in to comment.