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.

3728 lines
178KB

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