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.

3272 lines
148KB

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