diff --git a/lib/constants.js b/lib/constants.js new file mode 100644 index 0000000..e5c3155 --- /dev/null +++ b/lib/constants.js @@ -0,0 +1,135 @@ +var DEFAULT_SOURCETREE = '""', + DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR', + DEFAULT_FILEENCODING = 4, + DEFAULT_GROUP = 'Resources', + DEFAULT_FILETYPE = 'unknown', + HEADER_FILE_TYPE_SUFFIX = ".h", + ENTITLEMENTS_FILE_TYPE_SUFFIX = ".entitlements", + SOURCE_CODE_FILE_TYPE_PREFIX = "sourcecode."; + +var FILETYPE_BY_EXTENSION = { + a: 'archive.ar', + app: 'wrapper.application', + appex: 'wrapper.app-extension', + bundle: 'wrapper.plug-in', + c: 'sourcecode.c.c', + cc: 'sourcecode.cpp.cpp', + cpp: 'sourcecode.cpp.cpp', + cxx: 'sourcecode.cpp.cpp', + 'c++': 'sourcecode.cpp.cpp', + dylib: 'compiled.mach-o.dylib', + framework: 'wrapper.framework', + h: 'sourcecode.c.h', + hh: 'sourcecode.cpp.h', + hpp: 'sourcecode.cpp.h', + hxx: 'sourcecode.cpp.h', + 'h++': 'sourcecode.cpp.h', + m: 'sourcecode.c.objc', + mm: 'sourcecode.cpp.objcpp', + markdown: 'text', + mdimporter: 'wrapper.cfbundle', + octest: 'wrapper.cfbundle', + pch: 'sourcecode.c.h', + plist: 'text.plist.xml', + entitlements: 'text.plist.entitlements', + png: "image.png", + sh: 'text.script.sh', + swift: 'sourcecode.swift', + tbd: 'sourcecode.text-based-dylib-definition', + xcassets: 'folder.assetcatalog', + xcconfig: 'text.xcconfig', + xcdatamodel: 'wrapper.xcdatamodel', + xcodeproj: 'wrapper.pb-project', + xctest: 'wrapper.cfbundle', + xib: 'file.xib', + strings: 'text.plist.strings' + }, + GROUP_BY_FILETYPE = { + 'archive.ar': 'Frameworks', + 'compiled.mach-o.dylib': 'Frameworks', + 'sourcecode.text-based-dylib-definition': 'Frameworks', + 'wrapper.framework': 'Frameworks', + 'embedded.framework': 'Embed Frameworks', + 'sourcecode.c.h': 'Resources', + 'sourcecode.c.c': 'Sources', + 'sourcecode.c.objc': 'Sources', + 'sourcecode.swift': 'Sources', + 'sourcecode.cpp.cpp': 'Sources', + 'sourcecode.cpp.objcpp': 'Sources' + }, + PATH_BY_FILETYPE = { + 'compiled.mach-o.dylib': 'usr/lib/', + 'sourcecode.text-based-dylib-definition': 'usr/lib/', + 'wrapper.framework': 'System/Library/Frameworks/' + }, + SOURCETREE_BY_FILETYPE = { + 'compiled.mach-o.dylib': 'SDKROOT', + 'sourcecode.text-based-dylib-definition': 'SDKROOT', + 'wrapper.framework': 'SDKROOT' + }, + ENCODING_BY_FILETYPE = { + 'sourcecode.c.h': 4, + 'sourcecode.c.h': 4, + 'sourcecode.cpp.h': 4, + 'sourcecode.c.c': 4, + 'sourcecode.c.objc': 4, + 'sourcecode.cpp.cpp': 4, + 'sourcecode.cpp.objcpp': 4, + 'sourcecode.swift': 4, + 'text': 4, + 'text.plist.xml': 4, + 'text.script.sh': 4, + 'text.xcconfig': 4, + 'text.plist.strings': 4 + }; + +function isHeaderFileType(fileType) { + return fileType.endsWith(HEADER_FILE_TYPE_SUFFIX); +} + +function isSourceFileType(fileType) { + return fileType.startsWith(SOURCE_CODE_FILE_TYPE_PREFIX) && !isHeaderFileType(fileType); +} + +function isAssetFileType(fileType) { + return fileType === FILETYPE_BY_EXTENSION.xcassets; +} + +function isResource(group) { + return group === "Resources"; +} + +function isEntitlementFileType(fileType) { + return fileType.endsWith(ENTITLEMENTS_FILE_TYPE_SUFFIX); +} + +function isPlistFileType(fileType) { + return fileType === FILETYPE_BY_EXTENSION.plist; +} + +function unquoted(text) { + return text == null ? '' : text.replace (/(^")|("$)/g, '') +} + +module.exports = { + DEFAULT_SOURCETREE, + DEFAULT_PRODUCT_SOURCETREE, + DEFAULT_FILEENCODING, + DEFAULT_GROUP, + DEFAULT_FILETYPE, + HEADER_FILE_TYPE_SUFFIX, + ENTITLEMENTS_FILE_TYPE_SUFFIX, + SOURCE_CODE_FILE_TYPE_PREFIX, + FILETYPE_BY_EXTENSION, + GROUP_BY_FILETYPE, + PATH_BY_FILETYPE, + SOURCETREE_BY_FILETYPE, + ENCODING_BY_FILETYPE, + isHeaderFileType, + isSourceFileType, + isAssetFileType, + isResource, + isEntitlementFileType, + isPlistFileType, + unquoted +} \ No newline at end of file diff --git a/lib/pbxFile.js b/lib/pbxFile.js index fa0fb68..1b52d25 100644 --- a/lib/pbxFile.js +++ b/lib/pbxFile.js @@ -16,116 +16,24 @@ */ var path = require('path'), - util = require('util'); - -var DEFAULT_SOURCETREE = '""', - DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR', - DEFAULT_FILEENCODING = 4, - DEFAULT_GROUP = 'Resources', - DEFAULT_FILETYPE = 'unknown', - HEADER_FILE_TYPE_SUFFIX = ".h", - SOURCE_CODE_FILE_TYPE_PREFIX = "sourcecode."; - -var FILETYPE_BY_EXTENSION = { - a: 'archive.ar', - app: 'wrapper.application', - appex: 'wrapper.app-extension', - bundle: 'wrapper.plug-in', - c: 'sourcecode.c.c', - cc: 'sourcecode.cpp.cpp', - cpp: 'sourcecode.cpp.cpp', - cxx: 'sourcecode.cpp.cpp', - 'c++': 'sourcecode.cpp.cpp', - dylib: 'compiled.mach-o.dylib', - framework: 'wrapper.framework', - h: 'sourcecode.c.h', - hh: 'sourcecode.cpp.h', - hpp: 'sourcecode.cpp.h', - hxx: 'sourcecode.cpp.h', - 'h++': 'sourcecode.cpp.h', - m: 'sourcecode.c.objc', - mm: 'sourcecode.cpp.objcpp', - markdown: 'text', - mdimporter: 'wrapper.cfbundle', - octest: 'wrapper.cfbundle', - pch: 'sourcecode.c.h', - plist: 'text.plist.xml', - png: "image.png", - sh: 'text.script.sh', - swift: 'sourcecode.swift', - tbd: 'sourcecode.text-based-dylib-definition', - xcassets: 'folder.assetcatalog', - xcconfig: 'text.xcconfig', - xcdatamodel: 'wrapper.xcdatamodel', - xcodeproj: 'wrapper.pb-project', - xctest: 'wrapper.cfbundle', - xib: 'file.xib', - strings: 'text.plist.strings' - }, - GROUP_BY_FILETYPE = { - 'archive.ar': 'Frameworks', - 'compiled.mach-o.dylib': 'Frameworks', - 'sourcecode.text-based-dylib-definition': 'Frameworks', - 'wrapper.framework': 'Frameworks', - 'embedded.framework': 'Embed Frameworks', - 'sourcecode.c.h': 'Resources', - 'sourcecode.c.c': 'Sources', - 'sourcecode.c.objc': 'Sources', - 'sourcecode.swift': 'Sources', - 'sourcecode.cpp.cpp': 'Sources', - 'sourcecode.cpp.objcpp': 'Sources' - }, - PATH_BY_FILETYPE = { - 'compiled.mach-o.dylib': 'usr/lib/', - 'sourcecode.text-based-dylib-definition': 'usr/lib/', - 'wrapper.framework': 'System/Library/Frameworks/' - }, - SOURCETREE_BY_FILETYPE = { - 'compiled.mach-o.dylib': 'SDKROOT', - 'sourcecode.text-based-dylib-definition': 'SDKROOT', - 'wrapper.framework': 'SDKROOT' - }, - ENCODING_BY_FILETYPE = { - 'sourcecode.c.h': 4, - 'sourcecode.c.h': 4, - 'sourcecode.cpp.h': 4, - 'sourcecode.c.c': 4, - 'sourcecode.c.objc': 4, - 'sourcecode.cpp.cpp': 4, - 'sourcecode.cpp.objcpp': 4, - 'sourcecode.swift': 4, - 'text': 4, - 'text.plist.xml': 4, - 'text.script.sh': 4, - 'text.xcconfig': 4, - 'text.plist.strings': 4 - }; - -function isSourceOrHeaderFileType(fileType) { - return fileType.startsWith(SOURCE_CODE_FILE_TYPE_PREFIX); -} - -function isHeaderFileType(fileType) { - return fileType.endsWith(HEADER_FILE_TYPE_SUFFIX); -} - -function unquoted(text){ - return text == null ? '' : text.replace (/(^")|("$)/g, '') -} + util = require('util'), + constants = require('./constants'), + unquoted = constants.unquoted, + FILETYPE_BY_EXTENSION = constants.FILETYPE_BY_EXTENSION; function detectType(filePath) { var extension = path.extname(filePath).substring(1), filetype = FILETYPE_BY_EXTENSION[unquoted(extension)]; if (!filetype) { - return DEFAULT_FILETYPE; + return constants.DEFAULT_FILETYPE; } return filetype; } function defaultExtension(fileRef) { - var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != DEFAULT_FILETYPE ? + var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != constants.DEFAULT_FILETYPE ? fileRef.lastKnownFileType : fileRef.explicitFileType; for(var extension in FILETYPE_BY_EXTENSION) { @@ -138,7 +46,7 @@ function defaultExtension(fileRef) { function defaultEncoding(fileRef) { var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, - encoding = ENCODING_BY_FILETYPE[unquoted(filetype)]; + encoding = constants.ENCODING_BY_FILETYPE[unquoted(filetype)]; if (encoding) { return encoding; @@ -148,18 +56,18 @@ function defaultEncoding(fileRef) { function detectGroup(fileRef, opt) { var extension = path.extname(fileRef.basename).substring(1), filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, - groupName = GROUP_BY_FILETYPE[unquoted(filetype)]; + groupName = constants.GROUP_BY_FILETYPE[unquoted(filetype)]; if (extension === 'xcdatamodeld') { return 'Sources'; } if (opt.customFramework && opt.embed) { - return GROUP_BY_FILETYPE['embedded.framework']; + return constants.GROUP_BY_FILETYPE['embedded.framework']; } if (!groupName) { - return DEFAULT_GROUP; + return constants.DEFAULT_GROUP; } return groupName; @@ -168,18 +76,18 @@ function detectGroup(fileRef, opt) { function detectSourcetree(fileRef) { var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, - sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)]; + sourcetree = constants.SOURCETREE_BY_FILETYPE[unquoted(filetype)]; if (fileRef.explicitFileType) { - return DEFAULT_PRODUCT_SOURCETREE; + return constants.DEFAULT_PRODUCT_SOURCETREE; } if (fileRef.customFramework) { - return DEFAULT_SOURCETREE; + return constants.DEFAULT_SOURCETREE; } if (!sourcetree) { - return DEFAULT_SOURCETREE; + return constants.DEFAULT_SOURCETREE; } return sourcetree; @@ -187,7 +95,7 @@ function detectSourcetree(fileRef) { function defaultPath(fileRef, filePath) { var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, - defaultPath = PATH_BY_FILETYPE[unquoted(filetype)]; + defaultPath = constants.PATH_BY_FILETYPE[unquoted(filetype)]; if (fileRef.customFramework) { return filePath; @@ -200,18 +108,8 @@ function defaultPath(fileRef, filePath) { return filePath; } -function defaultGroup(fileRef) { - var groupName = GROUP_BY_FILETYPE[fileRef.lastKnownFileType]; - - if (!groupName) { - return DEFAULT_GROUP; - } - - return defaultGroup; -} - function pbxFile(filepath, opt) { - var opt = opt || {}; + opt = opt || {}; this.basename = opt.basename || path.basename(filepath); this.lastKnownFileType = opt.lastKnownFileType || detectType(filepath); @@ -257,8 +155,4 @@ function pbxFile(filepath, opt) { } } -module.exports = { - pbxFile: pbxFile, - isSourceOrHeaderFileType, - isHeaderFileType -} +module.exports = pbxFile; \ No newline at end of file diff --git a/lib/pbxProject.js b/lib/pbxProject.js index 793c01c..d08c55a 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -19,17 +19,22 @@ var util = require('util'), f = util.format, EventEmitter = require('events').EventEmitter, $path = require('path'), - uuid = require('uuid'), + $uuid = require('uuid'), fork = require('child_process').fork, pbxWriter = require('./pbxWriter'), - pbxFile = require('./pbxFile').pbxFile, - isSourceOrHeaderFileType = require('./pbxFile').isSourceOrHeaderFileType, - isHeaderFileType = require('./pbxFile').isHeaderFileType, + pbxFile = require('./pbxFile'), + constants = require('./constants'), fs = require('fs'), parser = require('./parser/pbxproj'), plist = require('simple-plist'), COMMENT_KEY = /_comment$/, - NO_SPECIAL_SYMBOLS = /^[a-zA-Z0-9_\.\$]+\.[a-zA-Z]+$/; + NO_SPECIAL_SYMBOLS = /^[a-zA-Z0-9_\.\$]+\.[a-zA-Z]+$/, + isSourceFileType = constants.isSourceFileType, + isHeaderFileType = constants.isHeaderFileType, + isResource = constants.isResource, + isEntitlementFileType = constants.isEntitlementFileType, + isAssetFileType = constants.isAssetFileType, + isPlistFileType = constants.isPlistFileType; function pbxProject(filename) { if (!(this instanceof pbxProject)) @@ -77,7 +82,7 @@ pbxProject.prototype.allUuids = function() { uuids = [], section; - for (key in sections) { + for (var key in sections) { section = sections[key] uuids = uuids.concat(Object.keys(section)) } @@ -90,7 +95,7 @@ pbxProject.prototype.allUuids = function() { } pbxProject.prototype.generateUuid = function() { - var id = uuid.v4() + var id = $uuid.v4() .replace(/-/g, '') .substr(0, 24) .toUpperCase() @@ -436,7 +441,7 @@ pbxProject.prototype.removeCopyfile = function(fpath, opt) { pbxProject.prototype.removeFromPbxCopyfilesBuildPhase = function(file) { var sources = this.pbxCopyfilesBuildPhaseObj(file.target); - for (i in sources.files) { + for (var i in sources.files) { if (sources.files[i].comment == longComment(file)) { sources.files.splice(i, 1); break; @@ -481,19 +486,21 @@ pbxProject.prototype.addToPbxBuildFileSection = function(file) { } pbxProject.prototype.removeFromPbxBuildFileSection = function(file) { - var uuid; - - for (uuid in this.pbxBuildFileSection()) { - if (this.pbxBuildFileSection()[uuid].fileRef_comment == file.basename) { - file.uuid = uuid; - delete this.pbxBuildFileSection()[uuid]; + var fileUuid; - var commentKey = f("%s_comment", uuid); - delete this.pbxBuildFileSection()[commentKey]; + for (fileUuid in this.pbxBuildFileSection()) { + if (this.pbxBuildFileSection()[fileUuid].fileRef_comment == file.basename) { + file.uuid = fileUuid; + this.removeFromPbxBuildFileSectionByUuid(fileUuid); } } } +pbxProject.prototype.removeFromPbxBuildFileSectionByUuid = function(itemUuid) { + var buildSection = this.pbxBuildFileSection(); + removeItemAndCommentFromSectionByUuid(buildSection, itemUuid); +} + pbxProject.prototype.findMainPbxGroup = function () { var groups = this.hash.project.objects['PBXGroup']; var candidates = []; @@ -511,6 +518,7 @@ pbxProject.prototype.findMainPbxGroup = function () { pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceTree, opt) { opt = opt || {}; + var srcRootPath = $path.dirname($path.dirname(this.filepath)); var oldGroup = this.pbxGroupByName(name); if (oldGroup) { this.removePbxGroup(name, path); @@ -554,36 +562,47 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT continue; } - var srcRootPath = $path.dirname($path.dirname(this.filepath)); var relativePath = $path.relative(srcRootPath, filePath); var file = new pbxFile(opt.filesRelativeToProject ? relativePath : filePath); - if (fs.existsSync(filePath) && fs.lstatSync(filePath).isDirectory()) { - file.uuid = this.generateUuid(); + file.uuid = this.generateUuid(); + file.fileRef = this.generateUuid(); + if(opt.target) { + file.target = opt.target; + } + if (fs.existsSync(filePath) && fs.lstatSync(filePath).isDirectory() && !isAssetFileType(file.lastKnownFileType)) { + if($path.extname(filePath) === ".lproj") { + continue; + } file.fileRef = file.uuid; + var files = fs.readdirSync(filePath).map(p => $path.join(filePath, p)); this.addToPbxFileReferenceSection(file); // PBXFileReference this.addToPbxBuildFileSection(file); pbxGroup.children.push(pbxGroupChild(file)); - var files = fs.readdirSync(filePath).map(p => $path.join(filePath, p)); - this.addPbxGroup(files, $path.basename(filePath), filePath, null, {uuid: file.uuid, filesRelativeToProject: opt.filesRelativeToProject}); - } else if (isSourceOrHeaderFileType(file.lastKnownFileType)) { - file.uuid = this.generateUuid(); - file.fileRef = this.generateUuid(); + this.addPbxGroup(files, $path.basename(filePath), filePath, null, {uuid: file.uuid, filesRelativeToProject: opt.filesRelativeToProject, target: opt.target}); + } else { this.addToPbxFileReferenceSection(file); // PBXFileReference - this.addToPbxBuildFileSection(file); // PBXBuildFile - if (!isHeaderFileType(file.lastKnownFileType)) { + pbxGroup.children.push(pbxGroupChild(file)); + if(isHeaderFileType(file.lastKnownFileType) || isPlistFileType(file.lastKnownFileType)) { + continue; + } + + if(isEntitlementFileType(file.lastKnownFileType)) { + this.addToBuildSettings('CODE_SIGN_ENTITLEMENTS', file.path, opt.target); + continue; + } + + if (isSourceFileType(file.lastKnownFileType)) { // PBXBuildFile this.addToPbxSourcesBuildPhase(file); + } else if(isResource(file.group)) { + this.addToPbxResourcesBuildPhase(file) } - pbxGroup.children.push(pbxGroupChild(file)); - } else { - file.uuid = this.generateUuid(); - file.fileRef = this.generateUuid(); - this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPbxBuildFileSection(file); - pbxGroup.children.push(pbxGroupChild(file)); } - } + handleLocalization.call(this, filePathsArray, pbxGroup, srcRootPath, opt); + if (groups) { groups[pbxGroupUuid] = pbxGroup; groups[commentKey] = name; @@ -601,11 +620,55 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT return {uuid: pbxGroupUuid, pbxGroup: pbxGroup}; } +function handleLocalization(files, pbxGroup, srcRootPath, opt) { + var storyboardNames = {}; + var allNames = {}; + var regions = {}; + + for (let i = 0; i < files.length; i++) { + const filePath = files[i]; + const parsedPath = $path.parse(filePath); + if($path.extname(filePath) === ".lproj") { + var regionName = parsedPath.name; + var region = regions[regionName] = {}; + var regionFiles = fs.readdirSync(filePath); + this.addKnownRegion(regionName); + for (let j = 0; j < regionFiles.length; j++) { + var regionFilePath = regionFiles[j]; + var parsedRegionFilePath = $path.parse(regionFilePath); + var regionFileName = parsedRegionFilePath.name; + if(parsedRegionFilePath.ext === ".storyboard") { + storyboardNames[parsedRegionFilePath.name] = true; + } + fileRegions = allNames[parsedRegionFilePath.name] = allNames[parsedRegionFilePath.name] || []; + fileRegions.push(regionName); + region[regionFileName] = $path.join(filePath, regionFilePath); + } + } + } + + for (var name in allNames) { + fileRegions = allNames[name] + var variantGroupName = storyboardNames[name] ? name + ".storyboard" : name + ".strings"; + + var variantGroup = this.addLocalizationVariantGroup(variantGroupName, { target: opt.target, skipAddToResourcesGroup: true }); + pbxGroup.children.push(pbxGroupChild(variantGroup)); + for (let k = 0; k < fileRegions.length; k++) { + var file = regions[fileRegions[k]][name]; + var refFile = new pbxFile($path.relative(srcRootPath, file), {basename: fileRegions[k]}); + refFile.fileRef = this.generateUuid(); + this.addToPbxFileReferenceSection(refFile); + this.addToPbxVariantGroup(refFile, variantGroup.fileRef); + } + } +}; + pbxProject.prototype.removePbxGroup = function(groupName, path) { - var group = this.pbxGroupByName(groupName); - if (!group) { + var groupKey = this.findPBXGroupKey({name: groupName}) || this.findPBXVariantGroupKey({name: groupName}); + if (!groupKey) { return; } + var group = this.getPBXGroupByKey(groupKey) || this.getPBXVariantGroupByKey(groupKey) path = path || ""; @@ -631,8 +694,12 @@ pbxProject.prototype.removePbxGroup = function(groupName, path) { } } - var section = this.hash.project.objects['PBXGroup'], - key, itemKey; + var section, key, itemKey; + if(unquote(group.isa) === "PBXVariantGroup") { + section = this.hash.project.objects['PBXVariantGroup']; + } else { + section = this.hash.project.objects['PBXGroup']; + } for (key in section) { // only look for comments @@ -773,7 +840,7 @@ pbxProject.prototype.removeFromFrameworksPbxGroup = function(file) { } var pluginsGroupChildren = this.pbxGroupByName('Frameworks').children; - for (i in pluginsGroupChildren) { + for (var i in pluginsGroupChildren) { if (pbxGroupChild(file).value == pluginsGroupChildren[i].value && pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) { pluginsGroupChildren.splice(i, 1); @@ -793,7 +860,7 @@ pbxProject.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) { var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target); if (sources) { var files = []; - for (i in sources.files) { + for (var i in sources.files) { if (sources.files[i].comment != longComment(file)) { files.push(sources.files[i]); } @@ -864,7 +931,7 @@ pbxProject.prototype.addToPbxFrameworksBuildPhase = function(file) { pbxProject.prototype.removeFromPbxFrameworksBuildPhase = function(file) { var sources = this.pbxFrameworksBuildPhaseObj(file.target); - for (i in sources.files) { + for (var i in sources.files) { if (sources.files[i].comment == longComment(file)) { sources.files.splice(i, 1); break; @@ -922,6 +989,14 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) { pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency], pbxContainerItemProxySection = this.hash.project.objects[pbxContainerItemProxy]; + if(!pbxTargetDependencySection){ + pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency] = {}; + } + + if(!pbxContainerItemProxySection){ + pbxContainerItemProxySection = this.hash.project.objects[pbxContainerItemProxy] = {}; + } + for (var index = 0; index < dependencyTargets.length; index++) { var dependencyTargetUuid = dependencyTargets[index], dependencyTargetCommentKey = f("%s_comment", dependencyTargetUuid), @@ -934,7 +1009,7 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) { containerPortal: this.hash.project['rootObject'], containerPortal_comment: this.hash.project['rootObject_comment'], proxyType: 1, - remoteGlobalIDString: dependencyTargetUuid, + remoteGlobalIDString: dependencyTargetUuid, remoteInfo: nativeTargets[dependencyTargetUuid].name }, targetDependency = { @@ -1001,12 +1076,12 @@ pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, co if (!COMMENT_KEY.test(key)) continue; var buildFileKey = key.split(COMMENT_KEY)[0], - buildFile = buildFileSection[buildFileKey]; - fileReference = fileReferenceSection[buildFile.fileRef]; + buildFile = buildFileSection[buildFileKey], + fileReference = fileReferenceSection[buildFile.fileRef]; if (!fileReference) continue; - var pbxFileObj = new pbxFile(fileReference.path); + var pbxFileObj = new pbxFile(fileReference.path || ""); filePathToBuildFile[fileReference.path] = { uuid: buildFileKey, basename: pbxFileObj.basename, group: pbxFileObj.group }; } @@ -1158,8 +1233,8 @@ pbxProject.prototype.buildPhase = function(group, target) { var buildPhase = buildPhases[i]; if (buildPhase.comment==group) return buildPhase.value + "_comment"; - } } +} pbxProject.prototype.buildPhaseObject = function(name, group, target) { var section = this.hash.project.objects[name], @@ -1182,13 +1257,13 @@ pbxProject.prototype.buildPhaseObject = function(name, group, target) { return null; } -pbxProject.prototype.addBuildProperty = function(prop, value, build_name) { +pbxProject.prototype.addBuildProperty = function(prop, value, build_name, productName) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()), key, configuration; for (key in configurations){ configuration = configurations[key]; - if (!build_name || configuration.name === build_name){ + if ((!build_name || configuration.name === build_name) && (!productName || configuration.buildSettings.PRODUCT_NAME === productName || configuration.buildSettings.PRODUCT_NAME === `"${productName}"`)) { configuration.buildSettings[prop] = value; } } @@ -1349,15 +1424,17 @@ pbxProject.prototype.removeFromHeaderSearchPaths = function(file) { } } -pbxProject.prototype.addToHeaderSearchPaths = function(file) { +pbxProject.prototype.addToHeaderSearchPaths = function(file, productName) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()), INHERITED = '"$(inherited)"', config, buildSettings, searchPaths; + productName = unquote(productName || this.productName); + for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) + if (unquote(buildSettings['PRODUCT_NAME']) != productName) continue; if (!buildSettings['HEADER_SEARCH_PATHS']) { @@ -1413,14 +1490,30 @@ pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) { } } -pbxProject.prototype.addToBuildSettings = function (buildSetting, value) { +pbxProject.prototype.addToBuildSettings = function (buildSetting, value, targetUuid) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + buildConfigurationsUuids = [], config, buildSettings; + if(targetUuid) { + var targets = this.hash.project.objects['PBXNativeTarget'] || []; + var target = targets[targetUuid] || {}; + var buildConfigurationList = target["buildConfigurationList"]; + var pbxXCConfigurationListSection = this.pbxXCConfigurationList() || {}; + var xcConfigurationList = pbxXCConfigurationListSection[buildConfigurationList] || {}; + var buildConfigurations = xcConfigurationList.buildConfigurations || []; + for(var configurationUuid in buildConfigurations){ + buildConfigurationsUuids.push(buildConfigurations[configurationUuid].value); + } + + } + for (config in configurations) { - buildSettings = configurations[config].buildSettings; + if(!target || buildConfigurationsUuids.indexOf(config) >= 0) { + buildSettings = configurations[config].buildSettings; - buildSettings[buildSetting] = value; + buildSettings[buildSetting] = value; + } } } @@ -1495,7 +1588,7 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) { isa: 'XCBuildConfiguration', buildSettings: { GCC_PREPROCESSOR_DEFINITIONS: ['"DEBUG=1"', '"$(inherited)"'], - INFOPLIST_FILE: '"' + $path.join(targetSubfolder, targetSubfolder + '-Info.plist' + '"'), + INFOPLIST_FILE: '"' + $path.join(targetSubfolder, 'Info.plist' + '"'), LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', PRODUCT_NAME: '"' + targetName + '"', SKIP_INSTALL: 'YES' @@ -1505,7 +1598,7 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) { name: 'Release', isa: 'XCBuildConfiguration', buildSettings: { - INFOPLIST_FILE: '"' + $path.join(targetSubfolder, targetSubfolder + '-Info.plist' + '"'), + INFOPLIST_FILE: '"' + $path.join(targetSubfolder, 'Info.plist' + '"'), LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', PRODUCT_NAME: '"' + targetName + '"', SKIP_INSTALL: 'YES' @@ -1557,7 +1650,7 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) { // this.addBuildPhaseToTarget(newPhase.buildPhase, this.getFirstTarget().uuid) - }; + } // Target: Add uuid to root project this.addToPbxProjectSection(target); @@ -1568,9 +1661,187 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) { // Return target on success return target; +}; + +pbxProject.prototype.removeTargetsByProductType = function(targetProductType) { + var nativeTargetsNonComments = nonComments(this.pbxNativeTargetSection()); + + for (var nativeTargetUuid in nativeTargetsNonComments) { + var target = nativeTargetsNonComments[nativeTargetUuid]; + if(target.productType === targetProductType || target.productType === `"${targetProductType}"`) { + this.removeTarget(target, nativeTargetUuid); + } + } +} + +pbxProject.prototype.removeTarget = function(target, targetKey) { + let files = []; + + // iterate all buildPhases and collect all files that should be removed + // remove the phase from the appropriate section + var buildPhases = target["buildPhases"]; + for (let i = 0; i < buildPhases.length; i++) { + var buildPhase = buildPhases[i]; + var sectionUuid = buildPhase.value; + var section = {}; //in case we don't recognise the section + if(buildPhase.comment === buildPhaseNameForIsa("PBXSourcesBuildPhase")){ + section = this.hash.project.objects["PBXSourcesBuildPhase"]; + files = files.concat(section[sectionUuid].files); + } else if (buildPhase.comment === buildPhaseNameForIsa("PBXResourcesBuildPhase")) { + section = this.hash.project.objects["PBXResourcesBuildPhase"]; + files = files.concat(section[sectionUuid].files); + } else if (buildPhase.comment === buildPhaseNameForIsa("PBXFrameworksBuildPhase")) { + section = this.hash.project.objects["PBXFrameworksBuildPhase"]; + files = files.concat(section[sectionUuid].files); + } + + removeItemAndCommentFromSectionByUuid(section, sectionUuid); + } + + //remove files from all build phases from PBXBuildFile section + for (let k = 0; k < files.length; k++) { + const fileUuid = files[k].value; + this.removeFromPbxBuildFileSectionByUuid(fileUuid); + } + + //remove target from the project itself + var targets = this.pbxProjectSection()[this.getFirstProject()['uuid']]['targets'] + for (let l = 0; l < targets.length; l++) { + if(targets[l].value === targetKey){ + targets.splice(l,1); + } + } + + //remove target build configurations + //get configurationList object and get all configuration uuids + var buildConfigurationList = target["buildConfigurationList"]; + var pbxXCConfigurationListSection = this.pbxXCConfigurationList(); + var xcConfigurationList = pbxXCConfigurationListSection[buildConfigurationList] || {}; + var buildConfigurations = xcConfigurationList.buildConfigurations || []; + + //remove all configurations from XCBuildConfiguration section + var pbxBuildConfigurationSection = this.pbxXCBuildConfigurationSection() + for (let m = 0; m < buildConfigurations.length; m++) { + const configuration = buildConfigurations[m]; + removeItemAndCommentFromSectionByUuid(pbxBuildConfigurationSection, configuration.value); + } + + //remove the XCConfigurationList from the section + removeItemAndCommentFromSectionByUuid(pbxXCConfigurationListSection, buildConfigurationList); + //get target product information + var productUuid = ""; + + var productReferenceUuid = target.productReference; + var pbxBuildFileSection = this.pbxBuildFileSection(); + var pbxBuildFileSectionNoComments = nonComments(pbxBuildFileSection); + + // the productReference is the uuid from the PBXFileReference Section, but we need the one in PBXBuildFile section + // check the fileRef of all records until we find the product + for (var uuid in pbxBuildFileSectionNoComments) { + if (this.pbxBuildFileSection()[uuid].fileRef == productReferenceUuid) { + productUuid = uuid; + } + } + + //remove copy phase + var pbxCopySection = this.hash.project.objects["PBXCopyFilesBuildPhase"]; + var noCommentsCopySection = nonComments(pbxCopySection); + for (var copyPhaseId in noCommentsCopySection) { + var copyPhase = noCommentsCopySection[copyPhaseId]; + if(copyPhase.files) { + + //check if the product of the target is part of this copy phase files + for (let p = 0; p < copyPhase.files.length; p++) { + const copyFile = copyPhase.files[p]; + if(copyFile.value === productUuid) { + //if this is the only file in the copy phase - delete the whole phase and remove it from all targets + if(copyPhase.files.length === 1) { + var nativeTargetsnoComments = nonComments(this.pbxNativeTargetSection()); + for (var nativeTargetUuid in nativeTargetsnoComments) { + const nativeTarget = nativeTargetsnoComments[nativeTargetUuid]; + for (var phaseIndex in nativeTarget.buildPhases) { + if (nativeTarget.buildPhases[phaseIndex].value == copyPhaseId) { + //remove copy build phase from containing target + nativeTarget.buildPhases.splice(phaseIndex, 1); + break; + } + } + } + + //remove from copySection + removeItemAndCommentFromSectionByUuid(pbxCopySection, copyPhaseId); + } else { + //if there are other files in the copy phase, just remove the product + copyPhase.files.splice(p, 1); + } + break; + } + } + } + } + + //remove the product from the PBXBuildFile section + removeItemAndCommentFromSectionByUuid(pbxBuildFileSection, productUuid); + + + //remove the product from the Products PBXGroup + var fileReferenceSection = this.pbxFileReferenceSection(); + var productReference = fileReferenceSection[productReferenceUuid]; + var productFile = new pbxFile(productReference.path); + productFile.fileRef = productReferenceUuid; + productFile.uuid = productReferenceUuid; + this.removeFromProductsPbxGroup(productFile); + + //remove the product from the PBXFileReference section + removeItemAndCommentFromSectionByUuid(fileReferenceSection, productReferenceUuid); + + + //find all PBXTargetDependency that refer the target and remove them with the PBXContainerItemProxy + var pbxTargetDependency = 'PBXTargetDependency'; + var pbxContainerItemProxy = 'PBXContainerItemProxy'; + var pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency]; + var pbxTargetDependencySectionNoComments = nonComments(pbxTargetDependencySection); + var pbxContainerItemProxySection = this.hash.project.objects[pbxContainerItemProxy]; + + for(var targetDependencyUuid in pbxTargetDependencySectionNoComments) { + var targetDependency = pbxTargetDependencySectionNoComments[targetDependencyUuid]; + if(targetDependency.target === targetKey) { + //remove the PBXContainerItemProxy + removeItemAndCommentFromSectionByUuid(pbxContainerItemProxySection, targetDependency.targetProxy); + //remove the PBXTargetDependency from dependencies from all targets + for (var nativeTargetKey in nativeTargetsnoComments) { + const nativeTarget = nativeTargetsnoComments[nativeTargetKey]; + for (var dependencyIndex in nativeTarget.dependencies) { + if (nativeTarget.dependencies[dependencyIndex].value == targetDependencyUuid) { + nativeTarget.dependencies.splice(dependencyIndex, 1); + } + } + } + //remove the PBXTargetDependency + removeItemAndCommentFromSectionByUuid(pbxTargetDependencySection, targetDependencyUuid); + } + } + + //remove targetAttributes for target + var attributes = this.getFirstProject()['firstProject']['attributes']; + if (attributes['TargetAttributes']) { + delete attributes['TargetAttributes'][targetKey]; + } + + //remove the target from PBXNativeTarget section + var nativeTargets = this.pbxNativeTargetSection(); + removeItemAndCommentFromSectionByUuid(nativeTargets, targetKey); + + this.removePbxGroup(unquote(target.name)); }; +function removeItemAndCommentFromSectionByUuid(section, itemUuid) { + var commentKey = f("%s_comment", itemUuid) + delete section[commentKey]; + delete section[itemUuid]; +} + // helper recursive prop search+replace function propReplace(obj, prop, value) { var o = {}; @@ -1791,7 +2062,7 @@ function unquote(str) { function buildPhaseNameForIsa (isa) { - BUILDPHASENAME_BY_ISA = { + var BUILDPHASENAME_BY_ISA = { PBXCopyFilesBuildPhase: 'Copy Files', PBXResourcesBuildPhase: 'Resources', PBXSourcesBuildPhase: 'Sources', @@ -1803,7 +2074,7 @@ function buildPhaseNameForIsa (isa) { function producttypeForTargettype (targetType) { - PRODUCTTYPE_BY_TARGETTYPE = { + var PRODUCTTYPE_BY_TARGETTYPE = { application: 'com.apple.product-type.application', app_extension: 'com.apple.product-type.app-extension', bundle: 'com.apple.product-type.bundle', @@ -1821,7 +2092,7 @@ function producttypeForTargettype (targetType) { function filetypeForProducttype (productType) { - FILETYPE_BY_PRODUCTTYPE = { + var FILETYPE_BY_PRODUCTTYPE = { 'com.apple.product-type.application': '"wrapper.application"', 'com.apple.product-type.app-extension': '"wrapper.app-extension"', 'com.apple.product-type.bundle': '"wrapper.plug-in"', @@ -2017,16 +2288,24 @@ pbxProject.prototype.findPBXVariantGroupKey = function(criteria) { return this.findPBXGroupKeyAndType(criteria, 'PBXVariantGroup'); } -pbxProject.prototype.addLocalizationVariantGroup = function(name) { +pbxProject.prototype.addLocalizationVariantGroup = function(name, ops) { + ops = ops || {}; var groupKey = this.pbxCreateVariantGroup(name); - var resourceGroupKey = this.findPBXGroupKey({name: 'Resources'}); - this.addToPbxGroup(groupKey, resourceGroupKey); + if(!ops.skipAddToResourcesGroup) { + var resourcesGroupKey = this.findPBXGroupKey({name: 'Resources'}); + this.addToPbxGroup(groupKey, resourcesGroupKey); + } var localizationVariantGroup = { uuid: this.generateUuid(), fileRef: groupKey, - basename: name + basename: name, + group: "Resources", + children: [] + } + if(ops.target) { + localizationVariantGroup.target = ops.target; } this.addToPbxBuildFileSection(localizationVariantGroup); // PBXBuildFile this.addToPbxResourcesBuildPhase(localizationVariantGroup); //PBXResourcesBuildPhase diff --git a/package.json b/package.json index 4d589aa..8ded6af 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Telerik ", "name": "nativescript-dev-xcode", "description": "parser for xcodeproj/project.pbxproj files", - "main":"index.js", + "main": "index.js", "version": "0.1.0", "repository": { "url": "https://github.com/NativeScript/nativescript-dev-xcode.git" diff --git a/test/BuildSettings.js b/test/BuildSettings.js index 698ce06..213f575 100644 --- a/test/BuildSettings.js +++ b/test/BuildSettings.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/FrameworkSearchPaths.js b/test/FrameworkSearchPaths.js index d6fb0ce..b709f3a 100644 --- a/test/FrameworkSearchPaths.js +++ b/test/FrameworkSearchPaths.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); var pbxFile = { diff --git a/test/HeaderSearchPaths.js b/test/HeaderSearchPaths.js index 1377384..998fd8b 100644 --- a/test/HeaderSearchPaths.js +++ b/test/HeaderSearchPaths.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/LibrarySearchPaths.js b/test/LibrarySearchPaths.js index 5b1461b..6788e10 100644 --- a/test/LibrarySearchPaths.js +++ b/test/LibrarySearchPaths.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/OtherLinkerFlags.js b/test/OtherLinkerFlags.js index f77ea8f..de59f4c 100644 --- a/test/OtherLinkerFlags.js +++ b/test/OtherLinkerFlags.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/addFramework.js b/test/addFramework.js index 11358ef..17b5551 100644 --- a/test/addFramework.js +++ b/test/addFramework.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/addHeaderFile.js b/test/addHeaderFile.js index f96a736..2373405 100644 --- a/test/addHeaderFile.js +++ b/test/addHeaderFile.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/addResourceFile.js b/test/addResourceFile.js index 04b6013..3c48c59 100644 --- a/test/addResourceFile.js +++ b/test/addResourceFile.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/addSourceFile.js b/test/addSourceFile.js index fd5352b..612a0de 100644 --- a/test/addSourceFile.js +++ b/test/addSourceFile.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/addStaticLibrary.js b/test/addStaticLibrary.js index 9b48546..b157a08 100644 --- a/test/addStaticLibrary.js +++ b/test/addStaticLibrary.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/addToPbxFileReferenceSection.js b/test/addToPbxFileReferenceSection.js index da5f440..494f223 100644 --- a/test/addToPbxFileReferenceSection.js +++ b/test/addToPbxFileReferenceSection.js @@ -18,7 +18,7 @@ var jsonProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(jsonProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), myProj = new pbx('.'); function cleanHash() { diff --git a/test/dataModelDocument.js b/test/dataModelDocument.js index c809d62..76477ed 100644 --- a/test/dataModelDocument.js +++ b/test/dataModelDocument.js @@ -19,7 +19,7 @@ var jsonProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(jsonProject), path = require('path'), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'), singleDataModelFilePath = __dirname + '/fixtures/single-data-model.xcdatamodeld', multipleDataModelFilePath = __dirname + '/fixtures/multiple-data-model.xcdatamodeld'; diff --git a/test/group.js b/test/group.js index 5072aa1..af2454e 100644 --- a/test/group.js +++ b/test/group.js @@ -16,7 +16,7 @@ */ var pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), project, projectHash; diff --git a/test/multipleTargets.js b/test/multipleTargets.js index dc4c419..dbb945f 100644 --- a/test/multipleTargets.js +++ b/test/multipleTargets.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/multiple-targets') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/pbxFile.js b/test/pbxFile.js index f096120..4f0d1a2 100644 --- a/test/pbxFile.js +++ b/test/pbxFile.js @@ -15,7 +15,7 @@ under the License. */ -var pbxFile = require('../lib/pbxFile').pbxFile; +var pbxFile = require('../lib/pbxFile'); exports['lastKnownFileType'] = { 'should detect that a .m path means sourcecode.c.objc': function (test) { diff --git a/test/removeFramework.js b/test/removeFramework.js index 15312d4..20cdbde 100644 --- a/test/removeFramework.js +++ b/test/removeFramework.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project'), fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/removeHeaderFile.js b/test/removeHeaderFile.js index 973533a..358a88a 100644 --- a/test/removeHeaderFile.js +++ b/test/removeHeaderFile.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/removeResourceFile.js b/test/removeResourceFile.js index ca7bb94..f6d6488 100644 --- a/test/removeResourceFile.js +++ b/test/removeResourceFile.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/removeSourceFile.js b/test/removeSourceFile.js index df9f2e7..92fb49b 100644 --- a/test/removeSourceFile.js +++ b/test/removeSourceFile.js @@ -18,7 +18,7 @@ var fullProject = require('./fixtures/full-project') fullProjectStr = JSON.stringify(fullProject), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'); function cleanHash() { diff --git a/test/xcode5searchPaths.js b/test/xcode5searchPaths.js index 61014cb..7cdf46c 100644 --- a/test/xcode5searchPaths.js +++ b/test/xcode5searchPaths.js @@ -18,7 +18,7 @@ var xcode5proj = require('./fixtures/library-search-paths') xcode5projStr = JSON.stringify(xcode5proj), pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile').pbxFile, + pbxFile = require('../lib/pbxFile'), proj = new pbx('.'), libPoop = { path: 'some/path/poop.a' };