├── .gitignore ├── LICENSE.TXT ├── README.md ├── XcodeProjAdder.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── XcodeProjAdder.xccheckout │ └── xcuserdata │ │ └── lukehines.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── lukehines.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── XcodeProjAdder.xcscheme │ └── xcschememanagement.plist ├── XcodeProjAdder ├── IOMethods.cpp ├── IOMethods.h ├── XcodeProjAdder.1 ├── main.cpp ├── stringMethods.cpp ├── stringMethods.h ├── xprojFileAdder.cpp ├── xprojFileAdder.h ├── xprojRestorer.cpp ├── xprojRestorer.h ├── xprojZoneFileTools.cpp └── xprojZoneFileTools.h └── bin └── XcodeProjAdder /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode gitignore 2 | # Taken from https://github.com/github/gitignore/blob/master/Global/Xcode.gitignore 3 | 4 | ## Build generated 5 | build/ 6 | DerivedData/ 7 | 8 | ## Various settings 9 | *.pbxuser 10 | !default.pbxuser 11 | *.mode1v3 12 | !default.mode1v3 13 | *.mode2v3 14 | !default.mode2v3 15 | *.perspectivev3 16 | !default.perspectivev3 17 | xcuserdata/ 18 | 19 | ## Other 20 | *.moved-aside 21 | *.xccheckout 22 | *.xcscmblueprint 23 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | DON'T BE A DICK PUBLIC LICENSE 2 | 3 | Version 1, December 2009 4 | 5 | Copyright (C) 2014 Luke Hines 6 | 7 | Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. 8 | 9 | DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 10 | 11 | Do whatever you like with the original work, just don't be a dick. 12 | 13 | Being a dick includes - but is not limited to - the following instances: 14 | 15 | 1a. Outright copyright infringement - Don't just copy this and change the name. 16 | 1b. Selling the unmodified original with no work done what-so-ever, that's REALLY being a dick. 17 | 1c. Modifying the original work to contain hidden harmful content. That would make you a PROPER dick. 18 | 19 | If you become rich through modifications, related works/services, or supporting the original work, share the love. Only a dick would make loads off this work and not buy the original works creator(s) a pint. 20 | 21 | Code is provided with no warranty. Using somebody else's code and bitching when it goes wrong makes you a DONKEY dick. Fix the problem yourself. A non-dick would submit the fix back. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Xcode-Proj-Adder 2 | ================ 3 | 4 | ***This project is deprecated: This solution no longer works with the latest versions of Xcode and there are currently no plans to update it. However there is a Ruby gem that can be used to provide the same functionality that this project used to. you can find more details [Here](https://github.com/CocoaPods/Xcodeproj)*** 5 | 6 | Add files to your Xcode project from command line 7 | 8 | When building Xcode projects from command line it is surprising to find that there is currently no way to add files to a project without going through the GUI. So… here is this quick tool to add existing files an Xcode project through OSX command line. 9 | 10 | Currently supports adding these types of files 11 | .h .m .cpp .mm .swift .png .jpg .mp3 .ttf .ogg 12 | 13 | If you are after the prebuilt tool, pull the source and it is available in the 'bin' directory. 14 | 15 | **Usage:** 16 | Run from terminal/script setting the -XCP argument along with one of the other two arguments. 17 | 18 | `-XCP` : Fully qualified path of ‘.xcodeproj’ (the project you want to add files to) 19 | 20 | `-SCSV` : CSV list of source file locations relative to the .xcodeproj file 21 | 22 | `-RESTORE` : removes files added since last run 23 | 24 | 25 | **Example:** 26 | 27 | **Add Source files** 28 | 29 | `$ ./XcodeProjAdder -XCP "Full Path to .xcodeproj" -SCSV "csv of source file locations relative to xcode .xcodeproj"` 30 | 31 | `$ ./XcodeProjAdder -XCP /Users/jimjohn/Products/TestProj.xcodeproj -SCSV ../tst1.cpp,../tst2.cpp,../tst1.h` 32 | 33 | **Restore project to state before files were added** 34 | 35 | `$ ./XcodeProjAdder -XCP "Full Path to .xcodeproj" -RESTORE` 36 | 37 | `$ ./XcodeProjAdder -XCP /Users/jimjohn/Products/TestProj.xcodeproj -RESTORE` 38 | 39 | 40 | This project is made available under the DON'T BE A DICK PUBLIC LICENSE (http://www.dbad-license.org/) 41 | -------------------------------------------------------------------------------- /XcodeProjAdder.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B2B35C6B1949D40F00E6274B /* xprojZoneFileTools.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2B35C6A1949D40F00E6274B /* xprojZoneFileTools.cpp */; }; 11 | B2BD1046194857DA00F633CE /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2BD1045194857DA00F633CE /* main.cpp */; }; 12 | B2BD1048194857DA00F633CE /* XcodeProjAdder.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = B2BD1047194857DA00F633CE /* XcodeProjAdder.1 */; }; 13 | B2BD10501948988B00F633CE /* stringMethods.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2BD104F1948988B00F633CE /* stringMethods.cpp */; }; 14 | B2BD105319489A7C00F633CE /* IOMethods.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2BD105219489A7C00F633CE /* IOMethods.cpp */; }; 15 | B2BD105719489DCD00F633CE /* xprojRestorer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2BD105619489DCD00F633CE /* xprojRestorer.cpp */; }; 16 | B2BD105A19489F7000F633CE /* xprojFileAdder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2BD105919489F7000F633CE /* xprojFileAdder.cpp */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXCopyFilesBuildPhase section */ 20 | B2BD1040194857DA00F633CE /* CopyFiles */ = { 21 | isa = PBXCopyFilesBuildPhase; 22 | buildActionMask = 2147483647; 23 | dstPath = /usr/share/man/man1/; 24 | dstSubfolderSpec = 0; 25 | files = ( 26 | B2BD1048194857DA00F633CE /* XcodeProjAdder.1 in CopyFiles */, 27 | ); 28 | runOnlyForDeploymentPostprocessing = 1; 29 | }; 30 | /* End PBXCopyFilesBuildPhase section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | B2B35C691949D3FD00E6274B /* xprojZoneFileTools.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = xprojZoneFileTools.h; sourceTree = ""; }; 34 | B2B35C6A1949D40F00E6274B /* xprojZoneFileTools.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xprojZoneFileTools.cpp; sourceTree = ""; }; 35 | B2BD1042194857DA00F633CE /* XcodeProjAdder */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = XcodeProjAdder; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | B2BD1045194857DA00F633CE /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 37 | B2BD1047194857DA00F633CE /* XcodeProjAdder.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = XcodeProjAdder.1; sourceTree = ""; }; 38 | B2BD104E1948987700F633CE /* stringMethods.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = stringMethods.h; sourceTree = ""; }; 39 | B2BD104F1948988B00F633CE /* stringMethods.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stringMethods.cpp; sourceTree = ""; }; 40 | B2BD105119489A7200F633CE /* IOMethods.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IOMethods.h; sourceTree = ""; }; 41 | B2BD105219489A7C00F633CE /* IOMethods.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IOMethods.cpp; sourceTree = ""; }; 42 | B2BD105519489DC200F633CE /* xprojRestorer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = xprojRestorer.h; sourceTree = ""; }; 43 | B2BD105619489DCD00F633CE /* xprojRestorer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xprojRestorer.cpp; sourceTree = ""; }; 44 | B2BD105819489F6200F633CE /* xprojFileAdder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = xprojFileAdder.h; sourceTree = ""; }; 45 | B2BD105919489F7000F633CE /* xprojFileAdder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xprojFileAdder.cpp; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | B2BD103F194857DA00F633CE /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | /* End PBXFrameworksBuildPhase section */ 57 | 58 | /* Begin PBXGroup section */ 59 | B2BD1039194857DA00F633CE = { 60 | isa = PBXGroup; 61 | children = ( 62 | B2BD1044194857DA00F633CE /* XcodeProjAdder */, 63 | B2BD1043194857DA00F633CE /* Products */, 64 | ); 65 | sourceTree = ""; 66 | }; 67 | B2BD1043194857DA00F633CE /* Products */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | B2BD1042194857DA00F633CE /* XcodeProjAdder */, 71 | ); 72 | name = Products; 73 | sourceTree = ""; 74 | }; 75 | B2BD1044194857DA00F633CE /* XcodeProjAdder */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | B2BD1045194857DA00F633CE /* main.cpp */, 79 | B2B35C691949D3FD00E6274B /* xprojZoneFileTools.h */, 80 | B2B35C6A1949D40F00E6274B /* xprojZoneFileTools.cpp */, 81 | B2BD105819489F6200F633CE /* xprojFileAdder.h */, 82 | B2BD105919489F7000F633CE /* xprojFileAdder.cpp */, 83 | B2BD105519489DC200F633CE /* xprojRestorer.h */, 84 | B2BD105619489DCD00F633CE /* xprojRestorer.cpp */, 85 | B2BD105419489D8D00F633CE /* Helper Classes */, 86 | B2BD1047194857DA00F633CE /* XcodeProjAdder.1 */, 87 | ); 88 | path = XcodeProjAdder; 89 | sourceTree = ""; 90 | }; 91 | B2BD105419489D8D00F633CE /* Helper Classes */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | B2BD105119489A7200F633CE /* IOMethods.h */, 95 | B2BD105219489A7C00F633CE /* IOMethods.cpp */, 96 | B2BD104E1948987700F633CE /* stringMethods.h */, 97 | B2BD104F1948988B00F633CE /* stringMethods.cpp */, 98 | ); 99 | name = "Helper Classes"; 100 | sourceTree = ""; 101 | }; 102 | /* End PBXGroup section */ 103 | 104 | /* Begin PBXNativeTarget section */ 105 | B2BD1041194857DA00F633CE /* XcodeProjAdder */ = { 106 | isa = PBXNativeTarget; 107 | buildConfigurationList = B2BD104B194857DA00F633CE /* Build configuration list for PBXNativeTarget "XcodeProjAdder" */; 108 | buildPhases = ( 109 | B2BD103E194857DA00F633CE /* Sources */, 110 | B2BD103F194857DA00F633CE /* Frameworks */, 111 | B2BD1040194857DA00F633CE /* CopyFiles */, 112 | ); 113 | buildRules = ( 114 | ); 115 | dependencies = ( 116 | ); 117 | name = XcodeProjAdder; 118 | productName = XcodeProjAdder; 119 | productReference = B2BD1042194857DA00F633CE /* XcodeProjAdder */; 120 | productType = "com.apple.product-type.tool"; 121 | }; 122 | /* End PBXNativeTarget section */ 123 | 124 | /* Begin PBXProject section */ 125 | B2BD103A194857DA00F633CE /* Project object */ = { 126 | isa = PBXProject; 127 | attributes = { 128 | LastUpgradeCheck = 0510; 129 | ORGANIZATIONNAME = "Luke Hines"; 130 | }; 131 | buildConfigurationList = B2BD103D194857DA00F633CE /* Build configuration list for PBXProject "XcodeProjAdder" */; 132 | compatibilityVersion = "Xcode 3.2"; 133 | developmentRegion = English; 134 | hasScannedForEncodings = 0; 135 | knownRegions = ( 136 | en, 137 | ); 138 | mainGroup = B2BD1039194857DA00F633CE; 139 | productRefGroup = B2BD1043194857DA00F633CE /* Products */; 140 | projectDirPath = ""; 141 | projectRoot = ""; 142 | targets = ( 143 | B2BD1041194857DA00F633CE /* XcodeProjAdder */, 144 | ); 145 | }; 146 | /* End PBXProject section */ 147 | 148 | /* Begin PBXSourcesBuildPhase section */ 149 | B2BD103E194857DA00F633CE /* Sources */ = { 150 | isa = PBXSourcesBuildPhase; 151 | buildActionMask = 2147483647; 152 | files = ( 153 | B2BD105A19489F7000F633CE /* xprojFileAdder.cpp in Sources */, 154 | B2BD1046194857DA00F633CE /* main.cpp in Sources */, 155 | B2BD105319489A7C00F633CE /* IOMethods.cpp in Sources */, 156 | B2B35C6B1949D40F00E6274B /* xprojZoneFileTools.cpp in Sources */, 157 | B2BD10501948988B00F633CE /* stringMethods.cpp in Sources */, 158 | B2BD105719489DCD00F633CE /* xprojRestorer.cpp in Sources */, 159 | ); 160 | runOnlyForDeploymentPostprocessing = 0; 161 | }; 162 | /* End PBXSourcesBuildPhase section */ 163 | 164 | /* Begin XCBuildConfiguration section */ 165 | B2BD1049194857DA00F633CE /* Debug */ = { 166 | isa = XCBuildConfiguration; 167 | buildSettings = { 168 | ALWAYS_SEARCH_USER_PATHS = NO; 169 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 170 | CLANG_CXX_LIBRARY = "libc++"; 171 | CLANG_ENABLE_MODULES = YES; 172 | CLANG_ENABLE_OBJC_ARC = YES; 173 | CLANG_WARN_BOOL_CONVERSION = YES; 174 | CLANG_WARN_CONSTANT_CONVERSION = YES; 175 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 176 | CLANG_WARN_EMPTY_BODY = YES; 177 | CLANG_WARN_ENUM_CONVERSION = YES; 178 | CLANG_WARN_INT_CONVERSION = YES; 179 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 180 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 181 | COPY_PHASE_STRIP = NO; 182 | GCC_C_LANGUAGE_STANDARD = gnu99; 183 | GCC_DYNAMIC_NO_PIC = NO; 184 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 185 | GCC_OPTIMIZATION_LEVEL = 0; 186 | GCC_PREPROCESSOR_DEFINITIONS = ( 187 | "DEBUG=1", 188 | "$(inherited)", 189 | ); 190 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 191 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 192 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 193 | GCC_WARN_UNDECLARED_SELECTOR = YES; 194 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 195 | GCC_WARN_UNUSED_FUNCTION = YES; 196 | GCC_WARN_UNUSED_VARIABLE = YES; 197 | MACOSX_DEPLOYMENT_TARGET = 10.9; 198 | ONLY_ACTIVE_ARCH = YES; 199 | SDKROOT = macosx; 200 | }; 201 | name = Debug; 202 | }; 203 | B2BD104A194857DA00F633CE /* Release */ = { 204 | isa = XCBuildConfiguration; 205 | buildSettings = { 206 | ALWAYS_SEARCH_USER_PATHS = NO; 207 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 208 | CLANG_CXX_LIBRARY = "libc++"; 209 | CLANG_ENABLE_MODULES = YES; 210 | CLANG_ENABLE_OBJC_ARC = YES; 211 | CLANG_WARN_BOOL_CONVERSION = YES; 212 | CLANG_WARN_CONSTANT_CONVERSION = YES; 213 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 214 | CLANG_WARN_EMPTY_BODY = YES; 215 | CLANG_WARN_ENUM_CONVERSION = YES; 216 | CLANG_WARN_INT_CONVERSION = YES; 217 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 218 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 219 | COPY_PHASE_STRIP = YES; 220 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 221 | ENABLE_NS_ASSERTIONS = NO; 222 | GCC_C_LANGUAGE_STANDARD = gnu99; 223 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 224 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 225 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 226 | GCC_WARN_UNDECLARED_SELECTOR = YES; 227 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 228 | GCC_WARN_UNUSED_FUNCTION = YES; 229 | GCC_WARN_UNUSED_VARIABLE = YES; 230 | MACOSX_DEPLOYMENT_TARGET = 10.9; 231 | SDKROOT = macosx; 232 | }; 233 | name = Release; 234 | }; 235 | B2BD104C194857DA00F633CE /* Debug */ = { 236 | isa = XCBuildConfiguration; 237 | buildSettings = { 238 | PRODUCT_NAME = "$(TARGET_NAME)"; 239 | }; 240 | name = Debug; 241 | }; 242 | B2BD104D194857DA00F633CE /* Release */ = { 243 | isa = XCBuildConfiguration; 244 | buildSettings = { 245 | PRODUCT_NAME = "$(TARGET_NAME)"; 246 | }; 247 | name = Release; 248 | }; 249 | /* End XCBuildConfiguration section */ 250 | 251 | /* Begin XCConfigurationList section */ 252 | B2BD103D194857DA00F633CE /* Build configuration list for PBXProject "XcodeProjAdder" */ = { 253 | isa = XCConfigurationList; 254 | buildConfigurations = ( 255 | B2BD1049194857DA00F633CE /* Debug */, 256 | B2BD104A194857DA00F633CE /* Release */, 257 | ); 258 | defaultConfigurationIsVisible = 0; 259 | defaultConfigurationName = Release; 260 | }; 261 | B2BD104B194857DA00F633CE /* Build configuration list for PBXNativeTarget "XcodeProjAdder" */ = { 262 | isa = XCConfigurationList; 263 | buildConfigurations = ( 264 | B2BD104C194857DA00F633CE /* Debug */, 265 | B2BD104D194857DA00F633CE /* Release */, 266 | ); 267 | defaultConfigurationIsVisible = 0; 268 | defaultConfigurationName = Release; 269 | }; 270 | /* End XCConfigurationList section */ 271 | }; 272 | rootObject = B2BD103A194857DA00F633CE /* Project object */; 273 | } 274 | -------------------------------------------------------------------------------- /XcodeProjAdder.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /XcodeProjAdder.xcodeproj/project.xcworkspace/xcshareddata/XcodeProjAdder.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 091332A5-277D-4279-8CBB-67A72C731F69 9 | IDESourceControlProjectName 10 | XcodeProjAdder 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 0FDD656733D5B0D52E92EA04E779D4A82A0CED51 14 | https://github.com/zackslash/Xcode-Proj-Adder.git 15 | 16 | IDESourceControlProjectPath 17 | XcodeProjAdder.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 0FDD656733D5B0D52E92EA04E779D4A82A0CED51 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/zackslash/Xcode-Proj-Adder.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 0FDD656733D5B0D52E92EA04E779D4A82A0CED51 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 0FDD656733D5B0D52E92EA04E779D4A82A0CED51 36 | IDESourceControlWCCName 37 | Xcode-Proj-Adder 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /XcodeProjAdder.xcodeproj/project.xcworkspace/xcuserdata/lukehines.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zackslash/Xcode-Proj-Adder/a5165bce3b03fafdea759a82014d69dfe0f280da/XcodeProjAdder.xcodeproj/project.xcworkspace/xcuserdata/lukehines.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /XcodeProjAdder.xcodeproj/xcuserdata/lukehines.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /XcodeProjAdder.xcodeproj/xcuserdata/lukehines.xcuserdatad/xcschemes/XcodeProjAdder.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /XcodeProjAdder.xcodeproj/xcuserdata/lukehines.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | XcodeProjAdder.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | B2BD1041194857DA00F633CE 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /XcodeProjAdder/IOMethods.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // IOMethods.cpp 3 | // XcodeProjAdder 4 | // 5 | // Created by Luke Hines on 11/06/2014. 6 | // Copyright (c) 2014 Luke Hines. 7 | // 8 | // DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 9 | // 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "IOMethods.h" 19 | 20 | std::string IOMethods::generateOSXUUID() 21 | { 22 | FILE* pipe = popen("uuidgen", "r"); 23 | if (!pipe) return "ERROR"; 24 | char buffer[128]; 25 | std::string result = ""; 26 | while(!feof(pipe)) 27 | { 28 | if(fgets(buffer, 128, pipe) != NULL) 29 | result += buffer; 30 | } 31 | pclose(pipe); 32 | result=ReplaceString(result, "-", ""); 33 | result.resize(24); 34 | return result; 35 | } 36 | 37 | std::string IOMethods::get_file_contents(std::string filename) 38 | { 39 | try { 40 | std::ifstream in(filename, std::ios::in | std::ios::binary); 41 | if (in) 42 | { 43 | std::string contents; 44 | in.seekg(0, std::ios::end); 45 | contents.resize(in.tellg()); 46 | in.seekg(0, std::ios::beg); 47 | in.read(&contents[0], contents.size()); 48 | in.close(); 49 | return(contents); 50 | } 51 | throw(errno); 52 | } 53 | catch(int errNum) 54 | { 55 | std::cout << "\n\nERROR: Looks like I cannot read your Xcode project file, make sure the path to your '.xcodeproj' is fully qualified and that you have both read and write permissions\n\n"; 56 | exit(1); 57 | } 58 | } 59 | 60 | 61 | 62 | inline bool ends_with(std::string const & value, std::string const & ending) { 63 | if (ending.size() > value.size()) return false; 64 | return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); 65 | } 66 | inline bool starts_with(std::string const & value, std::string const & start) { 67 | if (start.size() > value.size()) return false; 68 | return std::equal(start.begin(), start.end(), value.begin()); 69 | } 70 | 71 | std::vector IOMethods::expand_dirs(std::vector filenames) { 72 | std::vector result; 73 | 74 | DIR *d = NULL; 75 | struct dirent *dir; 76 | struct stat s; 77 | 78 | for (auto it = filenames.begin(); it != filenames.end(); it++) { 79 | std::string filename = *it; 80 | 81 | // Drop the last "/" in case of a directory 82 | if (ends_with(filename, "/")) { 83 | filename = filename.substr(0, filename.size()-1); 84 | } 85 | 86 | if (stat(filename.c_str(), &s) != 0) { 87 | continue; // error 88 | } 89 | 90 | if (s.st_mode & S_IFREG) { 91 | // Regular file: add to result 92 | result.push_back(filename); 93 | } 94 | 95 | else if( s.st_mode & S_IFDIR ) { 96 | // Directory 97 | 98 | d = opendir(filename.c_str()); 99 | if (d == NULL) { 100 | continue; //error 101 | } 102 | 103 | std::vector dir_contents; 104 | 105 | while ((dir = readdir(d)) != NULL) { 106 | std::string name = std::string(dir->d_name); 107 | 108 | if (starts_with(name, ".")) { 109 | // ignore ".", ".." and hidden files like ".DS_STORE" 110 | continue; 111 | } 112 | 113 | dir_contents.push_back(filename + "/" + name); 114 | } 115 | 116 | // recursive call to get contents of each subdirectory 117 | std::vector dir_result = IOMethods::expand_dirs(dir_contents); 118 | 119 | // add all the files to the result 120 | result.insert(result.end(), dir_result.begin(), dir_result.end()); 121 | } 122 | } 123 | 124 | return result; 125 | 126 | } -------------------------------------------------------------------------------- /XcodeProjAdder/IOMethods.h: -------------------------------------------------------------------------------- 1 | // 2 | // IOMethods.h 3 | // XcodeProjAdder 4 | // 5 | // Created by Luke Hines on 11/06/2014. 6 | // Copyright (c) 2014 Luke Hines. 7 | // 8 | // DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 9 | // 10 | 11 | #ifndef XcodeProjAdder_IOMethods_h 12 | #define XcodeProjAdder_IOMethods_h 13 | 14 | #include 15 | #include 16 | #include 17 | #include "stringMethods.h" 18 | 19 | namespace IOMethods 20 | { 21 | //Generates a 24 char UUID string in OSX 22 | std::string generateOSXUUID(); 23 | 24 | //Retrieves file contents as string 25 | std::string get_file_contents(std::string filename); 26 | 27 | //Given a list if files, expand it so that all directory paths are converted to their contents 28 | std::vector expand_dirs(std::vector filenames); 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /XcodeProjAdder/XcodeProjAdder.1: -------------------------------------------------------------------------------- 1 | .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples. 2 | .\"See Also: 3 | .\"man mdoc.samples for a complete listing of options 4 | .\"man mdoc for the short list of editing options 5 | .\"/usr/share/misc/mdoc.template 6 | .Dd 11/06/2014 \" DATE 7 | .Dt XcodeProjAdder 1 \" Program name and manual section number 8 | .Os Darwin 9 | .Sh NAME \" Section Header - required - don't modify 10 | .Nm XcodeProjAdder, 11 | .\" The following lines are read in generating the apropos(man -k) database. Use only key 12 | .\" words here as the database is built based on the words here and in the .ND line. 13 | .Nm Other_name_for_same_program(), 14 | .Nm Yet another name for the same program. 15 | .\" Use .Nm macro to designate other names for the documented program. 16 | .Nd This line parsed for whatis database. 17 | .Sh SYNOPSIS \" Section Header - required - don't modify 18 | .Nm 19 | .Op Fl abcd \" [-abcd] 20 | .Op Fl a Ar path \" [-a path] 21 | .Op Ar file \" [file] 22 | .Op Ar \" [file ...] 23 | .Ar arg0 \" Underlined argument - use .Ar anywhere to underline 24 | arg2 ... \" Arguments 25 | .Sh DESCRIPTION \" Section Header - required - don't modify 26 | Use the .Nm macro to refer to your program throughout the man page like such: 27 | .Nm 28 | Underlining is accomplished with the .Ar macro like this: 29 | .Ar underlined text . 30 | .Pp \" Inserts a space 31 | A list of items with descriptions: 32 | .Bl -tag -width -indent \" Begins a tagged list 33 | .It item a \" Each item preceded by .It macro 34 | Description of item a 35 | .It item b 36 | Description of item b 37 | .El \" Ends the list 38 | .Pp 39 | A list of flags and their descriptions: 40 | .Bl -tag -width -indent \" Differs from above in tag removed 41 | .It Fl a \"-a flag as a list item 42 | Description of -a flag 43 | .It Fl b 44 | Description of -b flag 45 | .El \" Ends the list 46 | .Pp 47 | .\" .Sh ENVIRONMENT \" May not be needed 48 | .\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1 49 | .\" .It Ev ENV_VAR_1 50 | .\" Description of ENV_VAR_1 51 | .\" .It Ev ENV_VAR_2 52 | .\" Description of ENV_VAR_2 53 | .\" .El 54 | .Sh FILES \" File used or created by the topic of the man page 55 | .Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact 56 | .It Pa /usr/share/file_name 57 | FILE_1 description 58 | .It Pa /Users/joeuser/Library/really_long_file_name 59 | FILE_2 description 60 | .El \" Ends the list 61 | .\" .Sh DIAGNOSTICS \" May not be needed 62 | .\" .Bl -diag 63 | .\" .It Diagnostic Tag 64 | .\" Diagnostic informtion here. 65 | .\" .It Diagnostic Tag 66 | .\" Diagnostic informtion here. 67 | .\" .El 68 | .Sh SEE ALSO 69 | .\" List links in ascending order by section, alphabetically within a section. 70 | .\" Please do not reference files that do not exist without filing a bug report 71 | .Xr a 1 , 72 | .Xr b 1 , 73 | .Xr c 1 , 74 | .Xr a 2 , 75 | .Xr b 2 , 76 | .Xr a 3 , 77 | .Xr b 3 78 | .\" .Sh BUGS \" Document known, unremedied bugs 79 | .\" .Sh HISTORY \" Document history if command behaves in a unique manner -------------------------------------------------------------------------------- /XcodeProjAdder/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // main.cpp 3 | // XcodeProjAdder 4 | // 5 | // Created by Luke Hines on 11/06/2014. 6 | // Copyright (c) 2014 Luke Hines. 7 | // 8 | // DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 9 | // 10 | 11 | #include 12 | 13 | #include "xprojRestorer.h" 14 | #include "xprojFileAdder.h" 15 | 16 | /* 17 | * Arguments 18 | * ================== 19 | * -XCP = Xcode project location. 20 | * -SCSV = CSV list of source file locations relative to the xcode project you wish to add them. 21 | * -RESTORE = restore project file that was backed up on last run of this tool. 22 | */ 23 | 24 | int main(int argc, const char * argv[]) 25 | { 26 | std::string projectFileLocation = ""; //Example: "/Users/lukehines/Library/Developer/Xcode/DerivedData/xProjgjdr/Build/Products/Debug/TestProj/TestProj.xcodeproj"; 27 | std::string sourceFilePathCSV = ""; //Example: "../tst1.cpp,../tst2.cpp"; 28 | bool restore = false; 29 | 30 | //Get arguments 31 | for(int count = 1; count < argc; count++ ) 32 | { 33 | if(!strcmp(argv[count], "-XCP")) //Xcode project location 34 | { 35 | projectFileLocation = argv[count+1]; 36 | } 37 | if(!strcmp(argv[count], "-SCSV")) //CSV list of source file locations (that must be relative to -XCP location) 38 | { 39 | sourceFilePathCSV = argv[count+1]; 40 | } 41 | if(!strcmp(argv[count], "-RESTORE")) //Flag to restore project from backup 42 | { 43 | restore = true; 44 | } 45 | } 46 | 47 | //Input validation 48 | if(restore) 49 | { 50 | if(projectFileLocation.length() <= 0) 51 | { 52 | std::cout << "Xcode project location is required for restore | \n-XCP = Xcode project location\n"; 53 | return 1; 54 | } 55 | restoreXprojFromBackup(projectFileLocation); 56 | return 0; 57 | } 58 | 59 | //Input validation 60 | if(projectFileLocation.length() <= 0 || sourceFilePathCSV.length() <= 0) 61 | { 62 | std::cout << "atleast XCP with 1 other argument required. \n-XCP = Xcode project location (.xcodeproj) \n-SCSV = CSV list of source file locations relative to the xcode project\n-RESTORE = restore project to backup file\n"; 63 | return 1; 64 | } 65 | 66 | addFilesToXproj(projectFileLocation, sourceFilePathCSV); 67 | 68 | return 0; 69 | } 70 | -------------------------------------------------------------------------------- /XcodeProjAdder/stringMethods.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // stringMethods.cpp 3 | // XcodeProjAdder 4 | // 5 | // Created by Luke Hines on 11/06/2014. 6 | // Copyright (c) 2014 Luke Hines. 7 | // 8 | // DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 9 | // 10 | #include "stringMethods.h" 11 | 12 | std::string getFileExtensionFromFile(std::string &s) 13 | { 14 | return s.substr(s.find_last_of(".") + 1); 15 | } 16 | 17 | std::string getFileNameFromPath(std::string path) 18 | { 19 | std::string filename; 20 | 21 | size_t pos = path.find_last_of("/"); 22 | if(pos != std::string::npos) 23 | filename.assign(path.begin() + pos + 1, path.end()); 24 | else 25 | filename = path; 26 | 27 | return filename; 28 | } 29 | 30 | std::vector &split(const std::string &s, char delim, std::vector &elems) 31 | { 32 | std::stringstream ss(s); 33 | std::string item; 34 | while (std::getline(ss, item, delim)) 35 | { 36 | elems.push_back(item); 37 | } 38 | return elems; 39 | } 40 | 41 | std::vector split(const std::string &s, char delim) 42 | { 43 | std::vector elems; 44 | split(s, delim, elems); 45 | return elems; 46 | } 47 | 48 | std::string trimPast(const std::string &s, const std::string delimiter) 49 | { 50 | size_t pos = s.find(delimiter); 51 | std::string token = (pos != -1) ? s.substr(0, pos) : s; 52 | return token; 53 | } 54 | 55 | std::string trimBefore(const std::string &s, const std::string delimiter) 56 | { 57 | size_t pos = s.find(delimiter); 58 | std::string token = (pos != -1) ? s.substr(pos, s.length()) : s; 59 | return token; 60 | } 61 | 62 | std::string ReplaceString(std::string subject, const std::string& search, const std::string& replace) 63 | { 64 | size_t pos = 0; 65 | while((pos = subject.find(search, pos)) != std::string::npos) 66 | { 67 | subject.replace(pos, search.length(), replace); 68 | pos += replace.length(); 69 | } 70 | return subject; 71 | } 72 | -------------------------------------------------------------------------------- /XcodeProjAdder/stringMethods.h: -------------------------------------------------------------------------------- 1 | // 2 | // stringMethods.h 3 | // XcodeProjAdder 4 | // 5 | // Created by Luke Hines on 11/06/2014. 6 | // Copyright (c) 2014 Luke Hines. 7 | // 8 | // DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 9 | // 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #ifndef XcodeProjAdder_stringMethods_h 16 | #define XcodeProjAdder_stringMethods_h 17 | 18 | //Retriees file extension from file name string 19 | std::string getFileExtensionFromFile(std::string &s); 20 | 21 | //Retrieves filename form path string 22 | std::string getFileNameFromPath(std::string path); 23 | 24 | //Splits string with pre-constructed vector 25 | std::vector &split(const std::string &s, char delim, std::vector &elems); 26 | 27 | //Splits string with new vector 28 | std::vector split(const std::string &s, char delim); 29 | 30 | //Remove everything in string from delimiter onwards 31 | std::string trimPast(const std::string &s, const std::string delimiter); 32 | 33 | //Remove everything in string infront of delimiter 34 | std::string trimBefore(const std::string &s, const std::string delimiter); 35 | 36 | //Replace substring in string 37 | std::string ReplaceString(std::string subject, const std::string& search, const std::string& replace); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /XcodeProjAdder/xprojFileAdder.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // xprojFileAdder.cpp 3 | // XcodeProjAdder 4 | // 5 | // Created by Luke Hines on 11/06/2014. 6 | // Copyright (c) 2014 Luke Hines. 7 | // 8 | // DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 9 | // 10 | 11 | #include 12 | 13 | #include "xprojFileAdder.h" 14 | 15 | void addFilesToXproj(std::string projectFileLocation, std::string sourceFilePathCSV) 16 | { 17 | /* xcode projects '.xcodeproj' is actually a folder, we want to target a file within 18 | this folder so we append this to the users project file path input */ 19 | projectFileLocation = projectFileLocation + "/project.pbxproj"; 20 | 21 | std::string initialProjectContent = IOMethods::get_file_contents(projectFileLocation); 22 | std::string transformedProjectContent = initialProjectContent; 23 | std::vector sourceFilePaths = split(sourceFilePathCSV, ','); 24 | sourceFilePaths = IOMethods::expand_dirs(sourceFilePaths); 25 | std::cout << "\n"; 26 | 27 | for(std::vector::iterator it = sourceFilePaths.begin(); it != sourceFilePaths.end(); ++it) 28 | { 29 | std::string sourceFilePath = *it; 30 | std::string sourceFileName = getFileNameFromPath(sourceFilePath); 31 | std::string fileExt = getFileExtensionFromFile(sourceFileName); 32 | std::cout << sourceFilePath + "\n"; 33 | 34 | //Check this tools compatiblity with file type 35 | if(!ZoneFileTools::isFileTypeSupported(fileExt)) 36 | { 37 | std::cout << "\n ERROR: file type '" + fileExt +"' is currently unsupported by this tool, please remove that file from the CSV and try again (or implement it in src!)\n\n"; 38 | exit(1); 39 | } 40 | 41 | //Generate UUIDs 1 & 2 42 | std::string UUID1 = IOMethods::generateOSXUUID(); 43 | std::string UUID2 = IOMethods::generateOSXUUID(); 44 | 45 | //PBXBuildFile section 46 | if (ZoneFileTools::fileBelongsInArea(fileExt, "PBXBuildFile")) 47 | { 48 | std::string buildFileSectionHeader = "/* Begin PBXBuildFile section */"; 49 | std::string buildFileSectionEntry = " " + UUID1 + " /* " + sourceFileName + " in Sources */ = {isa = PBXBuildFile; fileRef = " + UUID2 + " /* " + sourceFileName + " */; };"; 50 | transformedProjectContent = ReplaceString(transformedProjectContent, buildFileSectionHeader, buildFileSectionHeader + "\n" + buildFileSectionEntry); 51 | } 52 | 53 | //PBXSourcesBuildPhase section 54 | if (ZoneFileTools::fileBelongsInArea(fileExt, "PBXSourcesBuildPhase")) 55 | { 56 | std::string PBXSourcesBuildPhaseHeader = "/* Begin PBXSourcesBuildPhase section */"; 57 | std::string PBXSourcesBuildPhaseFooter = "/* End PBXSourcesBuildPhase section */"; 58 | std::string initialBuildPhaseWholeSection = trimPast(transformedProjectContent, PBXSourcesBuildPhaseFooter); 59 | initialBuildPhaseWholeSection = trimBefore(initialBuildPhaseWholeSection, PBXSourcesBuildPhaseHeader); 60 | initialBuildPhaseWholeSection = trimPast(initialBuildPhaseWholeSection, ");"); 61 | std::string transformedBuildPhaseWholeSection = initialBuildPhaseWholeSection + " " + UUID1 + " /* " + sourceFileName + " in Sources */,\n"; 62 | transformedProjectContent = ReplaceString(transformedProjectContent, initialBuildPhaseWholeSection, transformedBuildPhaseWholeSection); 63 | } 64 | 65 | //PBXFileReference section 66 | if (ZoneFileTools::fileBelongsInArea(fileExt, "PBXFileReference")) 67 | { 68 | std::string PBXFileReferenceHeader = "/* Begin PBXFileReference section */"; 69 | std::string PBXFileReferenceEntry = " " + UUID2 + " /* " + sourceFileName + " */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = " + ZoneFileTools::getIdentifierForFileExtention(fileExt) + "; name = " + sourceFileName + "; path = " + sourceFilePath + "; sourceTree = \"\"; };"; 70 | transformedProjectContent = ReplaceString(transformedProjectContent, PBXFileReferenceHeader, PBXFileReferenceHeader + "\n" + PBXFileReferenceEntry); 71 | } 72 | 73 | //PBXGroup section 74 | if (ZoneFileTools::fileBelongsInArea(fileExt, "PBXGroup")) 75 | { 76 | const std::string PBXGroupHeader="/* Begin PBXGroup section */"; 77 | std::string initialPBXGroupWholeSection = trimBefore(transformedProjectContent, PBXGroupHeader); 78 | initialPBXGroupWholeSection = trimPast(initialPBXGroupWholeSection, ");"); 79 | std::string transformedPBXGroupWhileSection = initialPBXGroupWholeSection + " " + UUID2 + " /* " + sourceFileName + " */,\n"; 80 | transformedProjectContent = ReplaceString(transformedProjectContent, initialPBXGroupWholeSection, transformedPBXGroupWhileSection); 81 | } 82 | 83 | //PBXResourcesBuildPhase section 84 | if (ZoneFileTools::fileBelongsInArea(fileExt, "PBXResourcesBuildPhase")) 85 | { 86 | const std::string PBXResourcesBuildHeader="/* Begin PBXResourcesBuildPhase section */"; 87 | std::string initialPBXResourcesBuildWholeSection = trimBefore(transformedProjectContent, PBXResourcesBuildHeader); 88 | initialPBXResourcesBuildWholeSection = trimPast(initialPBXResourcesBuildWholeSection, ");"); 89 | std::string transformedPBXResourcesBuildWhileSection = initialPBXResourcesBuildWholeSection + " " + UUID1 + " /* " + sourceFileName + " */,\n"; 90 | transformedProjectContent = ReplaceString(transformedProjectContent, initialPBXResourcesBuildWholeSection, transformedPBXResourcesBuildWhileSection); 91 | } 92 | } 93 | 94 | std::cout << "\n"; 95 | std::cout << "New project created\n"; 96 | 97 | std::ofstream out(projectFileLocation); 98 | out << transformedProjectContent; 99 | out.close(); 100 | 101 | //perform intersive logic (build) 102 | std::cout << "Written transformed project\n"; 103 | 104 | //Write backup file to perform a restore 105 | std::ofstream outr(projectFileLocation+"back"); 106 | outr << initialProjectContent; 107 | outr.close(); 108 | std::cout << "Restore file created\n"; 109 | std::cout << "\nCOMPLETE\n\n"; 110 | } 111 | -------------------------------------------------------------------------------- /XcodeProjAdder/xprojFileAdder.h: -------------------------------------------------------------------------------- 1 | // 2 | // xprojFileAdder.h 3 | // XcodeProjAdder 4 | // 5 | // Created by Luke Hines on 11/06/2014. 6 | // Copyright (c) 2014 Luke Hines. 7 | // 8 | // DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 9 | // 10 | 11 | #ifndef XcodeProjAdder_xprojFileAdder_h 12 | #define XcodeProjAdder_xprojFileAdder_h 13 | 14 | #include 15 | #include "stringMethods.h" 16 | #include "IOMethods.h" 17 | #include "xprojRestorer.h" 18 | #include "xprojZoneFileTools.h" 19 | 20 | //Adds a CSV list of relative (to the project) source files to an xcode project 21 | void addFilesToXproj(std::string projectFileLocation, std::string sourceFilePathCSV); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /XcodeProjAdder/xprojRestorer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // xprojRestorer.cpp 3 | // XcodeProjAdder 4 | // 5 | // Created by Luke Hines on 11/06/2014. 6 | // Copyright (c) 2014 Luke Hines. 7 | // 8 | // DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 9 | // 10 | 11 | #include "xprojRestorer.h" 12 | 13 | void restoreXprojFromBackup(std::string projectFileLocation) 14 | { 15 | /* xcode projects '.xcodeproj' is actually a folder, we want to target a file within 16 | * this folder so we append this to the users project file path input */ 17 | projectFileLocation = projectFileLocation+"/project.pbxproj"; 18 | 19 | std::string initialProjectContent = IOMethods::get_file_contents(projectFileLocation+"back"); 20 | std::ofstream out(projectFileLocation); 21 | out << initialProjectContent; 22 | out.close(); 23 | 24 | std::cout << "\nProject Restored\n\n"; 25 | } -------------------------------------------------------------------------------- /XcodeProjAdder/xprojRestorer.h: -------------------------------------------------------------------------------- 1 | // 2 | // xprojRestorer.h 3 | // XcodeProjAdder 4 | // 5 | // Created by Luke Hines on 11/06/2014. 6 | // Copyright (c) 2014 Luke Hines. 7 | // 8 | // DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 9 | // 10 | 11 | #ifndef XcodeProjAdder_xprojRestorer_h 12 | #define XcodeProjAdder_xprojRestorer_h 13 | 14 | #include 15 | #include "stringMethods.h" 16 | #include "IOMethods.h" 17 | 18 | //Restores the backup that is created when files are added to a project 19 | void restoreXprojFromBackup(std::string projectFileLocation); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /XcodeProjAdder/xprojZoneFileTools.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // xprojZoneFileChecker.cpp 3 | // XcodeProjAdder 4 | // 5 | // Created by Luke Hines on 11/06/2014. 6 | // Copyright (c) 2014 Luke Hines. 7 | // 8 | // DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 9 | // 10 | 11 | /* 12 | * ADDING NEW FILE TYPES 13 | * ====================== 14 | * Assuming that the file type only needs to be listed in one of the 5 groups listed in the 'Belongs in area' class 15 | * all that is required to add in a new file type is 16 | * 1.Add its extention into 'supportedFileTypes' vector 17 | * 2.Set the 'Xcode File Type Identifier' for this file type (This can be found in a xcode.proj file after this file has been added) 18 | * 3.Enter the extension into 'eligibleFileTypes' for each group where this should appear (again this is found out by reading through a standard project.pbxproj file) 19 | * 20 | */ 21 | 22 | #include 23 | 24 | #include "xprojZoneFileTools.h" 25 | 26 | //File types currently supported by this tool 27 | vector supportedFileTypes {"cpp", "h", "png", "jpg","m","swift","mp3","ttf","ogg","mm","pem","hpp","c","js"}; 28 | 29 | //Returns the xcode file type ID for a specified file type 30 | string ZoneFileTools::getIdentifierForFileExtention(string fileExtention) 31 | { 32 | string fileIdentifier = ""; 33 | if(fileExtention == supportedFileTypes[0]) 34 | fileIdentifier = "sourcecode.cpp.cpp"; 35 | else if(fileExtention == supportedFileTypes[1]) 36 | fileIdentifier = "sourcecode.c.h"; 37 | else if(fileExtention == supportedFileTypes[2]) 38 | fileIdentifier = "image.png"; 39 | else if(fileExtention == supportedFileTypes[3]) 40 | fileIdentifier = "image.jpeg"; 41 | else if(fileExtention == supportedFileTypes[4]) 42 | fileIdentifier = "sourcecode.c.objc"; 43 | else if(fileExtention == supportedFileTypes[5]) 44 | fileIdentifier = "sourcecode.swift"; 45 | else if(fileExtention == supportedFileTypes[6]) 46 | fileIdentifier = "audio.mp3"; 47 | else if(fileExtention == supportedFileTypes[9]) 48 | fileIdentifier = "sourcecode.cpp.objcpp"; 49 | else if(fileExtention == supportedFileTypes[11]) 50 | fileIdentifier = "sourcecode.cpp.h"; 51 | else if(fileExtention == supportedFileTypes[12]) 52 | fileIdentifier = "sourcecode.c.c"; 53 | else if(fileExtention == supportedFileTypes[13]) 54 | fileIdentifier = "sourcecode.javascript"; 55 | else 56 | return "file"; 57 | 58 | return fileIdentifier; 59 | } 60 | 61 | bool ZoneFileTools::fileBelongsInArea(string fileExtension,string areaID) 62 | { 63 | if(areaID == "PBXBuildFile") 64 | { 65 | vector eligibleFileTypes {supportedFileTypes[0], supportedFileTypes[2], supportedFileTypes[3], supportedFileTypes[4], supportedFileTypes[5],supportedFileTypes[6],supportedFileTypes[7],supportedFileTypes[8],supportedFileTypes[9],supportedFileTypes[10],supportedFileTypes[12],supportedFileTypes[13]}; 66 | return ZoneFileTools::in_array(fileExtension, eligibleFileTypes); 67 | } 68 | else if(areaID == "PBXSourcesBuildPhase") 69 | { 70 | vector eligibleFileTypes {supportedFileTypes[0], supportedFileTypes[4], supportedFileTypes[5],supportedFileTypes[9],supportedFileTypes[12]}; 71 | return ZoneFileTools::in_array(fileExtension, eligibleFileTypes); 72 | } 73 | else if(areaID == "PBXFileReference") 74 | { 75 | vector eligibleFileTypes {supportedFileTypes[0], supportedFileTypes[1], supportedFileTypes[2], supportedFileTypes[3], supportedFileTypes[4], supportedFileTypes[5],supportedFileTypes[6],supportedFileTypes[7],supportedFileTypes[8],supportedFileTypes[9],supportedFileTypes[10],supportedFileTypes[11],supportedFileTypes[12],supportedFileTypes[13]}; 76 | return ZoneFileTools::in_array(fileExtension, eligibleFileTypes); 77 | } 78 | else if(areaID == "PBXGroup") 79 | { 80 | vector eligibleFileTypes {supportedFileTypes[0], supportedFileTypes[1], supportedFileTypes[2], supportedFileTypes[3], supportedFileTypes[4], supportedFileTypes[5],supportedFileTypes[6],supportedFileTypes[7],supportedFileTypes[8],supportedFileTypes[9],supportedFileTypes[10],supportedFileTypes[11],supportedFileTypes[12],supportedFileTypes[13]}; 81 | return ZoneFileTools::in_array(fileExtension, eligibleFileTypes); 82 | } 83 | else if(areaID == "PBXResourcesBuildPhase") 84 | { 85 | vector eligibleFileTypes {supportedFileTypes[2], supportedFileTypes[3],supportedFileTypes[6],supportedFileTypes[7],supportedFileTypes[8],supportedFileTypes[10],supportedFileTypes[13]}; 86 | return ZoneFileTools::in_array(fileExtension, eligibleFileTypes); 87 | } 88 | 89 | return false; 90 | } 91 | 92 | bool ZoneFileTools::isFileTypeSupported(std::string ext) 93 | { 94 | return ZoneFileTools::in_array(ext, supportedFileTypes); 95 | } 96 | 97 | bool ZoneFileTools::in_array(const string &value, const vector &array) 98 | { 99 | return std::find(array.begin(), array.end(), value) != array.end(); 100 | } 101 | -------------------------------------------------------------------------------- /XcodeProjAdder/xprojZoneFileTools.h: -------------------------------------------------------------------------------- 1 | // 2 | // xprojZoneFileChecker.h 3 | // XcodeProjAdder 4 | // 5 | // Created by Luke Hines on 11/06/2014. 6 | // Copyright (c) 2014 Luke Hines. 7 | // 8 | // DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 9 | // 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace std; 17 | 18 | class ZoneFileTools 19 | { 20 | public: 21 | //Checks if a extention file belongs in a perticular Xcode project zone (Going by default Xcode behaviour) 22 | static bool fileBelongsInArea(string fileExtension,string areaID); 23 | 24 | //Retrieves the .pbxproj file type identifier for extension 25 | static string getIdentifierForFileExtention(string fileExtention); 26 | 27 | //Checks if a specific file type is supported by this tool 28 | static bool isFileTypeSupported(std::string ext); 29 | 30 | private: 31 | static bool in_array(const string &value, const vector &array); 32 | }; 33 | -------------------------------------------------------------------------------- /bin/XcodeProjAdder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zackslash/Xcode-Proj-Adder/a5165bce3b03fafdea759a82014d69dfe0f280da/bin/XcodeProjAdder --------------------------------------------------------------------------------