The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1187 lines
48KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCER_PROJECTEXPORT_XCODE_JUCEHEADER__
  19. #define __JUCER_PROJECTEXPORT_XCODE_JUCEHEADER__
  20. #include "jucer_ProjectExporter.h"
  21. namespace
  22. {
  23. const char* const osxVersionDefault = "default";
  24. const char* const osxVersion10_4 = "10.4 SDK";
  25. const char* const osxVersion10_5 = "10.5 SDK";
  26. const char* const osxVersion10_6 = "10.6 SDK";
  27. const char* const osxVersion10_7 = "10.7 SDK";
  28. const char* const osxArch_Default = "default";
  29. const char* const osxArch_Native = "Native";
  30. const char* const osxArch_32BitUniversal = "32BitUniversal";
  31. const char* const osxArch_64BitUniversal = "64BitUniversal";
  32. const char* const osxArch_64Bit = "64BitIntel";
  33. }
  34. //==============================================================================
  35. class XCodeProjectExporter : public ProjectExporter
  36. {
  37. public:
  38. //==============================================================================
  39. static const char* getNameMac() { return "XCode (MacOSX)"; }
  40. static const char* getNameiOS() { return "XCode (iOS)"; }
  41. static const char* getValueTreeTypeName (bool iOS) { return iOS ? "XCODE_IPHONE" : "XCODE_MAC"; }
  42. //==============================================================================
  43. XCodeProjectExporter (Project& project_, const ValueTree& settings_, const bool iOS_)
  44. : ProjectExporter (project_, settings_),
  45. iOS (iOS_)
  46. {
  47. name = iOS ? getNameiOS() : getNameMac();
  48. if (getTargetLocationString().isEmpty())
  49. getTargetLocationValue() = getDefaultBuildsRootFolder() + (iOS ? "iOS" : "MacOSX");
  50. }
  51. static XCodeProjectExporter* createForSettings (Project& project, const ValueTree& settings)
  52. {
  53. if (settings.hasType (getValueTreeTypeName (false)))
  54. return new XCodeProjectExporter (project, settings, false);
  55. else if (settings.hasType (getValueTreeTypeName (true)))
  56. return new XCodeProjectExporter (project, settings, true);
  57. return nullptr;
  58. }
  59. //==============================================================================
  60. Value getPListToMergeValue() { return getSetting ("customPList"); }
  61. String getPListToMergeString() const { return settings ["customPList"]; }
  62. Value getExtraFrameworksValue() { return getSetting (Ids::extraFrameworks); }
  63. String getExtraFrameworksString() const { return settings [Ids::extraFrameworks]; }
  64. Value getPostBuildScriptValue() { return getSetting (Ids::postbuildCommand); }
  65. String getPostBuildScript() const { return settings [Ids::postbuildCommand]; }
  66. int getLaunchPreferenceOrderForCurrentOS()
  67. {
  68. #if JUCE_MAC
  69. return iOS ? 1 : 2;
  70. #else
  71. return 0;
  72. #endif
  73. }
  74. bool isAvailableOnCurrentOS()
  75. {
  76. #if JUCE_MAC
  77. return true;
  78. #else
  79. return false;
  80. #endif
  81. }
  82. bool isPossibleForCurrentProject() { return projectType.isGUIApplication() || ! iOS; }
  83. bool usesMMFiles() const { return true; }
  84. bool isXcode() const { return true; }
  85. bool isOSX() const { return ! iOS; }
  86. bool canCopeWithDuplicateFiles() { return true; }
  87. void createPropertyEditors (PropertyListBuilder& props)
  88. {
  89. ProjectExporter::createPropertyEditors (props);
  90. if (projectType.isGUIApplication() && ! iOS)
  91. {
  92. props.add (new TextPropertyComponent (getSetting ("documentExtensions"), "Document file extensions", 128, false),
  93. "A comma-separated list of file extensions for documents that your app can open.");
  94. }
  95. else if (iOS)
  96. {
  97. props.add (new BooleanPropertyComponent (getSetting ("UIFileSharingEnabled"), "File Sharing Enabled", "Enabled"),
  98. "Enable this to expose your app's files to iTunes.");
  99. props.add (new BooleanPropertyComponent (getSetting ("UIStatusBarHidden"), "Status Bar Hidden", "Enabled"),
  100. "Enable this to disable the status bar in your app.");
  101. }
  102. props.add (new TextPropertyComponent (getPListToMergeValue(), "Custom PList", 8192, true),
  103. "You can paste the contents of an XML PList file in here, and the settings that it contains will override any "
  104. "settings that the Introjucer creates. BEWARE! When doing this, be careful to remove from the XML any "
  105. "values that you DO want the introjucer to change!");
  106. props.add (new TextPropertyComponent (getExtraFrameworksValue(), "Extra Frameworks", 2048, false),
  107. "A comma-separated list of extra frameworks that should be added to the build. "
  108. "(Don't include the .framework extension in the name)");
  109. if (projectType.isLibrary())
  110. {
  111. const char* const libTypes[] = { "Static Library (.a)", "Dynamic Library (.dylib)", 0 };
  112. const int libTypeValues[] = { 1, 2, 0 };
  113. props.add (new ChoicePropertyComponent (getLibraryType(), "Library Type",
  114. StringArray (libTypes), Array<var> (libTypeValues)));
  115. }
  116. props.add (new TextPropertyComponent (getPostBuildScriptValue(), "Post-build shell script", 32768, true),
  117. "Some shell-script that will be run after a build completes.");
  118. }
  119. void launchProject()
  120. {
  121. getProjectBundle().startAsProcess();
  122. }
  123. //==============================================================================
  124. void create (const OwnedArray<LibraryModule>&) const
  125. {
  126. infoPlistFile = getTargetFolder().getChildFile ("Info.plist");
  127. createIconFile();
  128. File projectBundle (getProjectBundle());
  129. createDirectoryOrThrow (projectBundle);
  130. createObjects();
  131. File projectFile (projectBundle.getChildFile ("project.pbxproj"));
  132. {
  133. MemoryOutputStream mo;
  134. writeProjectFile (mo);
  135. overwriteFileIfDifferentOrThrow (projectFile, mo);
  136. }
  137. writeInfoPlistFile();
  138. }
  139. protected:
  140. Value getLibraryType() { return getSetting (Ids::libraryType); }
  141. bool isStaticLibrary() const { return projectType.isLibrary() && (int) settings [Ids::libraryType] == 1; }
  142. //==============================================================================
  143. class XcodeBuildConfiguration : public BuildConfiguration
  144. {
  145. public:
  146. XcodeBuildConfiguration (Project& project, const ValueTree& settings, const bool iOS_)
  147. : BuildConfiguration (project, settings), iOS (iOS_)
  148. {
  149. }
  150. Value getMacSDKVersionValue() { return getValue (Ids::osxSDK); }
  151. String getMacSDKVersion() const { return config [Ids::osxSDK]; }
  152. Value getMacCompatibilityVersionValue() { return getValue (Ids::osxCompatibility); }
  153. String getMacCompatibilityVersion() const { return config [Ids::osxCompatibility]; }
  154. Value getiOSCompatibilityVersionValue() { return getValue (Ids::iosCompatibility); }
  155. String getiOSCompatibilityVersion() const { return config [Ids::iosCompatibility]; }
  156. Value getMacArchitectureValue() { return getValue (Ids::osxArchitecture); }
  157. String getMacArchitecture() const { return config [Ids::osxArchitecture]; }
  158. Value getCustomXcodeFlagsValue() { return getValue (Ids::customXcodeFlags); }
  159. String getCustomXcodeFlags() const { return config [Ids::customXcodeFlags]; }
  160. Value getCppLibTypeValue() { return getValue (Ids::cppLibType); }
  161. String getCppLibType() const { return config [Ids::cppLibType]; }
  162. void createPropertyEditors (PropertyListBuilder& props)
  163. {
  164. createBasicPropertyEditors (props);
  165. if (iOS)
  166. {
  167. if (getiOSCompatibilityVersion().isEmpty())
  168. getiOSCompatibilityVersionValue() = osxVersionDefault;
  169. const char* iosVersions[] = { "Use Default", "3.2", "4.0", "4.1", "4.2", "4.3", "5.0", "5.1", 0 };
  170. const char* iosVersionValues[] = { osxVersionDefault, "3.2", "4.0", "4.1", "4.2", "4.3", "5.0", "5.1", 0 };
  171. props.add (new ChoicePropertyComponent (getiOSCompatibilityVersionValue(), "iOS Deployment Target",
  172. StringArray (iosVersions), Array<var> (iosVersionValues)),
  173. "The minimum version of iOS that the target binary will run on.");
  174. }
  175. else
  176. {
  177. if (getMacSDKVersion().isEmpty())
  178. getMacSDKVersionValue() = osxVersionDefault;
  179. if (getMacCompatibilityVersion().isEmpty())
  180. getMacCompatibilityVersionValue() = osxVersionDefault;
  181. const char* osxVersions[] = { "Use Default", osxVersion10_5, osxVersion10_6, osxVersion10_7, 0 };
  182. const char* osxVersionValues[] = { osxVersionDefault, osxVersion10_5, osxVersion10_6, osxVersion10_7, 0 };
  183. props.add (new ChoicePropertyComponent (getMacSDKVersionValue(), "OSX Base SDK Version",
  184. StringArray (osxVersions), Array<var> (osxVersionValues)),
  185. "The version of OSX to link against in the XCode build.");
  186. props.add (new ChoicePropertyComponent (getMacCompatibilityVersionValue(), "OSX Compatibility Version",
  187. StringArray (osxVersions), Array<var> (osxVersionValues)),
  188. "The minimum version of OSX that the target binary will be compatible with.");
  189. if (getMacArchitecture().isEmpty())
  190. getMacArchitectureValue() = osxArch_Default;
  191. const char* osxArch[] = { "Use Default", "Native architecture of build machine",
  192. "Universal Binary (32-bit)", "Universal Binary (64-bit)", "64-bit Intel", 0 };
  193. const char* osxArchValues[] = { osxArch_Default, osxArch_Native, osxArch_32BitUniversal,
  194. osxArch_64BitUniversal, osxArch_64Bit, 0 };
  195. props.add (new ChoicePropertyComponent (getMacArchitectureValue(), "OSX Architecture",
  196. StringArray (osxArch), Array<var> (osxArchValues)),
  197. "The type of OSX binary that will be produced.");
  198. }
  199. props.add (new TextPropertyComponent (getCustomXcodeFlagsValue(), "Custom Xcode flags", 8192, false),
  200. "A comma-separated list of custom Xcode setting flags which will be appended to the list of generated flags, "
  201. "e.g. MACOSX_DEPLOYMENT_TARGET_i386 = 10.5, VALID_ARCHS = \"ppc i386 x86_64\"");
  202. const char* cppLibNames[] = { "Use Default", "Use LLVM libc++", 0 };
  203. Array<var> cppLibValues;
  204. cppLibValues.add (var::null);
  205. cppLibValues.add ("libc++");
  206. props.add (new ChoicePropertyComponent (getCppLibTypeValue(), "C++ Library", StringArray (cppLibNames), cppLibValues),
  207. "The type of C++ std lib that will be linked.");
  208. }
  209. bool iOS;
  210. };
  211. BuildConfiguration::Ptr createBuildConfig (const ValueTree& settings) const
  212. {
  213. return new XcodeBuildConfiguration (project, settings, iOS);
  214. }
  215. private:
  216. mutable OwnedArray<ValueTree> pbxBuildFiles, pbxFileReferences, pbxGroups, misc, projectConfigs, targetConfigs;
  217. mutable StringArray buildPhaseIDs, resourceIDs, sourceIDs, frameworkIDs;
  218. mutable StringArray frameworkFileIDs, rezFileIDs, resourceFileRefs;
  219. mutable File infoPlistFile, iconFile;
  220. const bool iOS;
  221. static String sanitisePath (const String& path)
  222. {
  223. if (path.startsWithChar ('~'))
  224. return "$(HOME)" + path.substring (1);
  225. return path;
  226. }
  227. File getProjectBundle() const { return getTargetFolder().getChildFile (project.getProjectFilenameRoot()).withFileExtension (".xcodeproj"); }
  228. //==============================================================================
  229. void createObjects() const
  230. {
  231. addFrameworks();
  232. addMainBuildProduct();
  233. if (xcodeCreatePList)
  234. {
  235. RelativePath plistPath (infoPlistFile, getTargetFolder(), RelativePath::buildTargetFolder);
  236. addFileReference (plistPath.toUnixStyle());
  237. resourceFileRefs.add (createFileRefID (plistPath));
  238. }
  239. if (iconFile.exists())
  240. {
  241. RelativePath iconPath (iconFile, getTargetFolder(), RelativePath::buildTargetFolder);
  242. addFileReference (iconPath.toUnixStyle());
  243. resourceIDs.add (addBuildFile (iconPath, false, false));
  244. resourceFileRefs.add (createFileRefID (iconPath));
  245. }
  246. {
  247. StringArray topLevelGroupIDs;
  248. for (int i = 0; i < groups.size(); ++i)
  249. if (groups.getReference(i).getNumChildren() > 0)
  250. topLevelGroupIDs.add (addProjectItem (groups.getReference(i)));
  251. { // Add 'resources' group
  252. String resourcesGroupID (createID ("__resources"));
  253. addGroup (resourcesGroupID, "Resources", resourceFileRefs);
  254. topLevelGroupIDs.add (resourcesGroupID);
  255. }
  256. { // Add 'frameworks' group
  257. String frameworksGroupID (createID ("__frameworks"));
  258. addGroup (frameworksGroupID, "Frameworks", frameworkFileIDs);
  259. topLevelGroupIDs.add (frameworksGroupID);
  260. }
  261. { // Add 'products' group
  262. String productsGroupID (createID ("__products"));
  263. StringArray products;
  264. products.add (createID ("__productFileID"));
  265. addGroup (productsGroupID, "Products", products);
  266. topLevelGroupIDs.add (productsGroupID);
  267. }
  268. addGroup (createID ("__mainsourcegroup"), "Source", topLevelGroupIDs);
  269. }
  270. for (ConstConfigIterator config (*this); config.next();)
  271. {
  272. const XcodeBuildConfiguration& xcodeConfig = dynamic_cast <const XcodeBuildConfiguration&> (*config);
  273. addProjectConfig (config->getName(), getProjectSettings (xcodeConfig));
  274. addTargetConfig (config->getName(), getTargetSettings (xcodeConfig));
  275. }
  276. addConfigList (projectConfigs, createID ("__projList"));
  277. addConfigList (targetConfigs, createID ("__configList"));
  278. if (! isStaticLibrary())
  279. addBuildPhase ("PBXResourcesBuildPhase", resourceIDs);
  280. if (rezFileIDs.size() > 0)
  281. addBuildPhase ("PBXRezBuildPhase", rezFileIDs);
  282. addBuildPhase ("PBXSourcesBuildPhase", sourceIDs);
  283. if (! isStaticLibrary())
  284. addBuildPhase ("PBXFrameworksBuildPhase", frameworkIDs);
  285. addShellScriptPhase();
  286. addTargetObject();
  287. addProjectObject();
  288. }
  289. static Image fixMacIconImageSize (Image& image)
  290. {
  291. const int validSizes[] = { 16, 32, 48, 128 };
  292. const int w = image.getWidth();
  293. const int h = image.getHeight();
  294. int bestSize = 16;
  295. for (int i = 0; i < numElementsInArray (validSizes); ++i)
  296. {
  297. if (w == h && w == validSizes[i])
  298. return image;
  299. if (jmax (w, h) > validSizes[i])
  300. bestSize = validSizes[i];
  301. }
  302. return rescaleImageForIcon (image, bestSize);
  303. }
  304. void writeIcnsFile (const Array<Image>& images, OutputStream& out) const
  305. {
  306. MemoryOutputStream data;
  307. for (int i = 0; i < images.size(); ++i)
  308. {
  309. Image image (fixMacIconImageSize (images.getReference (i)));
  310. const int w = image.getWidth();
  311. const int h = image.getHeight();
  312. jassert (w == h);
  313. const char* type = nullptr;
  314. const char* maskType = nullptr;
  315. if (w == 16) { type = "is32"; maskType = "s8mk"; }
  316. if (w == 32) { type = "il32"; maskType = "l8mk"; }
  317. if (w == 48) { type = "ih32"; maskType = "h8mk"; }
  318. if (w == 128) { type = "it32"; maskType = "t8mk"; }
  319. if (type != nullptr)
  320. {
  321. data.write (type, 4);
  322. data.writeIntBigEndian (8 + 4 * w * h);
  323. const Image::BitmapData bitmap (image, Image::BitmapData::readOnly);
  324. int y;
  325. for (y = 0; y < h; ++y)
  326. {
  327. for (int x = 0; x < w; ++x)
  328. {
  329. const Colour pixel (bitmap.getPixelColour (x, y));
  330. data.writeByte ((char) pixel.getAlpha());
  331. data.writeByte ((char) pixel.getRed());
  332. data.writeByte ((char) pixel.getGreen());
  333. data.writeByte ((char) pixel.getBlue());
  334. }
  335. }
  336. data.write (maskType, 4);
  337. data.writeIntBigEndian (8 + w * h);
  338. for (y = 0; y < h; ++y)
  339. {
  340. for (int x = 0; x < w; ++x)
  341. {
  342. const Colour pixel (bitmap.getPixelColour (x, y));
  343. data.writeByte ((char) pixel.getAlpha());
  344. }
  345. }
  346. }
  347. }
  348. jassert (data.getDataSize() > 0); // no suitable sized images?
  349. out.write ("icns", 4);
  350. out.writeIntBigEndian (data.getDataSize() + 8);
  351. out << data;
  352. }
  353. void createIconFile() const
  354. {
  355. Array<Image> images;
  356. Image bigIcon (getBigIcon());
  357. if (bigIcon.isValid())
  358. images.add (bigIcon);
  359. Image smallIcon (getSmallIcon());
  360. if (smallIcon.isValid())
  361. images.add (smallIcon);
  362. if (images.size() > 0)
  363. {
  364. MemoryOutputStream mo;
  365. writeIcnsFile (images, mo);
  366. iconFile = getTargetFolder().getChildFile ("Icon.icns");
  367. overwriteFileIfDifferentOrThrow (iconFile, mo);
  368. }
  369. }
  370. void writeInfoPlistFile() const
  371. {
  372. if (! xcodeCreatePList)
  373. return;
  374. ScopedPointer<XmlElement> plist (XmlDocument::parse (getPListToMergeString()));
  375. if (plist == nullptr || ! plist->hasTagName ("plist"))
  376. plist = new XmlElement ("plist");
  377. XmlElement* dict = plist->getChildByName ("dict");
  378. if (dict == nullptr)
  379. dict = plist->createNewChildElement ("dict");
  380. if (iOS)
  381. addPlistDictionaryKeyBool (dict, "LSRequiresIPhoneOS", true);
  382. addPlistDictionaryKey (dict, "CFBundleExecutable", "${EXECUTABLE_NAME}");
  383. addPlistDictionaryKey (dict, "CFBundleIconFile", iconFile.exists() ? iconFile.getFileName() : String::empty);
  384. addPlistDictionaryKey (dict, "CFBundleIdentifier", project.getBundleIdentifier().toString());
  385. addPlistDictionaryKey (dict, "CFBundleName", projectName);
  386. addPlistDictionaryKey (dict, "CFBundlePackageType", xcodePackageType);
  387. addPlistDictionaryKey (dict, "CFBundleSignature", xcodeBundleSignature);
  388. addPlistDictionaryKey (dict, "CFBundleShortVersionString", project.getVersionString());
  389. addPlistDictionaryKey (dict, "CFBundleVersion", project.getVersionString());
  390. addPlistDictionaryKey (dict, "NSHumanReadableCopyright", project.getCompanyName().toString());
  391. StringArray documentExtensions;
  392. documentExtensions.addTokens (replacePreprocessorDefs (getAllPreprocessorDefs(), settings ["documentExtensions"]),
  393. ",", String::empty);
  394. documentExtensions.trim();
  395. documentExtensions.removeEmptyStrings (true);
  396. if (documentExtensions.size() > 0)
  397. {
  398. dict->createNewChildElement ("key")->addTextElement ("CFBundleDocumentTypes");
  399. XmlElement* dict2 = dict->createNewChildElement ("array")->createNewChildElement ("dict");
  400. for (int i = 0; i < documentExtensions.size(); ++i)
  401. {
  402. String ex (documentExtensions[i]);
  403. if (ex.startsWithChar ('.'))
  404. ex = ex.substring (1);
  405. dict2->createNewChildElement ("key")->addTextElement ("CFBundleTypeExtensions");
  406. dict2->createNewChildElement ("array")->createNewChildElement ("string")->addTextElement (ex);
  407. addPlistDictionaryKey (dict2, "CFBundleTypeName", ex);
  408. addPlistDictionaryKey (dict2, "CFBundleTypeRole", "Editor");
  409. addPlistDictionaryKey (dict2, "NSPersistentStoreTypeKey", "XML");
  410. }
  411. }
  412. if (settings ["UIFileSharingEnabled"])
  413. addPlistDictionaryKeyBool (dict, "UIFileSharingEnabled", true);
  414. if (settings ["UIStatusBarHidden"])
  415. addPlistDictionaryKeyBool (dict, "UIStatusBarHidden", true);
  416. for (int i = 0; i < xcodeExtraPListEntries.size(); ++i)
  417. dict->addChildElement (new XmlElement (xcodeExtraPListEntries.getReference(i)));
  418. MemoryOutputStream mo;
  419. plist->writeToStream (mo, "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
  420. overwriteFileIfDifferentOrThrow (infoPlistFile, mo);
  421. }
  422. StringArray getHeaderSearchPaths (const BuildConfiguration& config) const
  423. {
  424. StringArray searchPaths (extraSearchPaths);
  425. searchPaths.addArray (config.getHeaderSearchPaths());
  426. searchPaths.removeDuplicates (false);
  427. return searchPaths;
  428. }
  429. static void getLinkerFlagsForStaticLibrary (const RelativePath& library, StringArray& flags, StringArray& librarySearchPaths)
  430. {
  431. jassert (library.getFileNameWithoutExtension().substring (0, 3) == "lib");
  432. flags.add ("-l" + library.getFileNameWithoutExtension().substring (3));
  433. String searchPath (library.toUnixStyle().upToLastOccurrenceOf ("/", false, false));
  434. if (! library.isAbsolute())
  435. searchPath = "$(SRCROOT)/" + searchPath;
  436. librarySearchPaths.add (sanitisePath (searchPath));
  437. }
  438. void getLinkerFlags (const BuildConfiguration& config, StringArray& flags, StringArray& librarySearchPaths) const
  439. {
  440. if (xcodeIsBundle)
  441. flags.add ("-bundle");
  442. const Array<RelativePath>& extraLibs = config.isDebug() ? xcodeExtraLibrariesDebug
  443. : xcodeExtraLibrariesRelease;
  444. for (int i = 0; i < extraLibs.size(); ++i)
  445. getLinkerFlagsForStaticLibrary (extraLibs.getReference(i), flags, librarySearchPaths);
  446. flags.add (replacePreprocessorTokens (config, getExtraLinkerFlagsString()));
  447. flags.removeEmptyStrings (true);
  448. }
  449. StringArray getProjectSettings (const XcodeBuildConfiguration& config) const
  450. {
  451. StringArray s;
  452. s.add ("ALWAYS_SEARCH_USER_PATHS = NO");
  453. s.add ("GCC_C_LANGUAGE_STANDARD = c99");
  454. s.add ("GCC_WARN_ABOUT_RETURN_TYPE = YES");
  455. s.add ("GCC_WARN_CHECK_SWITCH_STATEMENTS = YES");
  456. s.add ("GCC_WARN_UNUSED_VARIABLE = YES");
  457. s.add ("GCC_WARN_MISSING_PARENTHESES = YES");
  458. s.add ("GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES");
  459. s.add ("GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES");
  460. s.add ("WARNING_CFLAGS = -Wreorder");
  461. s.add ("GCC_MODEL_TUNING = G5");
  462. if (projectType.isLibrary())
  463. {
  464. s.add ("GCC_INLINES_ARE_PRIVATE_EXTERN = NO");
  465. s.add ("GCC_SYMBOLS_PRIVATE_EXTERN = NO");
  466. }
  467. else
  468. {
  469. s.add ("GCC_INLINES_ARE_PRIVATE_EXTERN = YES");
  470. }
  471. if (iOS)
  472. {
  473. s.add ("\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\"");
  474. s.add ("SDKROOT = iphoneos");
  475. s.add ("TARGETED_DEVICE_FAMILY = \"1,2\"");
  476. const String iosVersion (config.getiOSCompatibilityVersion());
  477. if (iosVersion.isNotEmpty() && iosVersion != osxVersionDefault)
  478. s.add ("IPHONEOS_DEPLOYMENT_TARGET = " + iosVersion);
  479. }
  480. s.add ("ZERO_LINK = NO");
  481. if (xcodeCanUseDwarf)
  482. s.add ("DEBUG_INFORMATION_FORMAT = \"dwarf\"");
  483. s.add ("PRODUCT_NAME = \"" + config.getTargetBinaryNameString() + "\"");
  484. return s;
  485. }
  486. StringArray getTargetSettings (const XcodeBuildConfiguration& config) const
  487. {
  488. StringArray s;
  489. const String arch (config.getMacArchitecture());
  490. if (arch == osxArch_Native) s.add ("ARCHS = \"$(ARCHS_NATIVE)\"");
  491. else if (arch == osxArch_32BitUniversal) s.add ("ARCHS = \"$(ARCHS_STANDARD_32_BIT)\"");
  492. else if (arch == osxArch_64BitUniversal) s.add ("ARCHS = \"$(ARCHS_STANDARD_32_64_BIT)\"");
  493. else if (arch == osxArch_64Bit) s.add ("ARCHS = \"$(ARCHS_STANDARD_64_BIT)\"");
  494. s.add ("HEADER_SEARCH_PATHS = \"" + replacePreprocessorTokens (config, getHeaderSearchPaths (config).joinIntoString (" ")) + " $(inherited)\"");
  495. s.add ("GCC_OPTIMIZATION_LEVEL = " + config.getGCCOptimisationFlag());
  496. s.add ("INFOPLIST_FILE = " + infoPlistFile.getFileName());
  497. const String extraFlags (replacePreprocessorTokens (config, getExtraCompilerFlagsString()).trim());
  498. if (extraFlags.isNotEmpty())
  499. s.add ("OTHER_CPLUSPLUSFLAGS = \"" + extraFlags + "\"");
  500. if (xcodeProductInstallPath.isNotEmpty())
  501. s.add ("INSTALL_PATH = \"" + xcodeProductInstallPath + "\"");
  502. if (xcodeIsBundle)
  503. {
  504. s.add ("LIBRARY_STYLE = Bundle");
  505. s.add ("WRAPPER_EXTENSION = " + xcodeBundleExtension.substring (1));
  506. s.add ("GENERATE_PKGINFO_FILE = YES");
  507. }
  508. if (xcodeOtherRezFlags.isNotEmpty())
  509. s.add ("OTHER_REZFLAGS = \"" + xcodeOtherRezFlags + "\"");
  510. if (projectType.isLibrary())
  511. {
  512. if (config.getTargetBinaryRelativePathString().isNotEmpty())
  513. {
  514. RelativePath binaryPath (config.getTargetBinaryRelativePathString(), RelativePath::projectFolder);
  515. binaryPath = binaryPath.rebased (projectFolder, getTargetFolder(), RelativePath::buildTargetFolder);
  516. s.add ("DSTROOT = " + sanitisePath (binaryPath.toUnixStyle()));
  517. s.add ("SYMROOT = " + sanitisePath (binaryPath.toUnixStyle()));
  518. }
  519. s.add ("CONFIGURATION_BUILD_DIR = \"$(BUILD_DIR)\"");
  520. s.add ("DEPLOYMENT_LOCATION = YES");
  521. }
  522. String gccVersion ("com.apple.compilers.llvm.clang.1_0");
  523. if (! iOS)
  524. {
  525. const String sdk (config.getMacSDKVersion());
  526. const String sdkCompat (config.getMacCompatibilityVersion());
  527. if (sdk == osxVersion10_5) s.add ("SDKROOT = macosx10.5");
  528. else if (sdk == osxVersion10_6) s.add ("SDKROOT = macosx10.6");
  529. else if (sdk == osxVersion10_7) s.add ("SDKROOT = macosx10.7");
  530. if (sdkCompat == osxVersion10_4) s.add ("MACOSX_DEPLOYMENT_TARGET = 10.4");
  531. else if (sdkCompat == osxVersion10_5) s.add ("MACOSX_DEPLOYMENT_TARGET = 10.5");
  532. else if (sdkCompat == osxVersion10_6) s.add ("MACOSX_DEPLOYMENT_TARGET = 10.6");
  533. else if (sdkCompat == osxVersion10_7) s.add ("MACOSX_DEPLOYMENT_TARGET = 10.7");
  534. s.add ("MACOSX_DEPLOYMENT_TARGET_ppc = 10.4");
  535. s.add ("SDKROOT_ppc = macosx10.5");
  536. if (xcodeExcludedFiles64Bit.isNotEmpty())
  537. {
  538. s.add ("EXCLUDED_SOURCE_FILE_NAMES = \"$(EXCLUDED_SOURCE_FILE_NAMES_$(CURRENT_ARCH))\"");
  539. s.add ("EXCLUDED_SOURCE_FILE_NAMES_x86_64 = " + xcodeExcludedFiles64Bit);
  540. }
  541. }
  542. s.add ("GCC_VERSION = " + gccVersion);
  543. s.add ("CLANG_CXX_LANGUAGE_STANDARD = \"c++0x\"");
  544. if (config.getCppLibType().isNotEmpty())
  545. s.add ("CLANG_CXX_LIBRARY = " + config.getCppLibType().quoted());
  546. {
  547. StringArray linkerFlags, librarySearchPaths;
  548. getLinkerFlags (config, linkerFlags, librarySearchPaths);
  549. if (linkerFlags.size() > 0)
  550. s.add ("OTHER_LDFLAGS = \"" + linkerFlags.joinIntoString (" ") + "\"");
  551. librarySearchPaths.addArray (config.getLibrarySearchPaths());
  552. librarySearchPaths.removeDuplicates (false);
  553. if (librarySearchPaths.size() > 0)
  554. {
  555. String libPaths ("LIBRARY_SEARCH_PATHS = (\"$(inherited)\"");
  556. for (int i = 0; i < librarySearchPaths.size(); ++i)
  557. libPaths += ", \"\\\"" + librarySearchPaths[i] + "\\\"\"";
  558. s.add (libPaths + ")");
  559. }
  560. }
  561. StringPairArray defines;
  562. if (config.isDebug())
  563. {
  564. defines.set ("_DEBUG", "1");
  565. defines.set ("DEBUG", "1");
  566. s.add ("ONLY_ACTIVE_ARCH = YES");
  567. s.add ("COPY_PHASE_STRIP = NO");
  568. s.add ("GCC_DYNAMIC_NO_PIC = NO");
  569. }
  570. else
  571. {
  572. defines.set ("_NDEBUG", "1");
  573. defines.set ("NDEBUG", "1");
  574. s.add ("GCC_GENERATE_DEBUGGING_SYMBOLS = NO");
  575. s.add ("GCC_SYMBOLS_PRIVATE_EXTERN = YES");
  576. }
  577. {
  578. defines = mergePreprocessorDefs (defines, getAllPreprocessorDefs (config));
  579. StringArray defsList;
  580. for (int i = 0; i < defines.size(); ++i)
  581. {
  582. String def (defines.getAllKeys()[i]);
  583. const String value (defines.getAllValues()[i]);
  584. if (value.isNotEmpty())
  585. def << "=" << value;
  586. defsList.add (def.quoted());
  587. }
  588. s.add ("GCC_PREPROCESSOR_DEFINITIONS = (" + indentList (defsList, ",") + ")");
  589. }
  590. s.addTokens (config.getCustomXcodeFlags(), ",", "\"'");
  591. s.trim();
  592. s.removeEmptyStrings();
  593. s.removeDuplicates (false);
  594. return s;
  595. }
  596. void addFrameworks() const
  597. {
  598. if (! isStaticLibrary())
  599. {
  600. StringArray s (xcodeFrameworks);
  601. s.addTokens (getExtraFrameworksString(), ",;", "\"'");
  602. s.trim();
  603. s.removeDuplicates (true);
  604. s.sort (true);
  605. for (int i = 0; i < s.size(); ++i)
  606. addFramework (s[i]);
  607. }
  608. }
  609. //==============================================================================
  610. void writeProjectFile (OutputStream& output) const
  611. {
  612. output << "// !$*UTF8*$!\n{\n"
  613. "\tarchiveVersion = 1;\n"
  614. "\tclasses = {\n\t};\n"
  615. "\tobjectVersion = 46;\n"
  616. "\tobjects = {\n\n";
  617. Array <ValueTree*> objects;
  618. objects.addArray (pbxBuildFiles);
  619. objects.addArray (pbxFileReferences);
  620. objects.addArray (pbxGroups);
  621. objects.addArray (targetConfigs);
  622. objects.addArray (projectConfigs);
  623. objects.addArray (misc);
  624. for (int i = 0; i < objects.size(); ++i)
  625. {
  626. ValueTree& o = *objects.getUnchecked(i);
  627. output << "\t\t" << o.getType().toString() << " = { ";
  628. for (int j = 0; j < o.getNumProperties(); ++j)
  629. {
  630. const Identifier propertyName (o.getPropertyName(j));
  631. String val (o.getProperty (propertyName).toString());
  632. if (val.isEmpty() || (val.containsAnyOf (" \t;<>()=,&+-_\r\n")
  633. && ! (val.trimStart().startsWithChar ('(')
  634. || val.trimStart().startsWithChar ('{'))))
  635. val = val.quoted();
  636. output << propertyName.toString() << " = " << val << "; ";
  637. }
  638. output << "};\n";
  639. }
  640. output << "\t};\n\trootObject = " << createID ("__root") << ";\n}\n";
  641. }
  642. static void addPlistDictionaryKey (XmlElement* xml, const String& key, const String& value)
  643. {
  644. forEachXmlChildElementWithTagName (*xml, e, "key")
  645. {
  646. if (e->getAllSubText().trim().equalsIgnoreCase (key))
  647. {
  648. if (e->getNextElement() != nullptr && e->getNextElement()->hasTagName ("key"))
  649. {
  650. // try to fix broken plist format..
  651. xml->removeChildElement (e, true);
  652. break;
  653. }
  654. else
  655. {
  656. return; // (value already exists)
  657. }
  658. }
  659. }
  660. xml->createNewChildElement ("key") ->addTextElement (key);
  661. xml->createNewChildElement ("string")->addTextElement (value);
  662. }
  663. static void addPlistDictionaryKeyBool (XmlElement* xml, const String& key, const bool value)
  664. {
  665. xml->createNewChildElement ("key")->addTextElement (key);
  666. xml->createNewChildElement (value ? "true" : "false");
  667. }
  668. String addBuildFile (const String& path, const String& fileRefID, bool addToSourceBuildPhase, bool inhibitWarnings) const
  669. {
  670. String fileID (createID (path + "buildref"));
  671. if (addToSourceBuildPhase)
  672. sourceIDs.add (fileID);
  673. ValueTree* v = new ValueTree (fileID);
  674. v->setProperty ("isa", "PBXBuildFile", 0);
  675. v->setProperty ("fileRef", fileRefID, 0);
  676. if (inhibitWarnings)
  677. v->setProperty ("settings", "{COMPILER_FLAGS = \"-w\"; }", 0);
  678. pbxBuildFiles.add (v);
  679. return fileID;
  680. }
  681. String addBuildFile (const RelativePath& path, bool addToSourceBuildPhase, bool inhibitWarnings) const
  682. {
  683. return addBuildFile (path.toUnixStyle(), createFileRefID (path), addToSourceBuildPhase, inhibitWarnings);
  684. }
  685. String addFileReference (String pathString) const
  686. {
  687. String sourceTree ("SOURCE_ROOT");
  688. RelativePath path (pathString, RelativePath::unknown);
  689. if (pathString.startsWith ("${"))
  690. {
  691. sourceTree = pathString.substring (2).upToFirstOccurrenceOf ("}", false, false);
  692. pathString = pathString.fromFirstOccurrenceOf ("}/", false, false);
  693. }
  694. else if (path.isAbsolute())
  695. {
  696. sourceTree = "<absolute>";
  697. }
  698. const String fileRefID (createFileRefID (pathString));
  699. ScopedPointer<ValueTree> v (new ValueTree (fileRefID));
  700. v->setProperty ("isa", "PBXFileReference", 0);
  701. v->setProperty ("lastKnownFileType", getFileType (path), 0);
  702. v->setProperty (Ids::name, pathString.fromLastOccurrenceOf ("/", false, false), 0);
  703. v->setProperty ("path", sanitisePath (pathString), 0);
  704. v->setProperty ("sourceTree", sourceTree, 0);
  705. const int existing = pbxFileReferences.indexOfSorted (*this, v);
  706. if (existing >= 0)
  707. {
  708. // If this fails, there's either a string hash collision, or the same file is being added twice (incorrectly)
  709. jassert (pbxFileReferences.getUnchecked (existing)->isEquivalentTo (*v));
  710. }
  711. else
  712. {
  713. pbxFileReferences.addSorted (*this, v.release());
  714. }
  715. return fileRefID;
  716. }
  717. public:
  718. static int compareElements (const ValueTree* first, const ValueTree* second)
  719. {
  720. return first->getType().getCharPointer().compare (second->getType().getCharPointer());
  721. }
  722. private:
  723. static String getFileType (const RelativePath& file)
  724. {
  725. if (file.hasFileExtension ("cpp;cc;cxx")) return "sourcecode.cpp.cpp";
  726. else if (file.hasFileExtension (".mm")) return "sourcecode.cpp.objcpp";
  727. else if (file.hasFileExtension (".m")) return "sourcecode.c.objc";
  728. else if (file.hasFileExtension (headerFileExtensions)) return "sourcecode.c.h";
  729. else if (file.hasFileExtension (".framework")) return "wrapper.framework";
  730. else if (file.hasFileExtension (".jpeg;.jpg")) return "image.jpeg";
  731. else if (file.hasFileExtension ("png;gif")) return "image" + file.getFileExtension();
  732. else if (file.hasFileExtension ("html;htm")) return "text.html";
  733. else if (file.hasFileExtension ("xml;zip;wav")) return "file" + file.getFileExtension();
  734. else if (file.hasFileExtension ("txt;rtf")) return "text" + file.getFileExtension();
  735. else if (file.hasFileExtension ("plist")) return "text.plist.xml";
  736. else if (file.hasFileExtension ("app")) return "wrapper.application";
  737. else if (file.hasFileExtension ("component;vst;plugin")) return "wrapper.cfbundle";
  738. else if (file.hasFileExtension ("xcodeproj")) return "wrapper.pb-project";
  739. else if (file.hasFileExtension ("a")) return "archive.ar";
  740. return "file" + file.getFileExtension();
  741. }
  742. String addFile (const RelativePath& path, bool shouldBeCompiled, bool inhibitWarnings) const
  743. {
  744. const String pathAsString (path.toUnixStyle());
  745. const String refID (addFileReference (path.toUnixStyle()));
  746. if (shouldBeCompiled)
  747. {
  748. if (path.hasFileExtension (".r"))
  749. rezFileIDs.add (addBuildFile (pathAsString, refID, false, inhibitWarnings));
  750. else
  751. addBuildFile (pathAsString, refID, true, inhibitWarnings);
  752. }
  753. return refID;
  754. }
  755. String addProjectItem (const Project::Item& projectItem) const
  756. {
  757. if (projectItem.isGroup())
  758. {
  759. StringArray childIDs;
  760. for (int i = 0; i < projectItem.getNumChildren(); ++i)
  761. {
  762. const String childID (addProjectItem (projectItem.getChild(i)));
  763. if (childID.isNotEmpty())
  764. childIDs.add (childID);
  765. }
  766. return addGroup (projectItem, childIDs);
  767. }
  768. else
  769. {
  770. if (projectItem.shouldBeAddedToTargetProject())
  771. {
  772. String itemPath (projectItem.getFilePath());
  773. bool inhibitWarnings = projectItem.shouldInhibitWarnings();
  774. if (itemPath.startsWith ("${"))
  775. {
  776. const RelativePath path (itemPath, RelativePath::unknown);
  777. return addFile (path, projectItem.shouldBeCompiled(), inhibitWarnings);
  778. }
  779. else
  780. {
  781. const RelativePath path (projectItem.getFile(), getTargetFolder(), RelativePath::buildTargetFolder);
  782. return addFile (path, projectItem.shouldBeCompiled(), inhibitWarnings);
  783. }
  784. }
  785. }
  786. return String::empty;
  787. }
  788. void addFramework (const String& frameworkName) const
  789. {
  790. const String path ("System/Library/Frameworks/" + frameworkName + ".framework");
  791. const String fileRefID (createFileRefID (path));
  792. addFileReference ("${SDKROOT}/" + path);
  793. frameworkIDs.add (addBuildFile (path, fileRefID, false, false));
  794. frameworkFileIDs.add (fileRefID);
  795. }
  796. void addGroup (const String& groupID, const String& groupName, const StringArray& childIDs) const
  797. {
  798. ValueTree* v = new ValueTree (groupID);
  799. v->setProperty ("isa", "PBXGroup", 0);
  800. v->setProperty ("children", "(" + indentList (childIDs, ",") + " )", 0);
  801. v->setProperty (Ids::name, groupName, 0);
  802. v->setProperty ("sourceTree", "<group>", 0);
  803. pbxGroups.add (v);
  804. }
  805. String addGroup (const Project::Item& item, StringArray& childIDs) const
  806. {
  807. const String groupName (item.getName());
  808. const String groupID (getIDForGroup (item));
  809. addGroup (groupID, groupName, childIDs);
  810. return groupID;
  811. }
  812. void addMainBuildProduct() const
  813. {
  814. jassert (xcodeFileType.isNotEmpty());
  815. jassert (xcodeBundleExtension.isEmpty() || xcodeBundleExtension.startsWithChar('.'));
  816. String productName (getConfiguration(0)->getTargetBinaryName().toString());
  817. if (xcodeFileType == "archive.ar")
  818. productName = getLibbedFilename (productName);
  819. else
  820. productName += xcodeBundleExtension;
  821. addBuildProduct (xcodeFileType, productName);
  822. }
  823. void addBuildProduct (const String& fileType, const String& binaryName) const
  824. {
  825. ValueTree* v = new ValueTree (createID ("__productFileID"));
  826. v->setProperty ("isa", "PBXFileReference", 0);
  827. v->setProperty ("explicitFileType", fileType, 0);
  828. v->setProperty ("includeInIndex", (int) 0, 0);
  829. v->setProperty ("path", sanitisePath (binaryName), 0);
  830. v->setProperty ("sourceTree", "BUILT_PRODUCTS_DIR", 0);
  831. pbxFileReferences.add (v);
  832. }
  833. void addTargetConfig (const String& configName, const StringArray& buildSettings) const
  834. {
  835. ValueTree* v = new ValueTree (createID ("targetconfigid_" + configName));
  836. v->setProperty ("isa", "XCBuildConfiguration", 0);
  837. v->setProperty ("buildSettings", "{" + indentList (buildSettings, ";") + " }", 0);
  838. v->setProperty (Ids::name, configName, 0);
  839. targetConfigs.add (v);
  840. }
  841. void addProjectConfig (const String& configName, const StringArray& buildSettings) const
  842. {
  843. ValueTree* v = new ValueTree (createID ("projectconfigid_" + configName));
  844. v->setProperty ("isa", "XCBuildConfiguration", 0);
  845. v->setProperty ("buildSettings", "{" + indentList (buildSettings, ";") + " }", 0);
  846. v->setProperty (Ids::name, configName, 0);
  847. projectConfigs.add (v);
  848. }
  849. void addConfigList (const OwnedArray <ValueTree>& configsToUse, const String& listID) const
  850. {
  851. StringArray configIDs;
  852. for (int i = 0; i < configsToUse.size(); ++i)
  853. configIDs.add (configsToUse[i]->getType().toString());
  854. ValueTree* v = new ValueTree (listID);
  855. v->setProperty ("isa", "XCConfigurationList", 0);
  856. v->setProperty ("buildConfigurations", "(" + indentList (configIDs, ",") + " )", 0);
  857. v->setProperty ("defaultConfigurationIsVisible", (int) 0, 0);
  858. if (configsToUse[0] != nullptr)
  859. v->setProperty ("defaultConfigurationName", configsToUse[0]->getProperty (Ids::name), 0);
  860. misc.add (v);
  861. }
  862. ValueTree* addBuildPhase (const String& phaseType, const StringArray& fileIds) const
  863. {
  864. String phaseId (createID (phaseType + "resbuildphase"));
  865. buildPhaseIDs.add (phaseId);
  866. ValueTree* v = new ValueTree (phaseId);
  867. v->setProperty ("isa", phaseType, 0);
  868. v->setProperty ("buildActionMask", "2147483647", 0);
  869. v->setProperty ("files", "(" + indentList (fileIds, ",") + " )", 0);
  870. v->setProperty ("runOnlyForDeploymentPostprocessing", (int) 0, 0);
  871. misc.add (v);
  872. return v;
  873. }
  874. void addTargetObject() const
  875. {
  876. ValueTree* const v = new ValueTree (createID ("__target"));
  877. v->setProperty ("isa", "PBXNativeTarget", 0);
  878. v->setProperty ("buildConfigurationList", createID ("__configList"), 0);
  879. v->setProperty ("buildPhases", "(" + indentList (buildPhaseIDs, ",") + " )", 0);
  880. v->setProperty ("buildRules", "( )", 0);
  881. v->setProperty ("dependencies", "( )", 0);
  882. v->setProperty (Ids::name, projectName, 0);
  883. v->setProperty ("productName", projectName, 0);
  884. v->setProperty ("productReference", createID ("__productFileID"), 0);
  885. if (xcodeProductInstallPath.isNotEmpty())
  886. v->setProperty ("productInstallPath", xcodeProductInstallPath, 0);
  887. jassert (xcodeProductType.isNotEmpty());
  888. v->setProperty ("productType", xcodeProductType, 0);
  889. misc.add (v);
  890. }
  891. void addProjectObject() const
  892. {
  893. ValueTree* const v = new ValueTree (createID ("__root"));
  894. v->setProperty ("isa", "PBXProject", 0);
  895. v->setProperty ("buildConfigurationList", createID ("__projList"), 0);
  896. v->setProperty ("compatibilityVersion", "Xcode 3.2", 0);
  897. v->setProperty ("hasScannedForEncodings", (int) 0, 0);
  898. v->setProperty ("mainGroup", createID ("__mainsourcegroup"), 0);
  899. v->setProperty ("projectDirPath", "\"\"", 0);
  900. v->setProperty ("projectRoot", "\"\"", 0);
  901. v->setProperty ("targets", "( " + createID ("__target") + " )", 0);
  902. misc.add (v);
  903. }
  904. void addShellScriptPhase() const
  905. {
  906. if (getPostBuildScript().isNotEmpty())
  907. {
  908. ValueTree* const v = addBuildPhase ("PBXShellScriptBuildPhase", StringArray());
  909. v->setProperty (Ids::name, "Post-build script", 0);
  910. v->setProperty ("shellPath", "/bin/sh", 0);
  911. v->setProperty ("shellScript", getPostBuildScript().replace ("\\", "\\\\")
  912. .replace ("\"", "\\\"")
  913. .replace ("\r\n", "\\n")
  914. .replace ("\n", "\\n"), 0);
  915. }
  916. }
  917. //==============================================================================
  918. static String indentList (const StringArray& list, const String& separator)
  919. {
  920. if (list.size() == 0)
  921. return " ";
  922. return "\n\t\t\t\t" + list.joinIntoString (separator + "\n\t\t\t\t")
  923. + (separator == ";" ? separator : String::empty);
  924. }
  925. String createID (String rootString) const
  926. {
  927. if (rootString.startsWith ("${"))
  928. rootString = rootString.fromFirstOccurrenceOf ("}/", false, false);
  929. rootString += project.getProjectUID();
  930. return MD5 (rootString.toUTF8()).toHexString().substring (0, 24).toUpperCase();
  931. }
  932. String createFileRefID (const RelativePath& path) const
  933. {
  934. return createFileRefID (path.toUnixStyle());
  935. }
  936. String createFileRefID (const String& path) const
  937. {
  938. return createID ("__fileref_" + path);
  939. }
  940. String getIDForGroup (const Project::Item& item) const
  941. {
  942. return createID (item.getID());
  943. }
  944. bool shouldFileBeCompiledByDefault (const RelativePath& file) const
  945. {
  946. return file.hasFileExtension (sourceFileExtensions);
  947. }
  948. };
  949. #endif // __JUCER_PROJECTEXPORT_XCODE_JUCEHEADER__