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.

2760 lines
121KB

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