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.

2798 lines
123KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #include "../Application/jucer_Application.h"
  20. #include "jucer_TextWithDefaultPropertyComponent.h"
  21. namespace
  22. {
  23. const char* const osxVersionDefault = "default";
  24. const int oldestSDKVersion = 5;
  25. const int currentSDKVersion = 12;
  26. const int minimumAUv3SDKVersion = 11;
  27. const char* const osxArch_Default = "default";
  28. const char* const osxArch_Native = "Native";
  29. const char* const osxArch_32BitUniversal = "32BitUniversal";
  30. const char* const osxArch_64BitUniversal = "64BitUniversal";
  31. const char* const osxArch_64Bit = "64BitIntel";
  32. }
  33. //==============================================================================
  34. class XCodeProjectExporter : public ProjectExporter
  35. {
  36. public:
  37. //==============================================================================
  38. static const char* getNameMac() { return "Xcode (MacOSX)"; }
  39. static const char* getNameiOS() { return "Xcode (iOS)"; }
  40. static const char* getValueTreeTypeName (bool iOS) { return iOS ? "XCODE_IPHONE" : "XCODE_MAC"; }
  41. //==============================================================================
  42. XCodeProjectExporter (Project& p, const ValueTree& t, const bool isIOS)
  43. : ProjectExporter (p, t),
  44. xcodeCanUseDwarf (true),
  45. iOS (isIOS)
  46. {
  47. name = iOS ? getNameiOS() : getNameMac();
  48. if (getTargetLocationString().isEmpty())
  49. getTargetLocationValue() = getDefaultBuildsRootFolder() + (iOS ? "iOS" : "MacOSX");
  50. initialiseDependencyPathValues();
  51. if (iOS)
  52. {
  53. if (getScreenOrientationValue().toString().isEmpty())
  54. getScreenOrientationValue() = "portraitlandscape";
  55. }
  56. }
  57. static XCodeProjectExporter* createForSettings (Project& project, const ValueTree& settings)
  58. {
  59. if (settings.hasType (getValueTreeTypeName (false))) return new XCodeProjectExporter (project, settings, false);
  60. if (settings.hasType (getValueTreeTypeName (true))) return new XCodeProjectExporter (project, settings, true);
  61. return nullptr;
  62. }
  63. //==============================================================================
  64. Value getPListToMergeValue() { return getSetting ("customPList"); }
  65. String getPListToMergeString() const { return settings ["customPList"]; }
  66. Value getPListPrefixHeaderValue() { return getSetting ("PListPrefixHeader"); }
  67. String getPListPrefixHeaderString() const { return settings ["PListPrefixHeader"]; }
  68. Value getPListPreprocessValue() { return getSetting ("PListPreprocess"); }
  69. bool isPListPreprocessEnabled() const { return settings ["PListPreprocess"]; }
  70. Value getExtraFrameworksValue() { return getSetting (Ids::extraFrameworks); }
  71. String getExtraFrameworksString() const { return settings [Ids::extraFrameworks]; }
  72. Value getPostBuildScriptValue() { return getSetting (Ids::postbuildCommand); }
  73. String getPostBuildScript() const { return settings [Ids::postbuildCommand]; }
  74. Value getPreBuildScriptValue() { return getSetting (Ids::prebuildCommand); }
  75. String getPreBuildScript() const { return settings [Ids::prebuildCommand]; }
  76. Value getScreenOrientationValue() { return getSetting (Ids::iosScreenOrientation); }
  77. String getScreenOrientationString() const { return settings [Ids::iosScreenOrientation]; }
  78. Value getCustomResourceFoldersValue() { return getSetting (Ids::customXcodeResourceFolders); }
  79. String getCustomResourceFoldersString() const { return getSettingString (Ids::customXcodeResourceFolders).replaceCharacters ("\r\n", "::"); }
  80. Value getCustomXcassetsFolderValue() { return getSetting (Ids::customXcassetsFolder); }
  81. String getCustomXcassetsFolderString() const { return settings [Ids::customXcassetsFolder]; }
  82. Value getMicrophonePermissionValue() { return getSetting (Ids::microphonePermissionNeeded); }
  83. bool isMicrophonePermissionEnabled() const { return settings [Ids::microphonePermissionNeeded]; }
  84. Value getInAppPurchasesValue() { return getSetting (Ids::iosInAppPurchases); }
  85. bool isInAppPurchasesEnabled() const { return settings [Ids::iosInAppPurchases]; }
  86. Value getBackgroundAudioValue() { return getSetting (Ids::iosBackgroundAudio); }
  87. bool isBackgroundAudioEnabled() const { return settings [Ids::iosBackgroundAudio]; }
  88. Value getBackgroundBleValue() { return getSetting (Ids::iosBackgroundBle); }
  89. bool isBackgroundBleEnabled() const { return settings [Ids::iosBackgroundBle]; }
  90. Value getIosDevelopmentTeamIDValue() { return getSetting (Ids::iosDevelopmentTeamID); }
  91. String getIosDevelopmentTeamIDString() const { return settings [Ids::iosDevelopmentTeamID]; }
  92. bool usesMMFiles() const override { return true; }
  93. bool canCopeWithDuplicateFiles() override { return true; }
  94. bool supportsUserDefinedConfigurations() const override { return true; }
  95. bool isXcode() const override { return true; }
  96. bool isVisualStudio() const override { return false; }
  97. bool isCodeBlocks() const override { return false; }
  98. bool isMakefile() const override { return false; }
  99. bool isAndroidStudio() const override { return false; }
  100. bool isAndroid() const override { return false; }
  101. bool isWindows() const override { return false; }
  102. bool isLinux() const override { return false; }
  103. bool isOSX() const override { return ! iOS; }
  104. bool isiOS() const override { return iOS; }
  105. bool supportsTargetType (ProjectType::Target::Type type) const override
  106. {
  107. switch (type)
  108. {
  109. case ProjectType::Target::AudioUnitv3PlugIn:
  110. case ProjectType::Target::StandalonePlugIn:
  111. case ProjectType::Target::GUIApp:
  112. case ProjectType::Target::StaticLibrary:
  113. case ProjectType::Target::SharedCodeTarget:
  114. case ProjectType::Target::AggregateTarget:
  115. return true;
  116. case ProjectType::Target::ConsoleApp:
  117. case ProjectType::Target::VSTPlugIn:
  118. case ProjectType::Target::VST3PlugIn:
  119. case ProjectType::Target::AAXPlugIn:
  120. case ProjectType::Target::RTASPlugIn:
  121. case ProjectType::Target::AudioUnitPlugIn:
  122. case ProjectType::Target::DynamicLibrary:
  123. return ! iOS;
  124. default:
  125. break;
  126. }
  127. return false;
  128. }
  129. void createExporterProperties (PropertyListBuilder& props) override
  130. {
  131. if (iOS)
  132. {
  133. props.add (new TextPropertyComponent (getCustomXcassetsFolderValue(), "Custom Xcassets folder", 128, false),
  134. "If this field is not empty, your Xcode project will use the custom xcassets folder specified here "
  135. "for the app icons and launchimages, and will ignore the Icon files specified above.");
  136. }
  137. props.add (new TextPropertyComponent (getCustomResourceFoldersValue(), "Custom Xcode Resource folders", 8192, true),
  138. "You can specify a list of custom resource folders here (separated by newlines or whitespace). "
  139. "References to these folders will then be added to the Xcode resources. "
  140. "This way you can specify them for OS X and iOS separately, and modify the content of the resource folders "
  141. "without re-saving the Projucer project.");
  142. if (iOS)
  143. {
  144. static const char* orientations[] = { "Portrait and Landscape", "Portrait", "Landscape", nullptr };
  145. static const char* orientationValues[] = { "portraitlandscape", "portrait", "landscape", nullptr };
  146. props.add (new ChoicePropertyComponent (getScreenOrientationValue(), "Screen orientation",StringArray (orientations), Array<var> (orientationValues)),
  147. "The screen orientations that this app should support");
  148. props.add (new BooleanPropertyComponent (getSetting ("UIFileSharingEnabled"), "File Sharing Enabled", "Enabled"),
  149. "Enable this to expose your app's files to iTunes.");
  150. props.add (new BooleanPropertyComponent (getSetting ("UIStatusBarHidden"), "Status Bar Hidden", "Enabled"),
  151. "Enable this to disable the status bar in your app.");
  152. props.add (new BooleanPropertyComponent (getMicrophonePermissionValue(), "Microphone access", "Enabled"),
  153. "Enable this to allow your app to use the microphone. "
  154. "The user of your app will be prompted to grant microphone access permissions.");
  155. props.add (new BooleanPropertyComponent (getInAppPurchasesValue(), "In-App purchases capability", "Enabled"),
  156. "Enable this to grant your app the capability for in-app purchases. "
  157. "This option requires that you specify a valid Development Team ID.");
  158. props.add (new BooleanPropertyComponent (getBackgroundAudioValue(), "Audio background capability", "Enabled"),
  159. "Enable this to grant your app the capability to access audio when in background mode.");
  160. props.add (new BooleanPropertyComponent (getBackgroundBleValue(), "Bluetooth MIDI background capability", "Enabled"),
  161. "Enable this to grant your app the capability to connect to Bluetooth LE devices when in background mode.");
  162. }
  163. else if (projectType.isGUIApplication())
  164. {
  165. props.add (new TextPropertyComponent (getSetting ("documentExtensions"), "Document file extensions", 128, false),
  166. "A comma-separated list of file extensions for documents that your app can open. "
  167. "Using a leading '.' is optional, and the extensions are not case-sensitive.");
  168. }
  169. props.add (new TextPropertyComponent (getPListToMergeValue(), "Custom PList", 8192, true),
  170. "You can paste the contents of an XML PList file in here, and the settings that it contains will override any "
  171. "settings that the Projucer creates. BEWARE! When doing this, be careful to remove from the XML any "
  172. "values that you DO want the Projucer to change!");
  173. props.add (new BooleanPropertyComponent (getPListPreprocessValue(), "PList Preprocess", "Enabled"),
  174. "Enable this to preprocess PList file. This will allow you to set values to preprocessor defines,"
  175. " for instance if you define: #define MY_FLAG 1 in a prefix header file (see PList prefix header), you can have"
  176. " a key with MY_FLAG value and it will be replaced with 1.");
  177. props.add (new TextPropertyComponent (getPListPrefixHeaderValue(), "PList Prefix Header", 512, false),
  178. "Header file containing definitions used in plist file (see PList Preprocess).");
  179. props.add (new TextPropertyComponent (getExtraFrameworksValue(), "Extra Frameworks", 2048, false),
  180. "A comma-separated list of extra frameworks that should be added to the build. "
  181. "(Don't include the .framework extension in the name)");
  182. props.add (new TextPropertyComponent (getPreBuildScriptValue(), "Pre-build shell script", 32768, true),
  183. "Some shell-script that will be run before a build starts.");
  184. props.add (new TextPropertyComponent (getPostBuildScriptValue(), "Post-build shell script", 32768, true),
  185. "Some shell-script that will be run after a build completes.");
  186. props.add (new TextPropertyComponent (getIosDevelopmentTeamIDValue(), "Development Team ID", 10, false),
  187. "The Development Team ID to be used for setting up code-signing your iOS app. This is a ten-character "
  188. "string (for example, \"S7B6T5XJ2Q\") that describes the distribution certificate Apple issued to you. "
  189. "You can find this string in the OS X app Keychain Access under \"Certificates\".");
  190. props.add (new BooleanPropertyComponent (getSetting ("keepCustomXcodeSchemes"), "Keep custom Xcode schemes", "Enabled"),
  191. "Enable this to keep any Xcode schemes you have created for debugging or running, e.g. to launch a plug-in in"
  192. "various hosts. If disabled, all schemes are replaced by a default set.");
  193. props.add (new BooleanPropertyComponent (getSetting ("useHeaderMap"), "USE_HEADERMAP", "Enabled"),
  194. "Enable this to make Xcode search all the projects folders for include files. This means you can be lazy "
  195. "and not bother using relative paths to include your headers, but it means your code won't be "
  196. "compatible with other build systems");
  197. }
  198. bool launchProject() override
  199. {
  200. #if JUCE_MAC
  201. return getProjectBundle().startAsProcess();
  202. #else
  203. return false;
  204. #endif
  205. }
  206. bool canLaunchProject() override
  207. {
  208. #if JUCE_MAC
  209. return true;
  210. #else
  211. return false;
  212. #endif
  213. }
  214. //==============================================================================
  215. void create (const OwnedArray<LibraryModule>&) const override
  216. {
  217. for (auto& target : targets)
  218. if (target->shouldCreatePList())
  219. target->infoPlistFile = getTargetFolder().getChildFile (target->getInfoPlistName());
  220. menuNibFile = getTargetFolder().getChildFile ("RecentFilesMenuTemplate.nib");
  221. createIconFile();
  222. File projectBundle (getProjectBundle());
  223. createDirectoryOrThrow (projectBundle);
  224. createObjects();
  225. File projectFile (projectBundle.getChildFile ("project.pbxproj"));
  226. {
  227. MemoryOutputStream mo;
  228. writeProjectFile (mo);
  229. overwriteFileIfDifferentOrThrow (projectFile, mo);
  230. }
  231. writeInfoPlistFiles();
  232. // Deleting the .rsrc files can be needed to force Xcode to update the version number.
  233. deleteRsrcFiles (getTargetFolder().getChildFile ("build"));
  234. }
  235. //==============================================================================
  236. void addPlatformSpecificSettingsForProjectType (const ProjectType&) override
  237. {
  238. callForAllSupportedTargets ([this] (ProjectType::Target::Type targetType)
  239. {
  240. if (XCodeTarget* target = new XCodeTarget (targetType, *this))
  241. {
  242. if (targetType == ProjectType::Target::AggregateTarget)
  243. targets.insert (0, target);
  244. else
  245. targets.add (target);
  246. }
  247. });
  248. // If you hit this assert, you tried to generate a project for an exporter
  249. // that does not support any of your targets!
  250. jassert (targets.size() > 0);
  251. }
  252. void updateDeprecatedProjectSettingsInteractively() override
  253. {
  254. if (hasInvalidPostBuildScript())
  255. {
  256. String alertWindowText = iOS ? "Your Xcode (iOS) Exporter settings use an invalid post-build script. Click 'Update' to remove it."
  257. : "Your Xcode (OSX) Exporter settings use a pre-JUCE 4.2 post-build script to move the plug-in binaries to their plug-in install folders.\n\n"
  258. "Since JUCE 4.2, this is instead done using \"AU/VST/VST2/AAX/RTAS Binary Location\" in the Xcode (OS X) configuration settings.\n\n"
  259. "Click 'Update' to remove the script (otherwise your plug-in may not compile correctly).";
  260. if (AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
  261. "Project settings: " + project.getDocumentTitle(),
  262. alertWindowText, "Update", "Cancel", nullptr, nullptr))
  263. getPostBuildScriptValue() = var();
  264. }
  265. }
  266. bool hasInvalidPostBuildScript() const
  267. {
  268. // check whether the script is identical to the old one that the Introjucer used to auto-generate
  269. return (MD5 (getPostBuildScript().toUTF8()).toHexString() == "265ac212a7e734c5bbd6150e1eae18a1");
  270. }
  271. protected:
  272. //==============================================================================
  273. class XcodeBuildConfiguration : public BuildConfiguration
  274. {
  275. public:
  276. XcodeBuildConfiguration (Project& p, const ValueTree& t, const bool isIOS, const ProjectExporter& e)
  277. : BuildConfiguration (p, t, e),
  278. iOS (isIOS),
  279. osxSDKVersion (config, Ids::osxSDK, nullptr, "default"),
  280. osxDeploymentTarget (config, Ids::osxCompatibility, nullptr, "default"),
  281. iosDeploymentTarget (config, Ids::iosCompatibility, nullptr, "default"),
  282. osxArchitecture (config, Ids::osxArchitecture, nullptr, "default"),
  283. customXcodeFlags (config, Ids::customXcodeFlags, nullptr),
  284. plistPreprocessorDefinitions (config, Ids::plistPreprocessorDefinitions, nullptr),
  285. cppLanguageStandard (config, Ids::cppLanguageStandard, nullptr),
  286. cppStandardLibrary (config, Ids::cppLibType, nullptr),
  287. codeSignIdentity (config, Ids::codeSigningIdentity, nullptr, iOS ? "iPhone Developer" : "Mac Developer"),
  288. fastMathEnabled (config, Ids::fastMath, nullptr),
  289. linkTimeOptimisationEnabled (config, Ids::linkTimeOptimisation, nullptr),
  290. stripLocalSymbolsEnabled (config, Ids::stripLocalSymbols, nullptr),
  291. vstBinaryLocation (config, Ids::xcodeVstBinaryLocation, nullptr, "$(HOME)/Library/Audio/Plug-Ins/VST/"),
  292. vst3BinaryLocation (config, Ids::xcodeVst3BinaryLocation, nullptr, "$(HOME)/Library/Audio/Plug-Ins/VST3/"),
  293. auBinaryLocation (config, Ids::xcodeAudioUnitBinaryLocation, nullptr, "$(HOME)/Library/Audio/Plug-Ins/Components/"),
  294. rtasBinaryLocation (config, Ids::xcodeRtasBinaryLocation, nullptr, "/Library/Application Support/Digidesign/Plug-Ins/"),
  295. aaxBinaryLocation (config, Ids::xcodeAaxBinaryLocation, nullptr, "/Library/Application Support/Avid/Audio/Plug-Ins/")
  296. {
  297. }
  298. //==========================================================================
  299. bool iOS;
  300. CachedValue<String> osxSDKVersion, osxDeploymentTarget, iosDeploymentTarget, osxArchitecture,
  301. customXcodeFlags, plistPreprocessorDefinitions,
  302. cppLanguageStandard, cppStandardLibrary, codeSignIdentity;
  303. CachedValue<bool> fastMathEnabled, linkTimeOptimisationEnabled, stripLocalSymbolsEnabled;
  304. CachedValue<String> vstBinaryLocation, vst3BinaryLocation, auBinaryLocation, rtasBinaryLocation, aaxBinaryLocation;
  305. //==========================================================================
  306. var getDefaultOptimisationLevel() const override { return var ((int) (isDebug() ? gccO0 : gccO3)); }
  307. void createConfigProperties (PropertyListBuilder& props) override
  308. {
  309. addXcodePluginInstallPathProperties (props);
  310. addGCCOptimisationProperty (props);
  311. if (iOS)
  312. {
  313. const char* iosVersions[] = { "Use Default", "7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "8.4", "9.0", "9.1", "9.2", "9.3", "10.0", 0 };
  314. const char* iosVersionValues[] = { osxVersionDefault, "7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "8.4", "9.0", "9.1", "9.2", "9.3", "10.0", 0 };
  315. props.add (new ChoicePropertyComponent (iosDeploymentTarget.getPropertyAsValue(), "iOS Deployment Target",
  316. StringArray (iosVersions), Array<var> (iosVersionValues)),
  317. "The minimum version of iOS that the target binary will run on.");
  318. }
  319. else
  320. {
  321. StringArray sdkVersionNames, osxVersionNames;
  322. Array<var> versionValues;
  323. sdkVersionNames.add ("Use Default");
  324. osxVersionNames.add ("Use Default");
  325. versionValues.add (osxVersionDefault);
  326. for (int ver = oldestSDKVersion; ver <= currentSDKVersion; ++ver)
  327. {
  328. sdkVersionNames.add (getSDKName (ver));
  329. osxVersionNames.add (getOSXVersionName (ver));
  330. versionValues.add (getSDKName (ver));
  331. }
  332. props.add (new ChoicePropertyComponent (osxSDKVersion.getPropertyAsValue(), "OSX Base SDK Version", sdkVersionNames, versionValues),
  333. "The version of OSX to link against in the XCode build.");
  334. props.add (new ChoicePropertyComponent (osxDeploymentTarget.getPropertyAsValue(), "OSX Deployment Target", osxVersionNames, versionValues),
  335. "The minimum version of OSX that the target binary will be compatible with.");
  336. const char* osxArch[] = { "Use Default", "Native architecture of build machine",
  337. "Universal Binary (32-bit)", "Universal Binary (32/64-bit)", "64-bit Intel", 0 };
  338. const char* osxArchValues[] = { osxArch_Default, osxArch_Native, osxArch_32BitUniversal,
  339. osxArch_64BitUniversal, osxArch_64Bit, 0 };
  340. props.add (new ChoicePropertyComponent (osxArchitecture.getPropertyAsValue(), "OSX Architecture",
  341. StringArray (osxArch), Array<var> (osxArchValues)),
  342. "The type of OSX binary that will be produced.");
  343. }
  344. props.add (new TextPropertyComponent (customXcodeFlags.getPropertyAsValue(), "Custom Xcode flags", 8192, false),
  345. "A comma-separated list of custom Xcode setting flags which will be appended to the list of generated flags, "
  346. "e.g. MACOSX_DEPLOYMENT_TARGET_i386 = 10.5, VALID_ARCHS = \"ppc i386 x86_64\"");
  347. props.add (new TextPropertyComponent (plistPreprocessorDefinitions.getPropertyAsValue(), "PList Preprocessor Definitions", 2048, true),
  348. "Preprocessor definitions used during PList preprocessing (see PList Preprocess).");
  349. const char* cppLanguageStandardNames[] = { "Use Default", "C++11", "GNU++11", "C++14", "GNU++14", nullptr };
  350. Array<var> cppLanguageStandardValues;
  351. cppLanguageStandardValues.add (var());
  352. cppLanguageStandardValues.add ("c++11");
  353. cppLanguageStandardValues.add ("gnu++11");
  354. cppLanguageStandardValues.add ("c++14");
  355. cppLanguageStandardValues.add ("gnu++14");
  356. props.add (new ChoicePropertyComponent (cppLanguageStandard.getPropertyAsValue(), "C++ Language Standard",
  357. StringArray (cppLanguageStandardNames), cppLanguageStandardValues),
  358. "The standard of the C++ language that will be used for compilation.");
  359. const char* cppLibNames[] = { "Use Default", "LLVM libc++", "GNU libstdc++", nullptr };
  360. Array<var> cppLibValues;
  361. cppLibValues.add (var());
  362. cppLibValues.add ("libc++");
  363. cppLibValues.add ("libstdc++");
  364. props.add (new ChoicePropertyComponent (cppStandardLibrary.getPropertyAsValue(), "C++ Library", StringArray (cppLibNames), cppLibValues),
  365. "The type of C++ std lib that will be linked.");
  366. props.add (new TextWithDefaultPropertyComponent<String> (codeSignIdentity, "Code-signing Identity", 1024),
  367. "The name of a code-signing identity for Xcode to apply.");
  368. props.add (new BooleanPropertyComponent (fastMathEnabled.getPropertyAsValue(), "Relax IEEE compliance", "Enabled"),
  369. "Enable this to use FAST_MATH non-IEEE mode. (Warning: this can have unexpected results!)");
  370. props.add (new BooleanPropertyComponent (linkTimeOptimisationEnabled.getPropertyAsValue(), "Link-Time Optimisation", "Enabled"),
  371. "Enable this to perform link-time code generation. This is recommended for release builds.");
  372. props.add (new BooleanPropertyComponent (stripLocalSymbolsEnabled.getPropertyAsValue(), "Strip local symbols", "Enabled"),
  373. "Enable this to strip any locally defined symbols resulting in a smaller binary size. Enabling this "
  374. "will also remove any function names from crash logs. Must be disabled for static library projects.");
  375. }
  376. String getLibrarySubdirPath() const override
  377. {
  378. return "${CURRENT_ARCH}";
  379. }
  380. private:
  381. //==========================================================================
  382. void addXcodePluginInstallPathProperties (PropertyListBuilder& props)
  383. {
  384. if (project.shouldBuildVST())
  385. props.add (new TextWithDefaultPropertyComponent<String> (vstBinaryLocation, "VST Binary location", 1024),
  386. "The folder in which the compiled VST binary should be placed.");
  387. if (project.shouldBuildVST3())
  388. props.add (new TextWithDefaultPropertyComponent<String> (vst3BinaryLocation, "VST3 Binary location", 1024),
  389. "The folder in which the compiled VST3 binary should be placed.");
  390. if (project.shouldBuildAU())
  391. props.add (new TextWithDefaultPropertyComponent<String> (auBinaryLocation, "AU Binary location", 1024),
  392. "The folder in which the compiled AU binary should be placed.");
  393. if (project.shouldBuildRTAS())
  394. props.add (new TextWithDefaultPropertyComponent<String> (rtasBinaryLocation, "RTAS Binary location", 1024),
  395. "The folder in which the compiled RTAS binary should be placed.");
  396. if (project.shouldBuildAAX())
  397. props.add (new TextWithDefaultPropertyComponent<String> (aaxBinaryLocation, "AAX Binary location", 1024),
  398. "The folder in which the compiled AAX binary should be placed.");
  399. }
  400. };
  401. BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override
  402. {
  403. return new XcodeBuildConfiguration (project, v, iOS, *this);
  404. }
  405. public:
  406. //==============================================================================
  407. /* The numbers for these enum values are defined by Xcode for the different
  408. possible destinations of a "copy files" post-build step.
  409. */
  410. enum XcodeCopyFilesDestinationIDs
  411. {
  412. kWrapperFolder = 1,
  413. kExecutablesFolder = 6,
  414. kResourcesFolder = 7,
  415. kFrameworksFolder = 10,
  416. kSharedFrameworksFolder = 11,
  417. kSharedSupportFolder = 12,
  418. kPluginsFolder = 13,
  419. kJavaResourcesFolder = 15,
  420. kXPCServicesFolder = 16
  421. };
  422. //==============================================================================
  423. struct XCodeTarget : ProjectType::Target
  424. {
  425. //==============================================================================
  426. XCodeTarget (ProjectType::Target::Type targetType, const XCodeProjectExporter& exporter)
  427. : ProjectType::Target (targetType),
  428. owner (exporter)
  429. {
  430. switch (type)
  431. {
  432. case GUIApp:
  433. xcodePackageType = "APPL";
  434. xcodeBundleSignature = "????";
  435. xcodeFileType = "wrapper.application";
  436. xcodeBundleExtension = ".app";
  437. xcodeProductType = "com.apple.product-type.application";
  438. xcodeCopyToProductInstallPathAfterBuild = false;
  439. break;
  440. case ConsoleApp:
  441. xcodeFileType = "compiled.mach-o.executable";
  442. xcodeBundleExtension = String();
  443. xcodeProductType = "com.apple.product-type.tool";
  444. xcodeCopyToProductInstallPathAfterBuild = false;
  445. break;
  446. case StaticLibrary:
  447. xcodeFileType = "archive.ar";
  448. xcodeProductType = "com.apple.product-type.library.static";
  449. xcodeCopyToProductInstallPathAfterBuild = false;
  450. break;
  451. case DynamicLibrary:
  452. xcodeFileType = "compiled.mach-o.dylib";
  453. xcodeProductType = "com.apple.product-type.library.dynamic";
  454. xcodeBundleExtension = ".dylib";
  455. xcodeCopyToProductInstallPathAfterBuild = false;
  456. break;
  457. case VSTPlugIn:
  458. xcodePackageType = "BNDL";
  459. xcodeBundleSignature = "????";
  460. xcodeFileType = "wrapper.cfbundle";
  461. xcodeBundleExtension = ".vst";
  462. xcodeProductType = "com.apple.product-type.bundle";
  463. xcodeCopyToProductInstallPathAfterBuild = true;
  464. break;
  465. case VST3PlugIn:
  466. xcodePackageType = "BNDL";
  467. xcodeBundleSignature = "????";
  468. xcodeFileType = "wrapper.cfbundle";
  469. xcodeBundleExtension = ".vst3";
  470. xcodeProductType = "com.apple.product-type.bundle";
  471. xcodeCopyToProductInstallPathAfterBuild = true;
  472. break;
  473. case AudioUnitPlugIn:
  474. xcodePackageType = "BNDL";
  475. xcodeBundleSignature = "????";
  476. xcodeFileType = "wrapper.cfbundle";
  477. xcodeBundleExtension = ".component";
  478. xcodeProductType = "com.apple.product-type.bundle";
  479. xcodeCopyToProductInstallPathAfterBuild = true;
  480. addExtraAudioUnitTargetSettings();
  481. break;
  482. case StandalonePlugIn:
  483. xcodePackageType = "APPL";
  484. xcodeBundleSignature = "????";
  485. xcodeFileType = "wrapper.application";
  486. xcodeBundleExtension = ".app";
  487. xcodeProductType = "com.apple.product-type.application";
  488. xcodeCopyToProductInstallPathAfterBuild = false;
  489. break;
  490. case AudioUnitv3PlugIn:
  491. xcodePackageType = "XPC!";
  492. xcodeBundleSignature = "????";
  493. xcodeFileType = "wrapper.app-extension";
  494. xcodeBundleExtension = ".appex";
  495. xcodeBundleIDSubPath = "AUv3";
  496. xcodeProductType = "com.apple.product-type.app-extension";
  497. xcodeCopyToProductInstallPathAfterBuild = false;
  498. addExtraAudioUnitv3PlugInTargetSettings();
  499. break;
  500. case AAXPlugIn:
  501. xcodePackageType = "TDMw";
  502. xcodeBundleSignature = "PTul";
  503. xcodeFileType = "wrapper.cfbundle";
  504. xcodeBundleExtension = ".aaxplugin";
  505. xcodeProductType = "com.apple.product-type.bundle";
  506. xcodeCopyToProductInstallPathAfterBuild = true;
  507. break;
  508. case RTASPlugIn:
  509. xcodePackageType = "TDMw";
  510. xcodeBundleSignature = "PTul";
  511. xcodeFileType = "wrapper.cfbundle";
  512. xcodeBundleExtension = ".dpm";
  513. xcodeProductType = "com.apple.product-type.bundle";
  514. xcodeCopyToProductInstallPathAfterBuild = true;
  515. break;
  516. case SharedCodeTarget:
  517. xcodeFileType = "archive.ar";
  518. xcodeProductType = "com.apple.product-type.library.static";
  519. xcodeCopyToProductInstallPathAfterBuild = false;
  520. break;
  521. case AggregateTarget:
  522. xcodeCopyToProductInstallPathAfterBuild = false;
  523. break;
  524. default:
  525. // unknown target type!
  526. jassertfalse;
  527. break;
  528. }
  529. }
  530. String getXCodeSchemeName() const
  531. {
  532. return owner.projectName + " - " + getName();
  533. }
  534. String getID() const
  535. {
  536. return owner.createID (String ("__target") + getName());
  537. }
  538. String getInfoPlistName() const
  539. {
  540. return String ("Info-") + String (getName()).replace (" ", "_") + String (".plist");
  541. }
  542. String xcodePackageType, xcodeBundleSignature, xcodeBundleExtension;
  543. String xcodeProductType, xcodeFileType;
  544. String xcodeOtherRezFlags, xcodeExcludedFiles64Bit, xcodeBundleIDSubPath;
  545. bool xcodeCopyToProductInstallPathAfterBuild;
  546. StringArray xcodeFrameworks, xcodeLibs;
  547. Array<XmlElement> xcodeExtraPListEntries;
  548. Array<RelativePath> xcodeExtraLibrariesDebug, xcodeExtraLibrariesRelease;
  549. StringArray frameworkIDs, buildPhaseIDs, configIDs, sourceIDs, rezFileIDs;
  550. String dependencyID, mainBuildProductID;
  551. File infoPlistFile;
  552. //==============================================================================
  553. void addMainBuildProduct() const
  554. {
  555. jassert (xcodeFileType.isNotEmpty());
  556. jassert (xcodeBundleExtension.isEmpty() || xcodeBundleExtension.startsWithChar ('.'));
  557. if (ProjectExporter::BuildConfiguration::Ptr config = owner.getConfiguration(0))
  558. {
  559. String productName (owner.replacePreprocessorTokens (*config, config->getTargetBinaryNameString()));
  560. if (xcodeFileType == "archive.ar")
  561. productName = getStaticLibbedFilename (productName);
  562. else
  563. productName += xcodeBundleExtension;
  564. addBuildProduct (xcodeFileType, productName);
  565. }
  566. }
  567. //==============================================================================
  568. void addBuildProduct (const String& fileType, const String& binaryName) const
  569. {
  570. ValueTree* v = new ValueTree (owner.createID (String ("__productFileID") + getName()));
  571. v->setProperty ("isa", "PBXFileReference", nullptr);
  572. v->setProperty ("explicitFileType", fileType, nullptr);
  573. v->setProperty ("includeInIndex", (int) 0, nullptr);
  574. v->setProperty ("path", sanitisePath (binaryName), nullptr);
  575. v->setProperty ("sourceTree", "BUILT_PRODUCTS_DIR", nullptr);
  576. owner.pbxFileReferences.add (v);
  577. }
  578. //==============================================================================
  579. void addDependency()
  580. {
  581. jassert (dependencyID.isEmpty());
  582. dependencyID = owner.createID (String ("__dependency") + getName());
  583. ValueTree* const v = new ValueTree (dependencyID);
  584. v->setProperty ("isa", "PBXTargetDependency", nullptr);
  585. v->setProperty ("target", getID(), nullptr);
  586. owner.misc.add (v);
  587. }
  588. String getDependencyID() const
  589. {
  590. jassert (dependencyID.isNotEmpty());
  591. return dependencyID;
  592. }
  593. //==============================================================================
  594. void addTargetConfig (const String& configName, const StringArray& buildSettings)
  595. {
  596. String configID = owner.createID (String ("targetconfigid_") + getName() + String ("_") + configName);
  597. ValueTree* v = new ValueTree (configID);
  598. v->setProperty ("isa", "XCBuildConfiguration", nullptr);
  599. v->setProperty ("buildSettings", indentBracedList (buildSettings), nullptr);
  600. v->setProperty (Ids::name, configName, nullptr);
  601. configIDs.add (configID);
  602. owner.targetConfigs.add (v);
  603. }
  604. //==============================================================================
  605. String getTargetAttributes() const
  606. {
  607. String attributes;
  608. attributes << getID() << " = { ";
  609. String developmentTeamID = owner.getIosDevelopmentTeamIDString();
  610. if (developmentTeamID.isNotEmpty())
  611. attributes << "DevelopmentTeam = " << developmentTeamID << "; ";
  612. const int inAppPurchasesEnabled = (owner.iOS && owner.isInAppPurchasesEnabled()) ? 1 : 0;
  613. const int interAppAudioEnabled = (owner.iOS
  614. && type == Target::StandalonePlugIn
  615. && owner.getProject().shouldEnableIAA()) ? 1 : 0;
  616. const int sandboxEnabled = (type == Target::AudioUnitv3PlugIn ? 1 : 0);
  617. attributes << "SystemCapabilities = {";
  618. attributes << "com.apple.InAppPurchase = { enabled = " << inAppPurchasesEnabled << "; }; ";
  619. attributes << "com.apple.InterAppAudio = { enabled = " << interAppAudioEnabled << "; }; ";
  620. attributes << "com.apple.Sandbox = { enabled = " << sandboxEnabled << "; }; ";
  621. attributes << "}; };";
  622. return attributes;
  623. }
  624. //==============================================================================
  625. ValueTree& addBuildPhase (const String& buildPhaseType, const StringArray& fileIds, const StringRef humanReadableName = StringRef())
  626. {
  627. String buildPhaseName = buildPhaseType + String ("_") + getName() + String ("_") + (humanReadableName.isNotEmpty() ? String (humanReadableName) : String ("resbuildphase"));
  628. String buildPhaseId (owner.createID (buildPhaseName));
  629. int n = 0;
  630. while (buildPhaseIDs.contains (buildPhaseId))
  631. buildPhaseId = owner.createID (buildPhaseName + String (++n));
  632. buildPhaseIDs.add (buildPhaseId);
  633. ValueTree* v = new ValueTree (buildPhaseId);
  634. v->setProperty ("isa", buildPhaseType, nullptr);
  635. v->setProperty ("buildActionMask", "2147483647", nullptr);
  636. v->setProperty ("files", indentParenthesisedList (fileIds), nullptr);
  637. v->setProperty ("runOnlyForDeploymentPostprocessing", (int) 0, nullptr);
  638. if (humanReadableName.isNotEmpty())
  639. v->setProperty ("name", String (humanReadableName), nullptr);
  640. owner.misc.add (v);
  641. return *v;
  642. }
  643. bool shouldCreatePList() const
  644. {
  645. const ProjectType::Target::TargetFileType fileType = getTargetFileType();
  646. return (fileType == executable && type != ConsoleApp) || fileType == pluginBundle || fileType == macOSAppex;
  647. }
  648. //==============================================================================
  649. StringArray getTargetSettings (const XcodeBuildConfiguration& config) const
  650. {
  651. if (type == AggregateTarget)
  652. // the aggregate target should not specify any settings at all!
  653. // it just defines dependencies on the other targets.
  654. return {};
  655. StringArray s;
  656. String bundleIdentifier = owner.project.getBundleIdentifier().toString();
  657. if (xcodeBundleIDSubPath.isNotEmpty())
  658. {
  659. StringArray bundleIdSegments = StringArray::fromTokens (bundleIdentifier, ".", StringRef());
  660. jassert (bundleIdSegments.size() > 0);
  661. bundleIdentifier += String (".") + bundleIdSegments[bundleIdSegments.size() - 1] + xcodeBundleIDSubPath;
  662. }
  663. s.add ("PRODUCT_BUNDLE_IDENTIFIER = " + bundleIdentifier);
  664. const String arch ((! owner.isiOS() && type == Target::AudioUnitv3PlugIn) ? osxArch_64Bit : config.osxArchitecture.get());
  665. if (arch == osxArch_Native) s.add ("ARCHS = \"$(NATIVE_ARCH_ACTUAL)\"");
  666. else if (arch == osxArch_32BitUniversal) s.add ("ARCHS = \"$(ARCHS_STANDARD_32_BIT)\"");
  667. else if (arch == osxArch_64BitUniversal) s.add ("ARCHS = \"$(ARCHS_STANDARD_32_64_BIT)\"");
  668. else if (arch == osxArch_64Bit) s.add ("ARCHS = \"$(ARCHS_STANDARD_64_BIT)\"");
  669. s.add ("HEADER_SEARCH_PATHS = " + getHeaderSearchPaths (config));
  670. s.add ("USE_HEADERMAP = " + String (static_cast<bool> (config.exporter.settings.getProperty ("useHeaderMap")) ? "YES" : "NO"));
  671. s.add ("GCC_OPTIMIZATION_LEVEL = " + config.getGCCOptimisationFlag());
  672. if (shouldCreatePList())
  673. {
  674. s.add ("INFOPLIST_FILE = " + infoPlistFile.getFileName());
  675. if (owner.getPListPrefixHeaderString().isNotEmpty())
  676. s.add ("INFOPLIST_PREFIX_HEADER = " + owner.getPListPrefixHeaderString());
  677. s.add ("INFOPLIST_PREPROCESS = " + (owner.isPListPreprocessEnabled() ? String ("YES") : String ("NO")));
  678. auto plistDefs = parsePreprocessorDefs (config.plistPreprocessorDefinitions.get());
  679. StringArray defsList;
  680. for (int i = 0; i < plistDefs.size(); ++i)
  681. {
  682. String def (plistDefs.getAllKeys()[i]);
  683. const String value (plistDefs.getAllValues()[i]);
  684. if (value.isNotEmpty())
  685. def << "=" << value.replace ("\"", "\\\\\\\"");
  686. defsList.add ("\"" + def + "\"");
  687. }
  688. if (defsList.size() > 0)
  689. s.add ("INFOPLIST_PREPROCESSOR_DEFINITIONS = " + indentParenthesisedList (defsList));
  690. }
  691. if (config.linkTimeOptimisationEnabled.get())
  692. s.add ("LLVM_LTO = YES");
  693. if (config.fastMathEnabled.get())
  694. s.add ("GCC_FAST_MATH = YES");
  695. const String extraFlags (owner.replacePreprocessorTokens (config, owner.getExtraCompilerFlagsString()).trim());
  696. if (extraFlags.isNotEmpty())
  697. s.add ("OTHER_CPLUSPLUSFLAGS = \"" + extraFlags + "\"");
  698. String installPath = getInstallPathForConfiguration (config);
  699. if (installPath.isNotEmpty())
  700. {
  701. s.add ("INSTALL_PATH = \"" + installPath + "\"");
  702. if (xcodeCopyToProductInstallPathAfterBuild)
  703. {
  704. s.add ("DEPLOYMENT_LOCATION = YES");
  705. s.add ("DSTROOT = /");
  706. }
  707. }
  708. if (getTargetFileType() == pluginBundle)
  709. {
  710. s.add ("LIBRARY_STYLE = Bundle");
  711. s.add ("WRAPPER_EXTENSION = " + xcodeBundleExtension.substring (1));
  712. s.add ("GENERATE_PKGINFO_FILE = YES");
  713. }
  714. if (xcodeOtherRezFlags.isNotEmpty())
  715. s.add ("OTHER_REZFLAGS = \"" + xcodeOtherRezFlags + "\"");
  716. String configurationBuildDir = "$(PROJECT_DIR)/build/$(CONFIGURATION)";
  717. if (config.getTargetBinaryRelativePathString().isNotEmpty())
  718. {
  719. // a target's position can either be defined via installPath + xcodeCopyToProductInstallPathAfterBuild
  720. // (= for audio plug-ins) or using a custom binary path (for everything else), but not both (= conflict!)
  721. jassert (! xcodeCopyToProductInstallPathAfterBuild);
  722. RelativePath binaryPath (config.getTargetBinaryRelativePathString(), RelativePath::projectFolder);
  723. configurationBuildDir = sanitisePath (binaryPath.rebased (owner.projectFolder, owner.getTargetFolder(), RelativePath::buildTargetFolder)
  724. .toUnixStyle());
  725. }
  726. s.add ("CONFIGURATION_BUILD_DIR = " + addQuotesIfRequired (configurationBuildDir));
  727. String gccVersion ("com.apple.compilers.llvm.clang.1_0");
  728. if (owner.iOS)
  729. {
  730. s.add ("ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon");
  731. s.add ("ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage");
  732. }
  733. else
  734. {
  735. String sdkRoot;
  736. s.add ("MACOSX_DEPLOYMENT_TARGET = " + getOSXDeploymentTarget(config, &sdkRoot));
  737. if (sdkRoot.isNotEmpty())
  738. s.add ("SDKROOT = " + sdkRoot);
  739. s.add ("MACOSX_DEPLOYMENT_TARGET_ppc = 10.4");
  740. s.add ("SDKROOT_ppc = macosx10.5");
  741. if (xcodeExcludedFiles64Bit.isNotEmpty())
  742. {
  743. s.add ("EXCLUDED_SOURCE_FILE_NAMES = \"$(EXCLUDED_SOURCE_FILE_NAMES_$(CURRENT_ARCH))\"");
  744. s.add ("EXCLUDED_SOURCE_FILE_NAMES_x86_64 = " + xcodeExcludedFiles64Bit);
  745. }
  746. }
  747. s.add ("GCC_VERSION = " + gccVersion);
  748. s.add ("CLANG_CXX_LANGUAGE_STANDARD = \"c++0x\"");
  749. s.add ("CLANG_LINK_OBJC_RUNTIME = NO");
  750. if (! config.codeSignIdentity.isUsingDefault())
  751. s.add ("CODE_SIGN_IDENTITY = " + config.codeSignIdentity.get().quoted());
  752. if (config.cppLanguageStandard.get().isNotEmpty())
  753. s.add ("CLANG_CXX_LANGUAGE_STANDARD = " + config.cppLanguageStandard.get().quoted());
  754. if (config.cppStandardLibrary.get().isNotEmpty())
  755. s.add ("CLANG_CXX_LIBRARY = " + config.cppStandardLibrary.get().quoted());
  756. s.add ("COMBINE_HIDPI_IMAGES = YES");
  757. {
  758. StringArray linkerFlags, librarySearchPaths;
  759. getLinkerSettings (config, linkerFlags, librarySearchPaths);
  760. if (linkerFlags.size() > 0)
  761. s.add ("OTHER_LDFLAGS = \"" + linkerFlags.joinIntoString (" ") + "\"");
  762. librarySearchPaths.addArray (config.getLibrarySearchPaths());
  763. librarySearchPaths = getCleanedStringArray (librarySearchPaths);
  764. if (librarySearchPaths.size() > 0)
  765. {
  766. String libPaths ("LIBRARY_SEARCH_PATHS = (\"$(inherited)\"");
  767. for (auto& p : librarySearchPaths)
  768. libPaths += ", \"\\\"" + p + "\\\"\"";
  769. s.add (libPaths + ")");
  770. }
  771. }
  772. StringPairArray defines;
  773. if (config.isDebug())
  774. {
  775. defines.set ("_DEBUG", "1");
  776. defines.set ("DEBUG", "1");
  777. s.add ("COPY_PHASE_STRIP = NO");
  778. s.add ("GCC_DYNAMIC_NO_PIC = NO");
  779. }
  780. else
  781. {
  782. defines.set ("_NDEBUG", "1");
  783. defines.set ("NDEBUG", "1");
  784. s.add ("GCC_GENERATE_DEBUGGING_SYMBOLS = NO");
  785. s.add ("GCC_SYMBOLS_PRIVATE_EXTERN = YES");
  786. s.add ("DEAD_CODE_STRIPPING = YES");
  787. }
  788. if (type != Target::SharedCodeTarget && type != Target::StaticLibrary && type != Target::DynamicLibrary
  789. && config.stripLocalSymbolsEnabled.get())
  790. {
  791. s.add ("STRIPFLAGS = \"-x\"");
  792. s.add ("DEPLOYMENT_POSTPROCESSING = YES");
  793. s.add ("SEPARATE_STRIP = YES");
  794. }
  795. if (owner.project.getProjectType().isAudioPlugin()
  796. && ( (owner.isOSX() && type == Target::AudioUnitv3PlugIn)
  797. || (owner.isiOS() && type == Target::StandalonePlugIn && owner.getProject().shouldEnableIAA())))
  798. s.add (String ("CODE_SIGN_ENTITLEMENTS = \"") + owner.getEntitlementsFileName() + String ("\""));
  799. defines = mergePreprocessorDefs (defines, owner.getAllPreprocessorDefs (config, type));
  800. StringArray defsList;
  801. for (int i = 0; i < defines.size(); ++i)
  802. {
  803. String def (defines.getAllKeys()[i]);
  804. const String value (defines.getAllValues()[i]);
  805. if (value.isNotEmpty())
  806. def << "=" << value.replace ("\"", "\\\\\\\"");
  807. defsList.add ("\"" + def + "\"");
  808. }
  809. s.add ("GCC_PREPROCESSOR_DEFINITIONS = " + indentParenthesisedList (defsList));
  810. s.addTokens (config.customXcodeFlags.get(), ",", "\"'");
  811. return getCleanedStringArray (s);
  812. }
  813. String getInstallPathForConfiguration (const XcodeBuildConfiguration& config) const
  814. {
  815. switch (type)
  816. {
  817. case GUIApp: return "$(HOME)/Applications";
  818. case ConsoleApp: return "/usr/bin";
  819. case VSTPlugIn: return config.vstBinaryLocation.get();
  820. case VST3PlugIn: return config.vst3BinaryLocation.get();
  821. case AudioUnitPlugIn: return config.auBinaryLocation.get();
  822. case RTASPlugIn: return config.rtasBinaryLocation.get();
  823. case AAXPlugIn: return config.aaxBinaryLocation.get();
  824. case SharedCodeTarget: return owner.isiOS() ? "@executable_path/Frameworks" : "@executable_path/../Frameworks";
  825. default: return {};
  826. }
  827. }
  828. //==============================================================================
  829. void getLinkerSettings (const BuildConfiguration& config, StringArray& flags, StringArray& librarySearchPaths) const
  830. {
  831. if (getTargetFileType() == pluginBundle)
  832. flags.add (owner.isiOS() ? "-bitcode_bundle" : "-bundle");
  833. Array<RelativePath> extraLibs (config.isDebug() ? xcodeExtraLibrariesDebug
  834. : xcodeExtraLibrariesRelease);
  835. addExtraLibsForTargetType (config, extraLibs);
  836. for (auto& lib : extraLibs)
  837. {
  838. flags.add (getLinkerFlagForLib (lib.getFileNameWithoutExtension()));
  839. librarySearchPaths.add (owner.getSearchPathForStaticLibrary (lib));
  840. }
  841. if (owner.project.getProjectType().isAudioPlugin() && type != Target::SharedCodeTarget)
  842. {
  843. if (owner.getTargetOfType (Target::SharedCodeTarget) != nullptr)
  844. {
  845. String productName (getStaticLibbedFilename (owner.replacePreprocessorTokens (config, config.getTargetBinaryNameString())));
  846. RelativePath sharedCodelib (productName, RelativePath::buildTargetFolder);
  847. flags.add (getLinkerFlagForLib (sharedCodelib.getFileNameWithoutExtension()));
  848. }
  849. }
  850. flags.add (owner.replacePreprocessorTokens (config, owner.getExtraLinkerFlagsString()));
  851. flags.add (owner.getExternalLibraryFlags (config));
  852. StringArray libs (owner.xcodeLibs);
  853. libs.addArray (xcodeLibs);
  854. for (auto& l : libs)
  855. flags.add (getLinkerFlagForLib (l));
  856. flags = getCleanedStringArray (flags);
  857. }
  858. //========================================================================== c
  859. void writeInfoPlistFile() const
  860. {
  861. if (! shouldCreatePList())
  862. return;
  863. ScopedPointer<XmlElement> plist (XmlDocument::parse (owner.getPListToMergeString()));
  864. if (plist == nullptr || ! plist->hasTagName ("plist"))
  865. plist = new XmlElement ("plist");
  866. XmlElement* dict = plist->getChildByName ("dict");
  867. if (dict == nullptr)
  868. dict = plist->createNewChildElement ("dict");
  869. if (owner.iOS)
  870. {
  871. addPlistDictionaryKeyBool (dict, "LSRequiresIPhoneOS", true);
  872. if (owner.isMicrophonePermissionEnabled())
  873. addPlistDictionaryKey (dict, "NSMicrophoneUsageDescription", "This app requires microphone input.");
  874. if (type != AudioUnitv3PlugIn)
  875. addPlistDictionaryKeyBool (dict, "UIViewControllerBasedStatusBarAppearance", false);
  876. }
  877. addPlistDictionaryKey (dict, "CFBundleExecutable", "${EXECUTABLE_NAME}");
  878. if (! owner.iOS) // (NB: on iOS this causes error ITMS-90032 during publishing)
  879. addPlistDictionaryKey (dict, "CFBundleIconFile", owner.iconFile.exists() ? owner.iconFile.getFileName() : String());
  880. addPlistDictionaryKey (dict, "CFBundleIdentifier", "$(PRODUCT_BUNDLE_IDENTIFIER)");
  881. addPlistDictionaryKey (dict, "CFBundleName", owner.projectName);
  882. // needed by NSExtension on iOS
  883. addPlistDictionaryKey (dict, "CFBundleDisplayName", owner.projectName);
  884. addPlistDictionaryKey (dict, "CFBundlePackageType", xcodePackageType);
  885. addPlistDictionaryKey (dict, "CFBundleSignature", xcodeBundleSignature);
  886. addPlistDictionaryKey (dict, "CFBundleShortVersionString", owner.project.getVersionString());
  887. addPlistDictionaryKey (dict, "CFBundleVersion", owner.project.getVersionString());
  888. addPlistDictionaryKey (dict, "NSHumanReadableCopyright", owner.project.getCompanyName().toString());
  889. addPlistDictionaryKeyBool (dict, "NSHighResolutionCapable", true);
  890. StringArray documentExtensions;
  891. documentExtensions.addTokens (replacePreprocessorDefs (owner.getAllPreprocessorDefs(), owner.settings ["documentExtensions"]),
  892. ",", StringRef());
  893. documentExtensions.trim();
  894. documentExtensions.removeEmptyStrings (true);
  895. if (documentExtensions.size() > 0 && type != AudioUnitv3PlugIn)
  896. {
  897. dict->createNewChildElement ("key")->addTextElement ("CFBundleDocumentTypes");
  898. XmlElement* dict2 = dict->createNewChildElement ("array")->createNewChildElement ("dict");
  899. XmlElement* arrayTag = nullptr;
  900. for (String ex : documentExtensions)
  901. {
  902. if (ex.startsWithChar ('.'))
  903. ex = ex.substring (1);
  904. if (arrayTag == nullptr)
  905. {
  906. dict2->createNewChildElement ("key")->addTextElement ("CFBundleTypeExtensions");
  907. arrayTag = dict2->createNewChildElement ("array");
  908. addPlistDictionaryKey (dict2, "CFBundleTypeName", ex);
  909. addPlistDictionaryKey (dict2, "CFBundleTypeRole", "Editor");
  910. addPlistDictionaryKey (dict2, "CFBundleTypeIconFile", "Icon");
  911. addPlistDictionaryKey (dict2, "NSPersistentStoreTypeKey", "XML");
  912. }
  913. arrayTag->createNewChildElement ("string")->addTextElement (ex);
  914. }
  915. }
  916. if (owner.settings ["UIFileSharingEnabled"] && type != AudioUnitv3PlugIn)
  917. addPlistDictionaryKeyBool (dict, "UIFileSharingEnabled", true);
  918. if (owner.settings ["UIStatusBarHidden"] && type != AudioUnitv3PlugIn)
  919. addPlistDictionaryKeyBool (dict, "UIStatusBarHidden", true);
  920. if (owner.iOS)
  921. {
  922. if (type != AudioUnitv3PlugIn)
  923. {
  924. // Forcing full screen disables the split screen feature and prevents error ITMS-90475
  925. addPlistDictionaryKeyBool (dict, "UIRequiresFullScreen", true);
  926. addPlistDictionaryKeyBool (dict, "UIStatusBarHidden", true);
  927. addIosScreenOrientations (dict);
  928. addIosBackgroundModes (dict);
  929. }
  930. if (type == StandalonePlugIn && owner.getProject().shouldEnableIAA())
  931. {
  932. XmlElement audioComponentsPlistKey ("key");
  933. audioComponentsPlistKey.addTextElement ("AudioComponents");
  934. dict->addChildElement (new XmlElement (audioComponentsPlistKey));
  935. XmlElement audioComponentsPlistEntry ("array");
  936. XmlElement* audioComponentsDict = audioComponentsPlistEntry.createNewChildElement ("dict");
  937. addPlistDictionaryKey (audioComponentsDict, "name", owner.project.getIAAPluginName());
  938. addPlistDictionaryKey (audioComponentsDict, "manufacturer", owner.project.getPluginManufacturerCode().toString().trim().substring (0, 4));
  939. addPlistDictionaryKey (audioComponentsDict, "type", owner.project.getIAATypeCode());
  940. addPlistDictionaryKey (audioComponentsDict, "subtype", owner.project.getPluginCode().toString().trim().substring (0, 4));
  941. addPlistDictionaryKeyInt (audioComponentsDict, "version", owner.project.getVersionAsHexInteger());
  942. dict->addChildElement (new XmlElement (audioComponentsPlistEntry));
  943. }
  944. }
  945. for (auto& e : xcodeExtraPListEntries)
  946. dict->addChildElement (new XmlElement (e));
  947. MemoryOutputStream mo;
  948. plist->writeToStream (mo, "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
  949. overwriteFileIfDifferentOrThrow (infoPlistFile, mo);
  950. }
  951. //==============================================================================
  952. void addIosScreenOrientations (XmlElement* dict) const
  953. {
  954. String screenOrientation = owner.getScreenOrientationString();
  955. StringArray iOSOrientations;
  956. if (screenOrientation.contains ("portrait")) { iOSOrientations.add ("UIInterfaceOrientationPortrait"); }
  957. if (screenOrientation.contains ("landscape")) { iOSOrientations.add ("UIInterfaceOrientationLandscapeLeft"); iOSOrientations.add ("UIInterfaceOrientationLandscapeRight"); }
  958. addArrayToPlist (dict, "UISupportedInterfaceOrientations", iOSOrientations);
  959. }
  960. //==============================================================================
  961. void addIosBackgroundModes (XmlElement* dict) const
  962. {
  963. StringArray iosBackgroundModes;
  964. if (owner.isBackgroundAudioEnabled()) iosBackgroundModes.add ("audio");
  965. if (owner.isBackgroundBleEnabled()) iosBackgroundModes.add ("bluetooth-central");
  966. addArrayToPlist (dict, "UIBackgroundModes", iosBackgroundModes);
  967. }
  968. //==============================================================================
  969. static void addArrayToPlist (XmlElement* dict, String arrayKey, const StringArray& arrayElements)
  970. {
  971. dict->createNewChildElement ("key")->addTextElement (arrayKey);
  972. XmlElement* plistStringArray = dict->createNewChildElement ("array");
  973. for (auto& e : arrayElements)
  974. plistStringArray->createNewChildElement ("string")->addTextElement (e);
  975. }
  976. //==============================================================================
  977. void addShellScriptBuildPhase (const String& phaseName, const String& script)
  978. {
  979. if (script.trim().isNotEmpty())
  980. {
  981. ValueTree& v = addBuildPhase ("PBXShellScriptBuildPhase", StringArray());
  982. v.setProperty (Ids::name, phaseName, nullptr);
  983. v.setProperty ("shellPath", "/bin/sh", nullptr);
  984. v.setProperty ("shellScript", script.replace ("\\", "\\\\")
  985. .replace ("\"", "\\\"")
  986. .replace ("\r\n", "\\n")
  987. .replace ("\n", "\\n"), nullptr);
  988. }
  989. }
  990. void addCopyFilesPhase (const String& phaseName, const StringArray& files, XcodeCopyFilesDestinationIDs dst)
  991. {
  992. ValueTree& v = addBuildPhase ("PBXCopyFilesBuildPhase", files, phaseName);
  993. v.setProperty ("dstPath", "", nullptr);
  994. v.setProperty ("dstSubfolderSpec", (int) dst, nullptr);
  995. }
  996. //==============================================================================
  997. String getHeaderSearchPaths (const BuildConfiguration& config) const
  998. {
  999. StringArray paths (owner.extraSearchPaths);
  1000. paths.addArray (config.getHeaderSearchPaths());
  1001. paths.addArray (getTargetExtraHeaderSearchPaths());
  1002. if (owner.project.getModules().isModuleEnabled ("juce_audio_plugin_client"))
  1003. {
  1004. // Needed to compile .r files
  1005. paths.add (owner.getModuleFolderRelativeToProject ("juce_audio_plugin_client")
  1006. .rebased (owner.projectFolder, owner.getTargetFolder(), RelativePath::buildTargetFolder)
  1007. .toUnixStyle());
  1008. }
  1009. paths.add ("$(inherited)");
  1010. paths = getCleanedStringArray (paths);
  1011. for (auto& s : paths)
  1012. {
  1013. s = owner.replacePreprocessorTokens (config, s);
  1014. if (s.containsChar (' '))
  1015. s = "\"\\\"" + s + "\\\"\""; // crazy double quotes required when there are spaces..
  1016. else
  1017. s = "\"" + s + "\"";
  1018. }
  1019. return "(" + paths.joinIntoString (", ") + ")";
  1020. }
  1021. private:
  1022. //==============================================================================
  1023. void addExtraAudioUnitTargetSettings()
  1024. {
  1025. xcodeOtherRezFlags = "-d ppc_$ppc -d i386_$i386 -d ppc64_$ppc64 -d x86_64_$x86_64"
  1026. " -I /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Versions/A/Headers"
  1027. " -I \\\"$(DEVELOPER_DIR)/Extras/CoreAudio/AudioUnits/AUPublic/AUBase\\\"";
  1028. xcodeFrameworks.addTokens ("AudioUnit CoreAudioKit", false);
  1029. XmlElement plistKey ("key");
  1030. plistKey.addTextElement ("AudioComponents");
  1031. XmlElement plistEntry ("array");
  1032. XmlElement* dict = plistEntry.createNewChildElement ("dict");
  1033. const String pluginManufacturerCode = owner.project.getPluginManufacturerCode().toString().trim().substring (0, 4);
  1034. const String pluginSubType = owner.project.getPluginCode() .toString().trim().substring (0, 4);
  1035. if (pluginManufacturerCode.toLowerCase() == pluginManufacturerCode)
  1036. {
  1037. throw SaveError ("AudioUnit plugin code identifiers invalid!\n\n"
  1038. "You have used only lower case letters in your AU plugin manufacturer identifier. "
  1039. "You must have at least one uppercase letter in your AU plugin manufacturer "
  1040. "identifier code.");
  1041. }
  1042. addPlistDictionaryKey (dict, "name", owner.project.getPluginManufacturer().toString()
  1043. + ": " + owner.project.getPluginName().toString());
  1044. addPlistDictionaryKey (dict, "description", owner.project.getPluginDesc().toString());
  1045. addPlistDictionaryKey (dict, "factoryFunction", owner.project.getPluginAUExportPrefix().toString() + "Factory");
  1046. addPlistDictionaryKey (dict, "manufacturer", pluginManufacturerCode);
  1047. addPlistDictionaryKey (dict, "type", owner.project.getAUMainTypeCode());
  1048. addPlistDictionaryKey (dict, "subtype", pluginSubType);
  1049. addPlistDictionaryKeyInt (dict, "version", owner.project.getVersionAsHexInteger());
  1050. xcodeExtraPListEntries.add (plistKey);
  1051. xcodeExtraPListEntries.add (plistEntry);
  1052. }
  1053. void addExtraAudioUnitv3PlugInTargetSettings()
  1054. {
  1055. if (owner.isiOS())
  1056. xcodeFrameworks.addTokens ("CoreAudioKit AVFoundation", false);
  1057. else
  1058. xcodeFrameworks.addTokens ("AudioUnit CoreAudioKit AVFoundation", false);
  1059. XmlElement plistKey ("key");
  1060. plistKey.addTextElement ("NSExtension");
  1061. XmlElement plistEntry ("dict");
  1062. addPlistDictionaryKey (&plistEntry, "NSExtensionPrincipalClass", owner.project.getPluginAUExportPrefix().toString() + "FactoryAUv3");
  1063. addPlistDictionaryKey (&plistEntry, "NSExtensionPointIdentifier", "com.apple.AudioUnit-UI");
  1064. plistEntry.createNewChildElement ("key")->addTextElement ("NSExtensionAttributes");
  1065. XmlElement* dict = plistEntry.createNewChildElement ("dict");
  1066. dict->createNewChildElement ("key")->addTextElement ("AudioComponents");
  1067. XmlElement* componentArray = dict->createNewChildElement ("array");
  1068. XmlElement* componentDict = componentArray->createNewChildElement ("dict");
  1069. addPlistDictionaryKey (componentDict, "name", owner.project.getPluginManufacturer().toString()
  1070. + ": " + owner.project.getPluginName().toString());
  1071. addPlistDictionaryKey (componentDict, "description", owner.project.getPluginDesc().toString());
  1072. addPlistDictionaryKey (componentDict, "factoryFunction",owner.project. getPluginAUExportPrefix().toString() + "FactoryAUv3");
  1073. addPlistDictionaryKey (componentDict, "manufacturer", owner.project.getPluginManufacturerCode().toString().trim().substring (0, 4));
  1074. addPlistDictionaryKey (componentDict, "type", owner.project.getAUMainTypeCode());
  1075. addPlistDictionaryKey (componentDict, "subtype", owner.project.getPluginCode().toString().trim().substring (0, 4));
  1076. addPlistDictionaryKeyInt (componentDict, "version", owner.project.getVersionAsHexInteger());
  1077. addPlistDictionaryKeyBool (componentDict, "sandboxSafe", true);
  1078. componentDict->createNewChildElement ("key")->addTextElement ("tags");
  1079. XmlElement* tagsArray = componentDict->createNewChildElement ("array");
  1080. tagsArray->createNewChildElement ("string")
  1081. ->addTextElement (static_cast<bool> (owner.project.getPluginIsSynth().getValue()) ? "Synth" : "Effects");
  1082. xcodeExtraPListEntries.add (plistKey);
  1083. xcodeExtraPListEntries.add (plistEntry);
  1084. }
  1085. void addExtraLibsForTargetType (const BuildConfiguration& config, Array<RelativePath>& extraLibs) const
  1086. {
  1087. if (type == AAXPlugIn)
  1088. {
  1089. auto aaxLibsFolder
  1090. = RelativePath (owner.getAAXPathValue().toString(), RelativePath::projectFolder)
  1091. .getChildFile ("Libs");
  1092. String libraryPath (config.isDebug() ? "Debug/libAAXLibrary" : "Release/libAAXLibrary");
  1093. libraryPath += (isUsingClangCppLibrary (config) ? "_libcpp.a" : ".a");
  1094. extraLibs.add (aaxLibsFolder.getChildFile (libraryPath));
  1095. }
  1096. else if (type == RTASPlugIn)
  1097. {
  1098. RelativePath rtasFolder (owner.getRTASPathValue().toString(), RelativePath::projectFolder);
  1099. extraLibs.add (rtasFolder.getChildFile ("MacBag/Libs/Debug/libPluginLibrary.a"));
  1100. extraLibs.add (rtasFolder.getChildFile ("MacBag/Libs/Release/libPluginLibrary.a"));
  1101. }
  1102. }
  1103. StringArray getTargetExtraHeaderSearchPaths() const
  1104. {
  1105. StringArray targetExtraSearchPaths;
  1106. if (type == RTASPlugIn)
  1107. {
  1108. RelativePath rtasFolder (owner.getRTASPathValue().toString(), RelativePath::projectFolder);
  1109. targetExtraSearchPaths.add ("$(DEVELOPER_DIR)/Headers/FlatCarbon");
  1110. targetExtraSearchPaths.add ("$(SDKROOT)/Developer/Headers/FlatCarbon");
  1111. static const char* p[] = { "AlturaPorts/TDMPlugIns/PlugInLibrary/Controls",
  1112. "AlturaPorts/TDMPlugIns/PlugInLibrary/CoreClasses",
  1113. "AlturaPorts/TDMPlugIns/PlugInLibrary/DSPClasses",
  1114. "AlturaPorts/TDMPlugIns/PlugInLibrary/EffectClasses",
  1115. "AlturaPorts/TDMPlugIns/PlugInLibrary/MacBuild",
  1116. "AlturaPorts/TDMPlugIns/PlugInLibrary/Meters",
  1117. "AlturaPorts/TDMPlugIns/PlugInLibrary/ProcessClasses",
  1118. "AlturaPorts/TDMPlugIns/PlugInLibrary/ProcessClasses/Interfaces",
  1119. "AlturaPorts/TDMPlugIns/PlugInLibrary/RTASP_Adapt",
  1120. "AlturaPorts/TDMPlugIns/PlugInLibrary/Utilities",
  1121. "AlturaPorts/TDMPlugIns/PlugInLibrary/ViewClasses",
  1122. "AlturaPorts/TDMPlugIns/DSPManager/**",
  1123. "AlturaPorts/TDMPlugIns/SupplementalPlugInLib/Encryption",
  1124. "AlturaPorts/TDMPlugIns/SupplementalPlugInLib/GraphicsExtensions",
  1125. "AlturaPorts/TDMPlugIns/common/**",
  1126. "AlturaPorts/TDMPlugIns/common/PI_LibInterface",
  1127. "AlturaPorts/TDMPlugIns/PACEProtection/**",
  1128. "AlturaPorts/TDMPlugIns/SignalProcessing/**",
  1129. "AlturaPorts/OMS/Headers",
  1130. "AlturaPorts/Fic/Interfaces/**",
  1131. "AlturaPorts/Fic/Source/SignalNets",
  1132. "AlturaPorts/DSIPublicInterface/PublicHeaders",
  1133. "DAEWin/Include",
  1134. "AlturaPorts/DigiPublic/Interfaces",
  1135. "AlturaPorts/DigiPublic",
  1136. "AlturaPorts/NewFileLibs/DOA",
  1137. "AlturaPorts/NewFileLibs/Cmn",
  1138. "xplat/AVX/avx2/avx2sdk/inc",
  1139. "xplat/AVX/avx2/avx2sdk/utils" };
  1140. for (auto* path : p)
  1141. owner.addProjectPathToBuildPathList (targetExtraSearchPaths, rtasFolder.getChildFile (path));
  1142. }
  1143. return targetExtraSearchPaths;
  1144. }
  1145. bool isUsingClangCppLibrary (const BuildConfiguration& config) const
  1146. {
  1147. if (auto xcodeConfig = dynamic_cast<const XcodeBuildConfiguration*> (&config))
  1148. {
  1149. const String& configValue = xcodeConfig->cppStandardLibrary.get();
  1150. if (configValue.isNotEmpty())
  1151. return (configValue == "libc++");
  1152. const int minorOSXDeploymentTarget
  1153. = getOSXDeploymentTarget (*xcodeConfig).fromLastOccurrenceOf (".", false, false).getIntValue();
  1154. return (minorOSXDeploymentTarget > 8);
  1155. }
  1156. return false;
  1157. }
  1158. String getOSXDeploymentTarget (const XcodeBuildConfiguration& config, String* sdkRoot = nullptr) const
  1159. {
  1160. const String sdk (config.osxSDKVersion.get());
  1161. const String sdkCompat (config.osxDeploymentTarget.get());
  1162. // The AUv3 target always needs to be at least 10.11
  1163. int oldestAllowedDeploymentTarget = (type == Target::AudioUnitv3PlugIn ? minimumAUv3SDKVersion
  1164. : oldestSDKVersion);
  1165. // if the user doesn't set it, then use the last known version that works well with JUCE
  1166. String deploymentTarget = "10.11";
  1167. for (int ver = oldestAllowedDeploymentTarget; ver <= currentSDKVersion; ++ver)
  1168. {
  1169. if (sdk == getSDKName (ver) && sdkRoot != nullptr) *sdkRoot = String ("macosx10." + String (ver));
  1170. if (sdkCompat == getSDKName (ver)) deploymentTarget = "10." + String (ver);
  1171. }
  1172. return deploymentTarget;
  1173. }
  1174. //==============================================================================
  1175. const XCodeProjectExporter& owner;
  1176. Target& operator= (const Target&) JUCE_DELETED_FUNCTION;
  1177. };
  1178. mutable StringArray xcodeFrameworks;
  1179. StringArray xcodeLibs;
  1180. private:
  1181. //==============================================================================
  1182. bool xcodeCanUseDwarf;
  1183. OwnedArray<XCodeTarget> targets;
  1184. mutable OwnedArray<ValueTree> pbxBuildFiles, pbxFileReferences, pbxGroups, misc, projectConfigs, targetConfigs;
  1185. mutable StringArray resourceIDs, sourceIDs, targetIDs;
  1186. mutable StringArray frameworkFileIDs, rezFileIDs, resourceFileRefs;
  1187. mutable File menuNibFile, iconFile;
  1188. mutable StringArray buildProducts;
  1189. const bool iOS;
  1190. static String sanitisePath (const String& path)
  1191. {
  1192. if (path.startsWithChar ('~'))
  1193. return "$(HOME)" + path.substring (1);
  1194. return path;
  1195. }
  1196. static String addQuotesIfRequired (const String& s)
  1197. {
  1198. return s.containsAnyOf (" $") ? s.quoted() : s;
  1199. }
  1200. File getProjectBundle() const { return getTargetFolder().getChildFile (project.getProjectFilenameRoot()).withFileExtension (".xcodeproj"); }
  1201. //==============================================================================
  1202. void createObjects() const
  1203. {
  1204. prepareTargets();
  1205. addFrameworks();
  1206. addCustomResourceFolders();
  1207. addPlistFileReferences();
  1208. if (iOS && ! projectType.isStaticLibrary())
  1209. addXcassets();
  1210. else
  1211. addNibFiles();
  1212. addIcons();
  1213. addBuildConfigurations();
  1214. addProjectConfigList (projectConfigs, createID ("__projList"));
  1215. {
  1216. StringArray topLevelGroupIDs;
  1217. addFilesAndGroupsToProject (topLevelGroupIDs);
  1218. addBuildPhases();
  1219. addExtraGroupsToProject (topLevelGroupIDs);
  1220. addGroup (createID ("__mainsourcegroup"), "Source", topLevelGroupIDs);
  1221. }
  1222. addProjectObject();
  1223. removeMismatchedXcuserdata();
  1224. }
  1225. void prepareTargets() const
  1226. {
  1227. for (auto* target : targets)
  1228. {
  1229. if (target->type == XCodeTarget::AggregateTarget)
  1230. continue;
  1231. target->addMainBuildProduct();
  1232. String targetName = target->getName();
  1233. String fileID (createID (targetName + String ("__targetbuildref")));
  1234. String fileRefID (createID (String ("__productFileID") + targetName));
  1235. ValueTree* v = new ValueTree (fileID);
  1236. v->setProperty ("isa", "PBXBuildFile", nullptr);
  1237. v->setProperty ("fileRef", fileRefID, nullptr);
  1238. target->mainBuildProductID = fileID;
  1239. pbxBuildFiles.add (v);
  1240. target->addDependency();
  1241. }
  1242. }
  1243. void addPlistFileReferences() const
  1244. {
  1245. for (auto* target : targets)
  1246. {
  1247. if (target->type == XCodeTarget::AggregateTarget)
  1248. continue;
  1249. if (target->shouldCreatePList())
  1250. {
  1251. RelativePath plistPath (target->infoPlistFile, getTargetFolder(), RelativePath::buildTargetFolder);
  1252. addFileReference (plistPath.toUnixStyle());
  1253. resourceFileRefs.add (createFileRefID (plistPath));
  1254. }
  1255. }
  1256. }
  1257. void addNibFiles() const
  1258. {
  1259. MemoryOutputStream nib;
  1260. nib.write (BinaryData::RecentFilesMenuTemplate_nib, BinaryData::RecentFilesMenuTemplate_nibSize);
  1261. overwriteFileIfDifferentOrThrow (menuNibFile, nib);
  1262. RelativePath menuNibPath (menuNibFile, getTargetFolder(), RelativePath::buildTargetFolder);
  1263. addFileReference (menuNibPath.toUnixStyle());
  1264. resourceIDs.add (addBuildFile (menuNibPath, false, false));
  1265. resourceFileRefs.add (createFileRefID (menuNibPath));
  1266. }
  1267. void addIcons() const
  1268. {
  1269. if (iconFile.exists())
  1270. {
  1271. RelativePath iconPath (iconFile, getTargetFolder(), RelativePath::buildTargetFolder);
  1272. addFileReference (iconPath.toUnixStyle());
  1273. resourceIDs.add (addBuildFile (iconPath, false, false));
  1274. resourceFileRefs.add (createFileRefID (iconPath));
  1275. }
  1276. }
  1277. void addBuildConfigurations() const
  1278. {
  1279. // add build configurations
  1280. for (ConstConfigIterator config (*this); config.next();)
  1281. {
  1282. const XcodeBuildConfiguration& xcodeConfig = dynamic_cast<const XcodeBuildConfiguration&> (*config);
  1283. addProjectConfig (config->getName(), getProjectSettings (xcodeConfig));
  1284. }
  1285. }
  1286. void addFilesAndGroupsToProject (StringArray& topLevelGroupIDs) const
  1287. {
  1288. StringArray entitlements = getEntitlements();
  1289. if (! entitlements.isEmpty())
  1290. topLevelGroupIDs.add (addEntitlementsFile (entitlements));
  1291. for (auto& group : getAllGroups())
  1292. if (group.getNumChildren() > 0)
  1293. topLevelGroupIDs.add (addProjectItem (group));
  1294. }
  1295. void addExtraGroupsToProject (StringArray& topLevelGroupIDs) const
  1296. {
  1297. { // Add 'resources' group
  1298. String resourcesGroupID (createID ("__resources"));
  1299. addGroup (resourcesGroupID, "Resources", resourceFileRefs);
  1300. topLevelGroupIDs.add (resourcesGroupID);
  1301. }
  1302. { // Add 'frameworks' group
  1303. String frameworksGroupID (createID ("__frameworks"));
  1304. addGroup (frameworksGroupID, "Frameworks", frameworkFileIDs);
  1305. topLevelGroupIDs.add (frameworksGroupID);
  1306. }
  1307. { // Add 'products' group
  1308. String productsGroupID (createID ("__products"));
  1309. addGroup (productsGroupID, "Products", buildProducts);
  1310. topLevelGroupIDs.add (productsGroupID);
  1311. }
  1312. }
  1313. void addBuildPhases() const
  1314. {
  1315. // add build phases
  1316. for (auto* target : targets)
  1317. {
  1318. if (target->type != XCodeTarget::AggregateTarget)
  1319. buildProducts.add (createID (String ("__productFileID") + String (target->getName())));
  1320. for (ConstConfigIterator config (*this); config.next();)
  1321. {
  1322. const XcodeBuildConfiguration& xcodeConfig = dynamic_cast<const XcodeBuildConfiguration&> (*config);
  1323. target->addTargetConfig (config->getName(), target->getTargetSettings (xcodeConfig));
  1324. }
  1325. addConfigList (*target, targetConfigs, createID (String ("__configList") + target->getName()));
  1326. target->addShellScriptBuildPhase ("Pre-build script", getPreBuildScript());
  1327. if (target->type != XCodeTarget::AggregateTarget)
  1328. {
  1329. // TODO: ideally resources wouldn't be copied into the AUv3 bundle as well.
  1330. // However, fixing this requires supporting App groups -> TODO: add app groups
  1331. if (! projectType.isStaticLibrary() && target->type != XCodeTarget::SharedCodeTarget)
  1332. target->addBuildPhase ("PBXResourcesBuildPhase", resourceIDs);
  1333. StringArray rezFiles (rezFileIDs);
  1334. rezFiles.addArray (target->rezFileIDs);
  1335. if (rezFiles.size() > 0)
  1336. target->addBuildPhase ("PBXRezBuildPhase", rezFiles);
  1337. StringArray sourceFiles (target->sourceIDs);
  1338. if (target->type == XCodeTarget::SharedCodeTarget
  1339. || (! project.getProjectType().isAudioPlugin()))
  1340. sourceFiles.addArray (sourceIDs);
  1341. target->addBuildPhase ("PBXSourcesBuildPhase", sourceFiles);
  1342. if (! projectType.isStaticLibrary() && target->type != XCodeTarget::SharedCodeTarget)
  1343. target->addBuildPhase ("PBXFrameworksBuildPhase", target->frameworkIDs);
  1344. }
  1345. target->addShellScriptBuildPhase ("Post-build script", getPostBuildScript());
  1346. if (project.getProjectType().isAudioPlugin() && project.shouldBuildAUv3()
  1347. && project.shouldBuildStandalonePlugin() && target->type == XCodeTarget::StandalonePlugIn)
  1348. embedAppExtension();
  1349. addTargetObject (*target);
  1350. }
  1351. }
  1352. void embedAppExtension() const
  1353. {
  1354. if (auto* standaloneTarget = getTargetOfType (XCodeTarget::StandalonePlugIn))
  1355. {
  1356. if (auto* auv3Target = getTargetOfType (XCodeTarget::AudioUnitv3PlugIn))
  1357. {
  1358. StringArray files;
  1359. files.add (auv3Target->mainBuildProductID);
  1360. standaloneTarget->addCopyFilesPhase ("Embed App Extensions", files, kPluginsFolder);
  1361. }
  1362. }
  1363. }
  1364. static Image fixMacIconImageSize (Drawable& image)
  1365. {
  1366. const int validSizes[] = { 16, 32, 48, 128, 256, 512, 1024 };
  1367. const int w = image.getWidth();
  1368. const int h = image.getHeight();
  1369. int bestSize = 16;
  1370. for (int size : validSizes)
  1371. {
  1372. if (w == h && w == size)
  1373. {
  1374. bestSize = w;
  1375. break;
  1376. }
  1377. if (jmax (w, h) > size)
  1378. bestSize = size;
  1379. }
  1380. return rescaleImageForIcon (image, bestSize);
  1381. }
  1382. //==============================================================================
  1383. XCodeTarget* getTargetOfType (ProjectType::Target::Type type) const
  1384. {
  1385. for (auto& target : targets)
  1386. if (target->type == type)
  1387. return target;
  1388. return nullptr;
  1389. }
  1390. void addTargetObject (XCodeTarget& target) const
  1391. {
  1392. String targetName = target.getName();
  1393. String targetID = target.getID();
  1394. ValueTree* const v = new ValueTree (targetID);
  1395. v->setProperty ("isa", target.type == XCodeTarget::AggregateTarget ? "PBXAggregateTarget" : "PBXNativeTarget", nullptr);
  1396. v->setProperty ("buildConfigurationList", createID (String ("__configList") + targetName), nullptr);
  1397. v->setProperty ("buildPhases", indentParenthesisedList (target.buildPhaseIDs), nullptr);
  1398. v->setProperty ("buildRules", "( )", nullptr);
  1399. v->setProperty ("dependencies", indentParenthesisedList (getTargetDependencies (target)), nullptr);
  1400. v->setProperty (Ids::name, target.getXCodeSchemeName(), nullptr);
  1401. v->setProperty ("productName", projectName, nullptr);
  1402. if (target.type != XCodeTarget::AggregateTarget)
  1403. {
  1404. v->setProperty ("productReference", createID (String ("__productFileID") + targetName), nullptr);
  1405. jassert (target.xcodeProductType.isNotEmpty());
  1406. v->setProperty ("productType", target.xcodeProductType, nullptr);
  1407. }
  1408. targetIDs.add (targetID);
  1409. misc.add (v);
  1410. }
  1411. StringArray getTargetDependencies (const XCodeTarget& target) const
  1412. {
  1413. StringArray dependencies;
  1414. if (project.getProjectType().isAudioPlugin())
  1415. {
  1416. if (target.type == XCodeTarget::StandalonePlugIn) // depends on AUv3 and shared code
  1417. {
  1418. if (XCodeTarget* auv3Target = getTargetOfType (XCodeTarget::AudioUnitv3PlugIn))
  1419. dependencies.add (auv3Target->getDependencyID());
  1420. if (XCodeTarget* sharedCodeTarget = getTargetOfType (XCodeTarget::SharedCodeTarget))
  1421. dependencies.add (sharedCodeTarget->getDependencyID());
  1422. }
  1423. else if (target.type == XCodeTarget::AggregateTarget) // depends on all other targets
  1424. {
  1425. for (int i = 1; i < targets.size(); ++i)
  1426. dependencies.add (targets[i]->getDependencyID());
  1427. }
  1428. else if (target.type != XCodeTarget::SharedCodeTarget) // shared code doesn't depend on anything; all other targets depend only on the shared code
  1429. {
  1430. if (XCodeTarget* sharedCodeTarget = getTargetOfType (XCodeTarget::SharedCodeTarget))
  1431. dependencies.add (sharedCodeTarget->getDependencyID());
  1432. }
  1433. }
  1434. return dependencies;
  1435. }
  1436. static void writeOldIconFormat (MemoryOutputStream& out, const Image& image, const char* type, const char* maskType)
  1437. {
  1438. const int w = image.getWidth();
  1439. const int h = image.getHeight();
  1440. out.write (type, 4);
  1441. out.writeIntBigEndian (8 + 4 * w * h);
  1442. const Image::BitmapData bitmap (image, Image::BitmapData::readOnly);
  1443. for (int y = 0; y < h; ++y)
  1444. {
  1445. for (int x = 0; x < w; ++x)
  1446. {
  1447. const Colour pixel (bitmap.getPixelColour (x, y));
  1448. out.writeByte ((char) pixel.getAlpha());
  1449. out.writeByte ((char) pixel.getRed());
  1450. out.writeByte ((char) pixel.getGreen());
  1451. out.writeByte ((char) pixel.getBlue());
  1452. }
  1453. }
  1454. out.write (maskType, 4);
  1455. out.writeIntBigEndian (8 + w * h);
  1456. for (int y = 0; y < h; ++y)
  1457. {
  1458. for (int x = 0; x < w; ++x)
  1459. {
  1460. const Colour pixel (bitmap.getPixelColour (x, y));
  1461. out.writeByte ((char) pixel.getAlpha());
  1462. }
  1463. }
  1464. }
  1465. static void writeNewIconFormat (MemoryOutputStream& out, const Image& image, const char* type)
  1466. {
  1467. MemoryOutputStream pngData;
  1468. PNGImageFormat pngFormat;
  1469. pngFormat.writeImageToStream (image, pngData);
  1470. out.write (type, 4);
  1471. out.writeIntBigEndian (8 + (int) pngData.getDataSize());
  1472. out << pngData;
  1473. }
  1474. void writeIcnsFile (const OwnedArray<Drawable>& images, OutputStream& out) const
  1475. {
  1476. MemoryOutputStream data;
  1477. int smallest = 0x7fffffff;
  1478. Drawable* smallestImage = nullptr;
  1479. for (int i = 0; i < images.size(); ++i)
  1480. {
  1481. const Image image (fixMacIconImageSize (*images.getUnchecked(i)));
  1482. jassert (image.getWidth() == image.getHeight());
  1483. if (image.getWidth() < smallest)
  1484. {
  1485. smallest = image.getWidth();
  1486. smallestImage = images.getUnchecked(i);
  1487. }
  1488. switch (image.getWidth())
  1489. {
  1490. case 16: writeOldIconFormat (data, image, "is32", "s8mk"); break;
  1491. case 32: writeOldIconFormat (data, image, "il32", "l8mk"); break;
  1492. case 48: writeOldIconFormat (data, image, "ih32", "h8mk"); break;
  1493. case 128: writeOldIconFormat (data, image, "it32", "t8mk"); break;
  1494. case 256: writeNewIconFormat (data, image, "ic08"); break;
  1495. case 512: writeNewIconFormat (data, image, "ic09"); break;
  1496. case 1024: writeNewIconFormat (data, image, "ic10"); break;
  1497. default: break;
  1498. }
  1499. }
  1500. jassert (data.getDataSize() > 0); // no suitable sized images?
  1501. // If you only supply a 1024 image, the file doesn't work on 10.8, so we need
  1502. // to force a smaller one in there too..
  1503. if (smallest > 512 && smallestImage != nullptr)
  1504. writeNewIconFormat (data, rescaleImageForIcon (*smallestImage, 512), "ic09");
  1505. out.write ("icns", 4);
  1506. out.writeIntBigEndian ((int) data.getDataSize() + 8);
  1507. out << data;
  1508. }
  1509. void getIconImages (OwnedArray<Drawable>& images) const
  1510. {
  1511. ScopedPointer<Drawable> bigIcon (getBigIcon());
  1512. if (bigIcon != nullptr)
  1513. images.add (bigIcon.release());
  1514. ScopedPointer<Drawable> smallIcon (getSmallIcon());
  1515. if (smallIcon != nullptr)
  1516. images.add (smallIcon.release());
  1517. }
  1518. void createiOSIconFiles (File appIconSet) const
  1519. {
  1520. OwnedArray<Drawable> images;
  1521. getIconImages (images);
  1522. if (images.size() > 0)
  1523. {
  1524. for (auto& type : getiOSAppIconTypes())
  1525. {
  1526. auto image = rescaleImageForIcon (*images.getFirst(), type.size);
  1527. MemoryOutputStream pngData;
  1528. PNGImageFormat pngFormat;
  1529. pngFormat.writeImageToStream (image, pngData);
  1530. overwriteFileIfDifferentOrThrow (appIconSet.getChildFile (type.filename), pngData);
  1531. }
  1532. }
  1533. }
  1534. void createIconFile() const
  1535. {
  1536. OwnedArray<Drawable> images;
  1537. getIconImages (images);
  1538. if (images.size() > 0)
  1539. {
  1540. MemoryOutputStream mo;
  1541. writeIcnsFile (images, mo);
  1542. iconFile = getTargetFolder().getChildFile ("Icon.icns");
  1543. overwriteFileIfDifferentOrThrow (iconFile, mo);
  1544. }
  1545. }
  1546. void writeInfoPlistFiles() const
  1547. {
  1548. for (auto& target : targets)
  1549. target->writeInfoPlistFile();
  1550. }
  1551. // Delete .rsrc files in folder but don't follow sym-links
  1552. void deleteRsrcFiles (const File& folder) const
  1553. {
  1554. for (DirectoryIterator di (folder, false, "*", File::findFilesAndDirectories); di.next();)
  1555. {
  1556. const File& entry = di.getFile();
  1557. if (! entry.isSymbolicLink())
  1558. {
  1559. if (entry.existsAsFile() && entry.getFileExtension().toLowerCase() == ".rsrc")
  1560. entry.deleteFile();
  1561. else if (entry.isDirectory())
  1562. deleteRsrcFiles (entry);
  1563. }
  1564. }
  1565. }
  1566. static String getLinkerFlagForLib (String library)
  1567. {
  1568. if (library.substring (0, 3) == "lib")
  1569. library = library.substring (3);
  1570. return "-l" + library.replace (" ", "\\\\ ").upToLastOccurrenceOf (".", false, false);
  1571. }
  1572. String getSearchPathForStaticLibrary (const RelativePath& library) const
  1573. {
  1574. String searchPath (library.toUnixStyle().upToLastOccurrenceOf ("/", false, false));
  1575. if (! library.isAbsolute())
  1576. {
  1577. String srcRoot (rebaseFromProjectFolderToBuildTarget (RelativePath (".", RelativePath::projectFolder)).toUnixStyle());
  1578. if (srcRoot.endsWith ("/.")) srcRoot = srcRoot.dropLastCharacters (2);
  1579. if (! srcRoot.endsWithChar ('/')) srcRoot << '/';
  1580. searchPath = srcRoot + searchPath;
  1581. }
  1582. return sanitisePath (searchPath);
  1583. }
  1584. StringArray getProjectSettings (const XcodeBuildConfiguration& config) const
  1585. {
  1586. StringArray s;
  1587. s.add ("ALWAYS_SEARCH_USER_PATHS = NO");
  1588. s.add ("GCC_C_LANGUAGE_STANDARD = c11");
  1589. s.add ("GCC_WARN_ABOUT_RETURN_TYPE = YES");
  1590. s.add ("GCC_WARN_CHECK_SWITCH_STATEMENTS = YES");
  1591. s.add ("GCC_WARN_UNUSED_VARIABLE = YES");
  1592. s.add ("GCC_WARN_MISSING_PARENTHESES = YES");
  1593. s.add ("GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES");
  1594. s.add ("GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES");
  1595. s.add ("WARNING_CFLAGS = -Wreorder");
  1596. s.add ("GCC_MODEL_TUNING = G5");
  1597. if (projectType.isStaticLibrary())
  1598. {
  1599. s.add ("GCC_INLINES_ARE_PRIVATE_EXTERN = NO");
  1600. s.add ("GCC_SYMBOLS_PRIVATE_EXTERN = NO");
  1601. }
  1602. else
  1603. {
  1604. s.add ("GCC_INLINES_ARE_PRIVATE_EXTERN = YES");
  1605. }
  1606. if (config.isDebug())
  1607. {
  1608. s.add ("ENABLE_TESTABILITY = YES");
  1609. if (config.osxArchitecture.get() == osxArch_Default || config.osxArchitecture.get().isEmpty())
  1610. s.add ("ONLY_ACTIVE_ARCH = YES");
  1611. }
  1612. if (iOS)
  1613. {
  1614. s.add ("\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = " + config.codeSignIdentity.get().quoted());
  1615. s.add ("SDKROOT = iphoneos");
  1616. s.add ("TARGETED_DEVICE_FAMILY = \"1,2\"");
  1617. const String iosVersion (config.iosDeploymentTarget.get());
  1618. if (iosVersion.isNotEmpty() && iosVersion != osxVersionDefault)
  1619. s.add ("IPHONEOS_DEPLOYMENT_TARGET = " + iosVersion);
  1620. else
  1621. s.add ("IPHONEOS_DEPLOYMENT_TARGET = 9.3");
  1622. }
  1623. else
  1624. {
  1625. if (! config.codeSignIdentity.isUsingDefault() || getIosDevelopmentTeamIDString().isNotEmpty())
  1626. s.add ("\"CODE_SIGN_IDENTITY\" = " + config.codeSignIdentity.get().quoted());
  1627. }
  1628. s.add ("ZERO_LINK = NO");
  1629. if (xcodeCanUseDwarf)
  1630. s.add ("DEBUG_INFORMATION_FORMAT = \"dwarf\"");
  1631. s.add ("PRODUCT_NAME = \"" + replacePreprocessorTokens (config, config.getTargetBinaryNameString()) + "\"");
  1632. return s;
  1633. }
  1634. void addFrameworks() const
  1635. {
  1636. if (! projectType.isStaticLibrary())
  1637. {
  1638. if (iOS && isInAppPurchasesEnabled())
  1639. xcodeFrameworks.addIfNotAlreadyThere ("StoreKit");
  1640. xcodeFrameworks.addTokens (getExtraFrameworksString(), ",;", "\"'");
  1641. xcodeFrameworks.trim();
  1642. StringArray s (xcodeFrameworks);
  1643. for (auto& target : targets)
  1644. s.addArray (target->xcodeFrameworks);
  1645. if (project.getConfigFlag ("JUCE_QUICKTIME") == Project::configFlagDisabled)
  1646. s.removeString ("QuickTime");
  1647. s.trim();
  1648. s.removeDuplicates (true);
  1649. s.sort (true);
  1650. for (auto& framework : s)
  1651. {
  1652. String frameworkID = addFramework (framework);
  1653. // find all the targets that are referring to this object
  1654. for (auto& target : targets)
  1655. if (xcodeFrameworks.contains (framework) || target->xcodeFrameworks.contains (framework))
  1656. target->frameworkIDs.add (frameworkID);
  1657. }
  1658. }
  1659. }
  1660. void addCustomResourceFolders() const
  1661. {
  1662. StringArray folders;
  1663. folders.addTokens (getCustomResourceFoldersString(), ":", "");
  1664. folders.trim();
  1665. for (auto& crf : folders)
  1666. addCustomResourceFolder (crf);
  1667. }
  1668. void addXcassets() const
  1669. {
  1670. String customXcassetsPath = getCustomXcassetsFolderString();
  1671. if (customXcassetsPath.isEmpty())
  1672. createXcassetsFolderFromIcons();
  1673. else
  1674. addCustomResourceFolder (customXcassetsPath, "folder.assetcatalog");
  1675. }
  1676. void addCustomResourceFolder (String folderPathRelativeToProjectFolder, const String fileType = "folder") const
  1677. {
  1678. String folderPath = RelativePath (folderPathRelativeToProjectFolder, RelativePath::projectFolder)
  1679. .rebased (projectFolder, getTargetFolder(), RelativePath::buildTargetFolder)
  1680. .toUnixStyle();
  1681. const String fileRefID (createFileRefID (folderPath));
  1682. addFileOrFolderReference (folderPath, "<group>", fileType);
  1683. resourceIDs.add (addBuildFile (folderPath, fileRefID, false, false));
  1684. resourceFileRefs.add (createFileRefID (folderPath));
  1685. }
  1686. //==============================================================================
  1687. void writeProjectFile (OutputStream& output) const
  1688. {
  1689. output << "// !$*UTF8*$!\n{\n"
  1690. "\tarchiveVersion = 1;\n"
  1691. "\tclasses = {\n\t};\n"
  1692. "\tobjectVersion = 46;\n"
  1693. "\tobjects = {\n\n";
  1694. Array<ValueTree*> objects;
  1695. objects.addArray (pbxBuildFiles);
  1696. objects.addArray (pbxFileReferences);
  1697. objects.addArray (pbxGroups);
  1698. objects.addArray (targetConfigs);
  1699. objects.addArray (projectConfigs);
  1700. objects.addArray (misc);
  1701. for (auto* o : objects)
  1702. {
  1703. output << "\t\t" << o->getType().toString() << " = {";
  1704. for (int j = 0; j < o->getNumProperties(); ++j)
  1705. {
  1706. const Identifier propertyName (o->getPropertyName(j));
  1707. String val (o->getProperty (propertyName).toString());
  1708. if (val.isEmpty() || (val.containsAnyOf (" \t;<>()=,&+-_@~\r\n\\#%^`*")
  1709. && ! (val.trimStart().startsWithChar ('(')
  1710. || val.trimStart().startsWithChar ('{'))))
  1711. val = "\"" + val + "\"";
  1712. output << propertyName.toString() << " = " << val << "; ";
  1713. }
  1714. output << "};\n";
  1715. }
  1716. output << "\t};\n\trootObject = " << createID ("__root") << ";\n}\n";
  1717. }
  1718. String addBuildFile (const String& path, const String& fileRefID, bool addToSourceBuildPhase, bool inhibitWarnings, XCodeTarget* xcodeTarget = nullptr) const
  1719. {
  1720. String fileID (createID (path + "buildref"));
  1721. if (addToSourceBuildPhase)
  1722. {
  1723. if (xcodeTarget != nullptr) xcodeTarget->sourceIDs.add (fileID);
  1724. else sourceIDs.add (fileID);
  1725. }
  1726. ValueTree* v = new ValueTree (fileID);
  1727. v->setProperty ("isa", "PBXBuildFile", nullptr);
  1728. v->setProperty ("fileRef", fileRefID, nullptr);
  1729. if (inhibitWarnings)
  1730. v->setProperty ("settings", "{COMPILER_FLAGS = \"-w\"; }", nullptr);
  1731. pbxBuildFiles.add (v);
  1732. return fileID;
  1733. }
  1734. String addBuildFile (const RelativePath& path, bool addToSourceBuildPhase, bool inhibitWarnings, XCodeTarget* xcodeTarget = nullptr) const
  1735. {
  1736. return addBuildFile (path.toUnixStyle(), createFileRefID (path), addToSourceBuildPhase, inhibitWarnings, xcodeTarget);
  1737. }
  1738. String addFileReference (String pathString) const
  1739. {
  1740. String sourceTree ("SOURCE_ROOT");
  1741. RelativePath path (pathString, RelativePath::unknown);
  1742. if (pathString.startsWith ("${"))
  1743. {
  1744. sourceTree = pathString.substring (2).upToFirstOccurrenceOf ("}", false, false);
  1745. pathString = pathString.fromFirstOccurrenceOf ("}/", false, false);
  1746. }
  1747. else if (path.isAbsolute())
  1748. {
  1749. sourceTree = "<absolute>";
  1750. }
  1751. String fileType = getFileType (path);
  1752. return addFileOrFolderReference (pathString, sourceTree, fileType);
  1753. }
  1754. String addFileOrFolderReference (String pathString, String sourceTree, String fileType) const
  1755. {
  1756. const String fileRefID (createFileRefID (pathString));
  1757. ScopedPointer<ValueTree> v (new ValueTree (fileRefID));
  1758. v->setProperty ("isa", "PBXFileReference", nullptr);
  1759. v->setProperty ("lastKnownFileType", fileType, nullptr);
  1760. v->setProperty (Ids::name, pathString.fromLastOccurrenceOf ("/", false, false), nullptr);
  1761. v->setProperty ("path", sanitisePath (pathString), nullptr);
  1762. v->setProperty ("sourceTree", sourceTree, nullptr);
  1763. const int existing = pbxFileReferences.indexOfSorted (*this, v);
  1764. if (existing >= 0)
  1765. {
  1766. // If this fails, there's either a string hash collision, or the same file is being added twice (incorrectly)
  1767. jassert (pbxFileReferences.getUnchecked (existing)->isEquivalentTo (*v));
  1768. }
  1769. else
  1770. {
  1771. pbxFileReferences.addSorted (*this, v.release());
  1772. }
  1773. return fileRefID;
  1774. }
  1775. public:
  1776. static int compareElements (const ValueTree* first, const ValueTree* second)
  1777. {
  1778. return first->getType().getCharPointer().compare (second->getType().getCharPointer());
  1779. }
  1780. private:
  1781. static String getFileType (const RelativePath& file)
  1782. {
  1783. if (file.hasFileExtension (cppFileExtensions)) return "sourcecode.cpp.cpp";
  1784. if (file.hasFileExtension (".mm")) return "sourcecode.cpp.objcpp";
  1785. if (file.hasFileExtension (".m")) return "sourcecode.c.objc";
  1786. if (file.hasFileExtension (".c")) return "sourcecode.c.c";
  1787. if (file.hasFileExtension (headerFileExtensions)) return "sourcecode.c.h";
  1788. if (file.hasFileExtension (asmFileExtensions)) return "sourcecode.c.asm";
  1789. if (file.hasFileExtension (".framework")) return "wrapper.framework";
  1790. if (file.hasFileExtension (".jpeg;.jpg")) return "image.jpeg";
  1791. if (file.hasFileExtension ("png;gif")) return "image" + file.getFileExtension();
  1792. if (file.hasFileExtension ("html;htm")) return "text.html";
  1793. if (file.hasFileExtension ("xml;zip;wav")) return "file" + file.getFileExtension();
  1794. if (file.hasFileExtension ("txt;rtf")) return "text" + file.getFileExtension();
  1795. if (file.hasFileExtension ("plist")) return "text.plist.xml";
  1796. if (file.hasFileExtension ("entitlements")) return "text.plist.xml";
  1797. if (file.hasFileExtension ("app")) return "wrapper.application";
  1798. if (file.hasFileExtension ("component;vst;plugin")) return "wrapper.cfbundle";
  1799. if (file.hasFileExtension ("xcodeproj")) return "wrapper.pb-project";
  1800. if (file.hasFileExtension ("a")) return "archive.ar";
  1801. if (file.hasFileExtension ("xcassets")) return "folder.assetcatalog";
  1802. return "file" + file.getFileExtension();
  1803. }
  1804. String addFile (const RelativePath& path, bool shouldBeCompiled, bool shouldBeAddedToBinaryResources,
  1805. bool shouldBeAddedToXcodeResources, bool inhibitWarnings, XCodeTarget* xcodeTarget) const
  1806. {
  1807. const String pathAsString (path.toUnixStyle());
  1808. const String refID (addFileReference (path.toUnixStyle()));
  1809. if (shouldBeCompiled)
  1810. {
  1811. addBuildFile (pathAsString, refID, true, inhibitWarnings, xcodeTarget);
  1812. }
  1813. else if (! shouldBeAddedToBinaryResources || shouldBeAddedToXcodeResources)
  1814. {
  1815. const String fileType (getFileType (path));
  1816. if (shouldBeAddedToXcodeResources)
  1817. {
  1818. resourceIDs.add (addBuildFile (pathAsString, refID, false, false));
  1819. resourceFileRefs.add (refID);
  1820. }
  1821. }
  1822. return refID;
  1823. }
  1824. String addRezFile (const Project::Item& projectItem, const RelativePath& path) const
  1825. {
  1826. const String pathAsString (path.toUnixStyle());
  1827. const String refID (addFileReference (path.toUnixStyle()));
  1828. if (projectItem.isModuleCode())
  1829. {
  1830. if (XCodeTarget* xcodeTarget = getTargetOfType (getProject().getTargetTypeFromFilePath (projectItem.getFile(), false)))
  1831. {
  1832. String rezFileID = addBuildFile (pathAsString, refID, false, false, xcodeTarget);
  1833. xcodeTarget->rezFileIDs.add (rezFileID);
  1834. return refID;
  1835. }
  1836. }
  1837. return {};
  1838. }
  1839. String getEntitlementsFileName() const
  1840. {
  1841. return project.getProjectFilenameRoot() + String (".entitlements");
  1842. }
  1843. StringArray getEntitlements() const
  1844. {
  1845. StringArray keys;
  1846. if (project.getProjectType().isAudioPlugin())
  1847. {
  1848. if (isiOS())
  1849. {
  1850. if (project.shouldEnableIAA())
  1851. keys.add ("inter-app-audio");
  1852. }
  1853. else
  1854. {
  1855. keys.add ("com.apple.security.app-sandbox");
  1856. }
  1857. }
  1858. return keys;
  1859. }
  1860. String addEntitlementsFile (StringArray keys) const
  1861. {
  1862. String content =
  1863. "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
  1864. "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
  1865. "<plist version=\"1.0\">\n"
  1866. "<dict>\n";
  1867. for (auto& key : keys)
  1868. {
  1869. content += "\t<key>" + key + "</key>\n"
  1870. "\t<true/>\n";
  1871. }
  1872. content += "</dict>\n"
  1873. "</plist>\n";
  1874. File entitlementsFile = getTargetFolder().getChildFile (getEntitlementsFileName());
  1875. overwriteFileIfDifferentOrThrow (entitlementsFile, content);
  1876. RelativePath plistPath (entitlementsFile, getTargetFolder(), RelativePath::buildTargetFolder);
  1877. return addFile (plistPath, false, false, false, false, nullptr);
  1878. }
  1879. String addProjectItem (const Project::Item& projectItem) const
  1880. {
  1881. if (modulesGroup != nullptr && projectItem.getParent() == *modulesGroup)
  1882. return addFileReference (rebaseFromProjectFolderToBuildTarget (getModuleFolderRelativeToProject (projectItem.getName())).toUnixStyle());
  1883. if (projectItem.isGroup())
  1884. {
  1885. StringArray childIDs;
  1886. for (int i = 0; i < projectItem.getNumChildren(); ++i)
  1887. {
  1888. const String childID (addProjectItem (projectItem.getChild(i)));
  1889. if (childID.isNotEmpty())
  1890. childIDs.add (childID);
  1891. }
  1892. return addGroup (projectItem, childIDs);
  1893. }
  1894. if (projectItem.shouldBeAddedToTargetProject())
  1895. {
  1896. const String itemPath (projectItem.getFilePath());
  1897. RelativePath path;
  1898. if (itemPath.startsWith ("${"))
  1899. path = RelativePath (itemPath, RelativePath::unknown);
  1900. else
  1901. path = RelativePath (projectItem.getFile(), getTargetFolder(), RelativePath::buildTargetFolder);
  1902. if (path.hasFileExtension (".r"))
  1903. return addRezFile (projectItem, path);
  1904. XCodeTarget* xcodeTarget = nullptr;
  1905. if (projectItem.isModuleCode() && projectItem.shouldBeCompiled())
  1906. xcodeTarget = getTargetOfType (project.getTargetTypeFromFilePath (projectItem.getFile(), false));
  1907. return addFile (path, projectItem.shouldBeCompiled(),
  1908. projectItem.shouldBeAddedToBinaryResources(),
  1909. projectItem.shouldBeAddedToXcodeResources(),
  1910. projectItem.shouldInhibitWarnings(),
  1911. xcodeTarget);
  1912. }
  1913. return {};
  1914. }
  1915. String addFramework (const String& frameworkName) const
  1916. {
  1917. String path (frameworkName);
  1918. if (! File::isAbsolutePath (path))
  1919. path = "System/Library/Frameworks/" + path;
  1920. if (! path.endsWithIgnoreCase (".framework"))
  1921. path << ".framework";
  1922. const String fileRefID (createFileRefID (path));
  1923. addFileReference ((File::isAbsolutePath (frameworkName) ? "" : "${SDKROOT}/") + path);
  1924. frameworkFileIDs.add (fileRefID);
  1925. return addBuildFile (path, fileRefID, false, false);
  1926. }
  1927. void addGroup (const String& groupID, const String& groupName, const StringArray& childIDs) const
  1928. {
  1929. ValueTree* v = new ValueTree (groupID);
  1930. v->setProperty ("isa", "PBXGroup", nullptr);
  1931. v->setProperty ("children", indentParenthesisedList (childIDs), nullptr);
  1932. v->setProperty (Ids::name, groupName, nullptr);
  1933. v->setProperty ("sourceTree", "<group>", nullptr);
  1934. pbxGroups.add (v);
  1935. }
  1936. String addGroup (const Project::Item& item, StringArray& childIDs) const
  1937. {
  1938. const String groupName (item.getName());
  1939. const String groupID (getIDForGroup (item));
  1940. addGroup (groupID, groupName, childIDs);
  1941. return groupID;
  1942. }
  1943. void addProjectConfig (const String& configName, const StringArray& buildSettings) const
  1944. {
  1945. ValueTree* v = new ValueTree (createID ("projectconfigid_" + configName));
  1946. v->setProperty ("isa", "XCBuildConfiguration", nullptr);
  1947. v->setProperty ("buildSettings", indentBracedList (buildSettings), nullptr);
  1948. v->setProperty (Ids::name, configName, nullptr);
  1949. projectConfigs.add (v);
  1950. }
  1951. void addConfigList (XCodeTarget& target, const OwnedArray <ValueTree>& configsToUse, const String& listID) const
  1952. {
  1953. ValueTree* v = new ValueTree (listID);
  1954. v->setProperty ("isa", "XCConfigurationList", nullptr);
  1955. v->setProperty ("buildConfigurations", indentParenthesisedList (target.configIDs), nullptr);
  1956. v->setProperty ("defaultConfigurationIsVisible", (int) 0, nullptr);
  1957. if (auto* first = configsToUse.getFirst())
  1958. v->setProperty ("defaultConfigurationName", first->getProperty (Ids::name), nullptr);
  1959. misc.add (v);
  1960. }
  1961. void addProjectConfigList (const OwnedArray <ValueTree>& configsToUse, const String& listID) const
  1962. {
  1963. StringArray configIDs;
  1964. for (auto* c : configsToUse)
  1965. configIDs.add (c->getType().toString());
  1966. ValueTree* v = new ValueTree (listID);
  1967. v->setProperty ("isa", "XCConfigurationList", nullptr);
  1968. v->setProperty ("buildConfigurations", indentParenthesisedList (configIDs), nullptr);
  1969. v->setProperty ("defaultConfigurationIsVisible", (int) 0, nullptr);
  1970. if (auto* first = configsToUse.getFirst())
  1971. v->setProperty ("defaultConfigurationName", first->getProperty (Ids::name), nullptr);
  1972. misc.add (v);
  1973. }
  1974. void addProjectObject() const
  1975. {
  1976. ValueTree* const v = new ValueTree (createID ("__root"));
  1977. v->setProperty ("isa", "PBXProject", nullptr);
  1978. v->setProperty ("buildConfigurationList", createID ("__projList"), nullptr);
  1979. v->setProperty ("attributes", getProjectObjectAttributes(), nullptr);
  1980. v->setProperty ("compatibilityVersion", "Xcode 3.2", nullptr);
  1981. v->setProperty ("hasScannedForEncodings", (int) 0, nullptr);
  1982. v->setProperty ("mainGroup", createID ("__mainsourcegroup"), nullptr);
  1983. v->setProperty ("projectDirPath", "\"\"", nullptr);
  1984. v->setProperty ("projectRoot", "\"\"", nullptr);
  1985. String targetString = "(" + targetIDs.joinIntoString (", ") + ")";
  1986. v->setProperty ("targets", targetString, nullptr);
  1987. misc.add (v);
  1988. }
  1989. //==============================================================================
  1990. void removeMismatchedXcuserdata() const
  1991. {
  1992. if (settings ["keepCustomXcodeSchemes"])
  1993. return;
  1994. File xcuserdata = getProjectBundle().getChildFile ("xcuserdata");
  1995. if (! xcuserdata.exists())
  1996. return;
  1997. if (! xcuserdataMatchesTargets (xcuserdata))
  1998. {
  1999. xcuserdata.deleteRecursively();
  2000. getProjectBundle().getChildFile ("project.xcworkspace").deleteRecursively();
  2001. }
  2002. }
  2003. bool xcuserdataMatchesTargets (const File& xcuserdata) const
  2004. {
  2005. Array<File> xcschemeManagementPlists;
  2006. xcuserdata.findChildFiles (xcschemeManagementPlists, File::findFiles, true, "xcschememanagement.plist");
  2007. for (auto& plist : xcschemeManagementPlists)
  2008. if (! xcschemeManagementPlistMatchesTargets (plist))
  2009. return false;
  2010. return true;
  2011. }
  2012. static StringArray parseNamesOfTargetsFromPlist (const XmlElement& dictXML)
  2013. {
  2014. forEachXmlChildElementWithTagName (dictXML, schemesKey, "key")
  2015. {
  2016. if (schemesKey->getAllSubText().trim().equalsIgnoreCase ("SchemeUserState"))
  2017. {
  2018. if (auto* dict = schemesKey->getNextElement())
  2019. {
  2020. if (dict->hasTagName ("dict"))
  2021. {
  2022. StringArray names;
  2023. forEachXmlChildElementWithTagName (*dict, key, "key")
  2024. names.add (key->getAllSubText().upToLastOccurrenceOf (".xcscheme", false, false).trim());
  2025. names.sort (false);
  2026. return names;
  2027. }
  2028. }
  2029. }
  2030. }
  2031. return {};
  2032. }
  2033. StringArray getNamesOfTargets() const
  2034. {
  2035. StringArray names;
  2036. for (auto& target : targets)
  2037. names.add (target->getXCodeSchemeName());
  2038. names.sort (false);
  2039. return names;
  2040. }
  2041. bool xcschemeManagementPlistMatchesTargets (const File& plist) const
  2042. {
  2043. ScopedPointer<XmlElement> xml (XmlDocument::parse (plist));
  2044. if (xml != nullptr)
  2045. if (auto* dict = xml->getChildByName ("dict"))
  2046. return parseNamesOfTargetsFromPlist (*dict) == getNamesOfTargets();
  2047. return false;
  2048. }
  2049. //==============================================================================
  2050. struct AppIconType
  2051. {
  2052. const char* idiom;
  2053. const char* sizeString;
  2054. const char* filename;
  2055. const char* scale;
  2056. int size;
  2057. };
  2058. static Array<AppIconType> getiOSAppIconTypes()
  2059. {
  2060. AppIconType types[] =
  2061. {
  2062. { "iphone", "29x29", "Icon-29.png", "1x", 29 },
  2063. { "iphone", "29x29", "Icon-29@2x.png", "2x", 58 },
  2064. { "iphone", "29x29", "Icon-29@3x.png", "3x", 87 },
  2065. { "iphone", "40x40", "Icon-Spotlight-40@2x.png", "2x", 80 },
  2066. { "iphone", "40x40", "Icon-Spotlight-40@3x.png", "3x", 120 },
  2067. { "iphone", "57x57", "Icon.png", "1x", 57 },
  2068. { "iphone", "57x57", "Icon@2x.png", "2x", 114 },
  2069. { "iphone", "60x60", "Icon-60@2x.png", "2x", 120 },
  2070. { "iphone", "60x60", "Icon-@3x.png", "3x", 180 },
  2071. { "ipad", "29x29", "Icon-Small-1.png", "1x", 29 },
  2072. { "ipad", "29x29", "Icon-Small@2x-1.png", "2x", 58 },
  2073. { "ipad", "40x40", "Icon-Spotlight-40.png", "1x", 40 },
  2074. { "ipad", "40x40", "Icon-Spotlight-40@2x-1.png", "2x", 80 },
  2075. { "ipad", "50x50", "Icon-Small-50.png", "1x", 50 },
  2076. { "ipad", "50x50", "Icon-Small-50@2x.png", "2x", 100 },
  2077. { "ipad", "72x72", "Icon-72.png", "1x", 72 },
  2078. { "ipad", "72x72", "Icon-72@2x.png", "2x", 144 },
  2079. { "ipad", "76x76", "Icon-76.png", "1x", 76 },
  2080. { "ipad", "76x76", "Icon-76@2x.png", "2x", 152 },
  2081. { "ipad", "83.5x83.5", "Icon-83.5@2x.png", "2x", 167 }
  2082. };
  2083. return Array<AppIconType> (types, numElementsInArray (types));
  2084. }
  2085. static String getiOSAppIconContents()
  2086. {
  2087. var images;
  2088. for (auto& type : getiOSAppIconTypes())
  2089. {
  2090. DynamicObject::Ptr d = new DynamicObject();
  2091. d->setProperty ("idiom", type.idiom);
  2092. d->setProperty ("size", type.sizeString);
  2093. d->setProperty ("filename", type.filename);
  2094. d->setProperty ("scale", type.scale);
  2095. images.append (var (d.get()));
  2096. }
  2097. return getiOSAssetContents (images);
  2098. }
  2099. String getProjectObjectAttributes() const
  2100. {
  2101. String attributes;
  2102. attributes << "{ LastUpgradeCheck = 0830; ";
  2103. if (projectType.isGUIApplication() || projectType.isAudioPlugin())
  2104. {
  2105. attributes << "TargetAttributes = { ";
  2106. for (auto& target : targets)
  2107. attributes << target->getTargetAttributes();
  2108. attributes << " }; ";
  2109. }
  2110. attributes << "}";
  2111. return attributes;
  2112. }
  2113. //==============================================================================
  2114. struct ImageType
  2115. {
  2116. const char* orientation;
  2117. const char* idiom;
  2118. const char* subtype;
  2119. const char* extent;
  2120. const char* scale;
  2121. const char* filename;
  2122. int width;
  2123. int height;
  2124. };
  2125. static Array<ImageType> getiOSLaunchImageTypes()
  2126. {
  2127. ImageType types[] =
  2128. {
  2129. { "portrait", "iphone", nullptr, "full-screen", "2x", "LaunchImage-iphone-2x.png", 640, 960 },
  2130. { "portrait", "iphone", "retina4", "full-screen", "2x", "LaunchImage-iphone-retina4.png", 640, 1136 },
  2131. { "portrait", "ipad", nullptr, "full-screen", "1x", "LaunchImage-ipad-portrait-1x.png", 768, 1024 },
  2132. { "landscape","ipad", nullptr, "full-screen", "1x", "LaunchImage-ipad-landscape-1x.png", 1024, 768 },
  2133. { "portrait", "ipad", nullptr, "full-screen", "2x", "LaunchImage-ipad-portrait-2x.png", 1536, 2048 },
  2134. { "landscape","ipad", nullptr, "full-screen", "2x", "LaunchImage-ipad-landscape-2x.png", 2048, 1536 }
  2135. };
  2136. return Array<ImageType> (types, numElementsInArray (types));
  2137. }
  2138. static String getiOSLaunchImageContents()
  2139. {
  2140. var images;
  2141. for (auto& type : getiOSLaunchImageTypes())
  2142. {
  2143. DynamicObject::Ptr d = new DynamicObject();
  2144. d->setProperty ("orientation", type.orientation);
  2145. d->setProperty ("idiom", type.idiom);
  2146. d->setProperty ("extent", type.extent);
  2147. d->setProperty ("minimum-system-version", "7.0");
  2148. d->setProperty ("scale", type.scale);
  2149. d->setProperty ("filename", type.filename);
  2150. if (type.subtype != nullptr)
  2151. d->setProperty ("subtype", type.subtype);
  2152. images.append (var (d.get()));
  2153. }
  2154. return getiOSAssetContents (images);
  2155. }
  2156. static void createiOSLaunchImageFiles (const File& launchImageSet)
  2157. {
  2158. for (auto& type : getiOSLaunchImageTypes())
  2159. {
  2160. Image image (Image::ARGB, type.width, type.height, true); // (empty black image)
  2161. image.clear (image.getBounds(), Colours::black);
  2162. MemoryOutputStream pngData;
  2163. PNGImageFormat pngFormat;
  2164. pngFormat.writeImageToStream (image, pngData);
  2165. overwriteFileIfDifferentOrThrow (launchImageSet.getChildFile (type.filename), pngData);
  2166. }
  2167. }
  2168. //==============================================================================
  2169. static String getiOSAssetContents (var images)
  2170. {
  2171. DynamicObject::Ptr v (new DynamicObject());
  2172. var info (new DynamicObject());
  2173. info.getDynamicObject()->setProperty ("version", 1);
  2174. info.getDynamicObject()->setProperty ("author", "xcode");
  2175. v->setProperty ("images", images);
  2176. v->setProperty ("info", info);
  2177. return JSON::toString (var (v.get()));
  2178. }
  2179. void createXcassetsFolderFromIcons() const
  2180. {
  2181. const File assets (getTargetFolder().getChildFile (project.getProjectFilenameRoot())
  2182. .getChildFile ("Images.xcassets"));
  2183. const File iconSet (assets.getChildFile ("AppIcon.appiconset"));
  2184. const File launchImage (assets.getChildFile ("LaunchImage.launchimage"));
  2185. overwriteFileIfDifferentOrThrow (iconSet.getChildFile ("Contents.json"), getiOSAppIconContents());
  2186. createiOSIconFiles (iconSet);
  2187. overwriteFileIfDifferentOrThrow (launchImage.getChildFile ("Contents.json"), getiOSLaunchImageContents());
  2188. createiOSLaunchImageFiles (launchImage);
  2189. RelativePath assetsPath (assets, getTargetFolder(), RelativePath::buildTargetFolder);
  2190. addFileReference (assetsPath.toUnixStyle());
  2191. resourceIDs.add (addBuildFile (assetsPath, false, false));
  2192. resourceFileRefs.add (createFileRefID (assetsPath));
  2193. }
  2194. //==============================================================================
  2195. static String indentBracedList (const StringArray& list) { return "{" + indentList (list, ";", 0, true) + " }"; }
  2196. static String indentParenthesisedList (const StringArray& list) { return "(" + indentList (list, ",", 1, false) + " )"; }
  2197. static String indentList (const StringArray& list, const String& separator, int extraTabs, bool shouldSort)
  2198. {
  2199. if (list.size() == 0)
  2200. return " ";
  2201. const String tabs ("\n" + String::repeatedString ("\t", extraTabs + 4));
  2202. if (shouldSort)
  2203. {
  2204. StringArray sorted (list);
  2205. sorted.sort (true);
  2206. return tabs + sorted.joinIntoString (separator + tabs) + separator;
  2207. }
  2208. return tabs + list.joinIntoString (separator + tabs) + separator;
  2209. }
  2210. String createID (String rootString) const
  2211. {
  2212. if (rootString.startsWith ("${"))
  2213. rootString = rootString.fromFirstOccurrenceOf ("}/", false, false);
  2214. rootString += project.getProjectUID();
  2215. return MD5 (rootString.toUTF8()).toHexString().substring (0, 24).toUpperCase();
  2216. }
  2217. String createFileRefID (const RelativePath& path) const { return createFileRefID (path.toUnixStyle()); }
  2218. String createFileRefID (const String& path) const { return createID ("__fileref_" + path); }
  2219. String getIDForGroup (const Project::Item& item) const { return createID (item.getID()); }
  2220. bool shouldFileBeCompiledByDefault (const RelativePath& file) const override
  2221. {
  2222. return file.hasFileExtension (sourceFileExtensions);
  2223. }
  2224. static String getOSXVersionName (int version)
  2225. {
  2226. jassert (version >= 4);
  2227. return "10." + String (version);
  2228. }
  2229. static String getSDKName (int version)
  2230. {
  2231. return getOSXVersionName (version) + " SDK";
  2232. }
  2233. void initialiseDependencyPathValues()
  2234. {
  2235. vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder), Ids::vst3Path, TargetOS::osx)));
  2236. aaxPath. referTo (Value (new DependencyPathValueSource (getSetting (Ids::aaxFolder), Ids::aaxPath, TargetOS::osx)));
  2237. rtasPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::rtasFolder), Ids::rtasPath, TargetOS::osx)));
  2238. }
  2239. JUCE_DECLARE_NON_COPYABLE (XCodeProjectExporter)
  2240. };