-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
jucer_ProjectExport_Xcode.h
3100 lines (2480 loc) · 140 KB
/
jucer_ProjectExport_Xcode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 5 End-User License
Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
27th April 2017).
End User License Agreement: www.juce.com/juce-5-licence
Privacy Policy: www.juce.com/juce-5-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
#pragma once
//==============================================================================
namespace
{
const char* const osxVersionDefault = "10.11";
const char* const iosVersionDefault = "9.3";
const int oldestSDKVersion = 7;
const int currentSDKVersion = 13;
const int minimumAUv3SDKVersion = 11;
const char* const osxArch_Default = "default";
const char* const osxArch_Native = "Native";
const char* const osxArch_32BitUniversal = "32BitUniversal";
const char* const osxArch_64BitUniversal = "64BitUniversal";
const char* const osxArch_64Bit = "64BitIntel";
}
//==============================================================================
class XcodeProjectExporter : public ProjectExporter
{
public:
//==============================================================================
static const char* getNameMac() { return "Xcode (MacOSX)"; }
static const char* getNameiOS() { return "Xcode (iOS)"; }
static const char* getValueTreeTypeName (bool iOS) { return iOS ? "XCODE_IPHONE" : "XCODE_MAC"; }
//==============================================================================
XcodeProjectExporter (Project& p, const ValueTree& t, const bool isIOS)
: ProjectExporter (p, t),
xcodeCanUseDwarf (true),
iOS (isIOS),
customPListValue (settings, Ids::customPList, getUndoManager()),
pListPrefixHeaderValue (settings, Ids::pListPrefixHeader, getUndoManager()),
pListPreprocessValue (settings, Ids::pListPreprocess, getUndoManager()),
extraFrameworksValue (settings, Ids::extraFrameworks, getUndoManager()),
postbuildCommandValue (settings, Ids::postbuildCommand, getUndoManager()),
prebuildCommandValue (settings, Ids::prebuildCommand, getUndoManager()),
iosAppExtensionDuplicateResourcesFolderValue (settings, Ids::iosAppExtensionDuplicateResourcesFolder, getUndoManager()),
iosDeviceFamilyValue (settings, Ids::iosDeviceFamily, getUndoManager(), "1,2"),
iPhoneScreenOrientationValue (settings, Ids::iPhoneScreenOrientation, getUndoManager(), "portraitlandscape"),
iPadScreenOrientationValue (settings, Ids::iPadScreenOrientation, getUndoManager(), "portraitlandscape"),
customXcodeResourceFoldersValue (settings, Ids::customXcodeResourceFolders, getUndoManager()),
customXcassetsFolderValue (settings, Ids::customXcassetsFolder, getUndoManager()),
microphonePermissionNeededValue (settings, Ids::microphonePermissionNeeded, getUndoManager()),
microphonePermissionsTextValue (settings, Ids::microphonePermissionsText, getUndoManager(), "This is an audio app which requires audio input. If you do not have a USB audio interface connected it will use the microphone."),
uiFileSharingEnabledValue (settings, Ids::UIFileSharingEnabled, getUndoManager()),
uiSupportsDocumentBrowserValue (settings, Ids::UISupportsDocumentBrowser, getUndoManager()),
uiStatusBarHiddenValue (settings, Ids::UIStatusBarHidden, getUndoManager()),
documentExtensionsValue (settings, Ids::documentExtensions, getUndoManager()),
iosInAppPurchasesValue (settings, Ids::iosInAppPurchases, getUndoManager()),
iosBackgroundAudioValue (settings, Ids::iosBackgroundAudio, getUndoManager()),
iosBackgroundBleValue (settings, Ids::iosBackgroundBle, getUndoManager()),
iosPushNotificationsValue (settings, Ids::iosPushNotifications, getUndoManager()),
iosAppGroupsValue (settings, Ids::iosAppGroups, getUndoManager()),
iCloudPermissionsValue (settings, Ids::iCloudPermissions, getUndoManager()),
iosDevelopmentTeamIDValue (settings, Ids::iosDevelopmentTeamID, getUndoManager()),
iosAppGroupsIDValue (settings, Ids::iosAppGroupsId, getUndoManager()),
keepCustomXcodeSchemesValue (settings, Ids::keepCustomXcodeSchemes, getUndoManager()),
useHeaderMapValue (settings, Ids::useHeaderMap, getUndoManager())
{
name = iOS ? getNameiOS() : getNameMac();
targetLocationValue.setDefault (getDefaultBuildsRootFolder() + getTargetFolderForExporter (getValueTreeTypeName (isIOS)));
}
static XcodeProjectExporter* createForSettings (Project& project, const ValueTree& settings)
{
if (settings.hasType (getValueTreeTypeName (false))) return new XcodeProjectExporter (project, settings, false);
if (settings.hasType (getValueTreeTypeName (true))) return new XcodeProjectExporter (project, settings, true);
return nullptr;
}
//==============================================================================
String getPListToMergeString() const { return customPListValue.get(); }
String getPListPrefixHeaderString() const { return pListPrefixHeaderValue.get(); }
bool isPListPreprocessEnabled() const { return pListPreprocessValue.get(); }
String getExtraFrameworksString() const { return extraFrameworksValue.get(); }
String getPostBuildScript() const { return postbuildCommandValue.get(); }
String getPreBuildScript() const { return prebuildCommandValue.get(); }
bool shouldDuplicateResourcesFolderForAppExtension() const { return iosAppExtensionDuplicateResourcesFolderValue.get(); }
String getDeviceFamilyString() const { return iosDeviceFamilyValue.get(); }
String getiPhoneScreenOrientationString() const { return iPhoneScreenOrientationValue.get(); }
String getiPadScreenOrientationString() const { return iPadScreenOrientationValue.get(); }
String getCustomResourceFoldersString() const { return customXcodeResourceFoldersValue.get().toString().replaceCharacters ("\r\n", "::"); }
String getCustomXcassetsFolderString() const { return customXcassetsFolderValue.get(); }
bool isMicrophonePermissionEnabled() const { return microphonePermissionNeededValue.get(); }
String getMicrophonePermissionsTextString() const { return microphonePermissionsTextValue.get(); }
bool isInAppPurchasesEnabled() const { return iosInAppPurchasesValue.get(); }
bool isBackgroundAudioEnabled() const { return iosBackgroundAudioValue.get(); }
bool isBackgroundBleEnabled() const { return iosBackgroundBleValue.get(); }
bool isPushNotificationsEnabled() const { return iosPushNotificationsValue.get(); }
bool isAppGroupsEnabled() const { return iosAppGroupsValue.get(); }
bool isiCloudPermissionsEnabled() const { return iCloudPermissionsValue.get(); }
bool isFileSharingEnabled() const { return uiFileSharingEnabledValue.get(); }
bool isDocumentBrowserEnabled() const { return uiSupportsDocumentBrowserValue.get(); }
bool isStatusBarHidden() const { return uiStatusBarHiddenValue.get(); }
String getIosDevelopmentTeamIDString() const { return iosDevelopmentTeamIDValue.get(); }
String getAppGroupIdString() const { return iosAppGroupsIDValue.get(); }
//==============================================================================
bool usesMMFiles() const override { return true; }
bool canCopeWithDuplicateFiles() override { return true; }
bool supportsUserDefinedConfigurations() const override { return true; }
bool isXcode() const override { return true; }
bool isVisualStudio() const override { return false; }
bool isCodeBlocks() const override { return false; }
bool isMakefile() const override { return false; }
bool isAndroidStudio() const override { return false; }
bool isCLion() const override { return false; }
bool isAndroid() const override { return false; }
bool isWindows() const override { return false; }
bool isLinux() const override { return false; }
bool isOSX() const override { return ! iOS; }
bool isiOS() const override { return iOS; }
bool supportsTargetType (ProjectType::Target::Type type) const override
{
switch (type)
{
case ProjectType::Target::AudioUnitv3PlugIn:
case ProjectType::Target::StandalonePlugIn:
case ProjectType::Target::GUIApp:
case ProjectType::Target::StaticLibrary:
case ProjectType::Target::SharedCodeTarget:
case ProjectType::Target::AggregateTarget:
return true;
case ProjectType::Target::ConsoleApp:
case ProjectType::Target::VSTPlugIn:
case ProjectType::Target::VST3PlugIn:
case ProjectType::Target::AAXPlugIn:
case ProjectType::Target::RTASPlugIn:
case ProjectType::Target::AudioUnitPlugIn:
case ProjectType::Target::DynamicLibrary:
return ! iOS;
default:
break;
}
return false;
}
void createExporterProperties (PropertyListBuilder& props) override
{
if (iOS)
{
props.add (new TextPropertyComponent (customXcassetsFolderValue, "Custom Xcassets Folder", 128, false),
"If this field is not empty, your Xcode project will use the custom xcassets folder specified here "
"for the app icons and launchimages, and will ignore the Icon files specified above.");
}
props.add (new TextPropertyComponent (customXcodeResourceFoldersValue, "Custom Xcode Resource Folders", 8192, true),
"You can specify a list of custom resource folders here (separated by newlines or whitespace). "
"References to these folders will then be added to the Xcode resources. "
"This way you can specify them for OS X and iOS separately, and modify the content of the resource folders "
"without re-saving the Projucer project.");
if (iOS)
{
if (getProject().getProjectType().isAudioPlugin())
props.add (new ChoicePropertyComponent (iosAppExtensionDuplicateResourcesFolderValue,
"Don't Add Resources Folder to App Extension"),
"Enable this to prevent the Projucer from creating a resources folder for AUv3 app extensions.");
props.add (new ChoicePropertyComponent (iosDeviceFamilyValue, "Device Family",
{ "iPhone", "iPad", "Universal" },
{ "1", "2", "1,2" }),
"The device family to target.");
{
StringArray orientationStrings { "Portrait and Landscape", "Portrait", "Landscape" };
Array<var> orientationValues { "portraitlandscape", "portrait", "landscape"};
props.add (new ChoicePropertyComponent (iPhoneScreenOrientationValue, "iPhone Screen Orientation",
orientationStrings, orientationValues),
"The screen orientations that this app should support on iPhones.");
props.add (new ChoicePropertyComponent (iPadScreenOrientationValue, "iPad Screen Orientation",
orientationStrings, orientationValues),
"The screen orientations that this app should support on iPads.");
}
props.add (new ChoicePropertyComponent (uiFileSharingEnabledValue, "File Sharing Enabled"),
"Enable this to expose your app's files to iTunes.");
props.add (new ChoicePropertyComponent (uiSupportsDocumentBrowserValue, "Support Document Browser"),
"Enable this to allow the user to access your app documents from a native file chooser.");
props.add (new ChoicePropertyComponent (uiStatusBarHiddenValue, "Status Bar Hidden"),
"Enable this to disable the status bar in your app.");
props.add (new ChoicePropertyComponent (microphonePermissionNeededValue, "Microphone Access"),
"Enable this to allow your app to use the microphone. "
"The user of your app will be prompted to grant microphone access permissions.");
props.add (new TextPropertyComponentWithEnablement (microphonePermissionsTextValue, microphonePermissionNeededValue,
"Microphone Access Text", 1024, false),
"A short description of why your app requires microphone access.");
}
else if (projectType.isGUIApplication())
{
props.add (new TextPropertyComponent (documentExtensionsValue, "Document File Extensions", 128, false),
"A comma-separated list of file extensions for documents that your app can open. "
"Using a leading '.' is optional, and the extensions are not case-sensitive.");
}
props.add (new ChoicePropertyComponent (iosInAppPurchasesValue, "In-App Purchases Capability"),
"Enable this to grant your app the capability for in-app purchases. "
"This option requires that you specify a valid Development Team ID.");
if (iOS)
{
props.add (new ChoicePropertyComponent (iosBackgroundAudioValue, "Audio Background Capability"),
"Enable this to grant your app the capability to access audio when in background mode.");
props.add (new ChoicePropertyComponent (iosBackgroundBleValue, "Bluetooth MIDI Background Capability"),
"Enable this to grant your app the capability to connect to Bluetooth LE devices when in background mode.");
props.add (new ChoicePropertyComponent (iosAppGroupsValue, "App Groups Capability"),
"Enable this to grant your app the capability to share resources between apps using the same app group ID.");
props.add (new ChoicePropertyComponent (iCloudPermissionsValue, "iCloud Permissions"),
"Enable this to grant your app the capability to use native file load/save browser windows on iOS.");
}
props.add (new ChoicePropertyComponent (iosPushNotificationsValue, "Push Notifications Capability"),
"Enable this to grant your app the capability to receive push notifications.");
props.add (new TextPropertyComponent (customPListValue, "Custom PList", 8192, true),
"You can paste the contents of an XML PList file in here, and the settings that it contains will override any "
"settings that the Projucer creates. BEWARE! When doing this, be careful to remove from the XML any "
"values that you DO want the Projucer to change!");
props.add (new ChoicePropertyComponent (pListPreprocessValue, "PList Preprocess"),
"Enable this to preprocess PList file. This will allow you to set values to preprocessor defines,"
" for instance if you define: #define MY_FLAG 1 in a prefix header file (see PList prefix header), you can have"
" a key with MY_FLAG value and it will be replaced with 1.");
props.add (new TextPropertyComponent (pListPrefixHeaderValue, "PList Prefix Header", 512, false),
"Header file containing definitions used in plist file (see PList Preprocess).");
props.add (new TextPropertyComponent (extraFrameworksValue, "Extra Frameworks", 2048, false),
"A comma-separated list of extra frameworks that should be added to the build. "
"(Don't include the .framework extension in the name)");
props.add (new TextPropertyComponent (prebuildCommandValue, "Pre-Build Shell Script", 32768, true),
"Some shell-script that will be run before a build starts.");
props.add (new TextPropertyComponent (postbuildCommandValue, "Post-Build Shell Script", 32768, true),
"Some shell-script that will be run after a build completes.");
props.add (new TextPropertyComponent (iosDevelopmentTeamIDValue, "Development Team ID", 10, false),
"The Development Team ID to be used for setting up code-signing your iOS app. This is a ten-character "
"string (for example, \"S7B6T5XJ2Q\") that describes the distribution certificate Apple issued to you. "
"You can find this string in the OS X app Keychain Access under \"Certificates\".");
if (iOS)
props.add (new TextPropertyComponentWithEnablement (iosAppGroupsIDValue, iosAppGroupsValue, "App Group ID", 256, false),
"The App Group ID to be used for allowing multiple apps to access a shared resource folder. Multiple IDs can be "
"added separated by a semicolon.");
props.add (new ChoicePropertyComponent (keepCustomXcodeSchemesValue, "Keep Custom Xcode Schemes"),
"Enable this to keep any Xcode schemes you have created for debugging or running, e.g. to launch a plug-in in"
"various hosts. If disabled, all schemes are replaced by a default set.");
props.add (new ChoicePropertyComponent (useHeaderMapValue, "USE_HEADERMAP"),
"Enable this to make Xcode search all the projects folders for include files. This means you can be lazy "
"and not bother using relative paths to include your headers, but it means your code won't be "
"compatible with other build systems");
}
bool launchProject() override
{
#if JUCE_MAC
return getProjectBundle().startAsProcess();
#else
return false;
#endif
}
bool canLaunchProject() override
{
#if JUCE_MAC
return true;
#else
return false;
#endif
}
//==============================================================================
void create (const OwnedArray<LibraryModule>&) const override
{
for (auto& target : targets)
if (target->shouldCreatePList())
target->infoPlistFile = getTargetFolder().getChildFile (target->getInfoPlistName());
menuNibFile = getTargetFolder().getChildFile ("RecentFilesMenuTemplate.nib");
createIconFile();
auto projectBundle = getProjectBundle();
createDirectoryOrThrow (projectBundle);
createObjects();
auto projectFile = projectBundle.getChildFile ("project.pbxproj");
{
MemoryOutputStream mo;
writeProjectFile (mo);
overwriteFileIfDifferentOrThrow (projectFile, mo);
}
writeInfoPlistFiles();
// Deleting the .rsrc files can be needed to force Xcode to update the version number.
deleteRsrcFiles (getTargetFolder().getChildFile ("build"));
}
//==============================================================================
void addPlatformSpecificSettingsForProjectType (const ProjectType&) override
{
callForAllSupportedTargets ([this] (ProjectType::Target::Type targetType)
{
if (auto* target = new XcodeTarget (targetType, *this))
{
if (targetType == ProjectType::Target::AggregateTarget)
targets.insert (0, target);
else
targets.add (target);
}
});
// If you hit this assert, you tried to generate a project for an exporter
// that does not support any of your targets!
jassert (targets.size() > 0);
}
void updateDeprecatedProjectSettingsInteractively() override
{
if (hasInvalidPostBuildScript())
{
String alertWindowText = iOS ? "Your Xcode (iOS) Exporter settings use an invalid post-build script. Click 'Update' to remove it."
: "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"
"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"
"Click 'Update' to remove the script (otherwise your plug-in may not compile correctly).";
if (AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
"Project settings: " + project.getDocumentTitle(),
alertWindowText, "Update", "Cancel", nullptr, nullptr))
postbuildCommandValue.resetToDefault();
}
}
bool hasInvalidPostBuildScript() const
{
// check whether the script is identical to the old one that the Introjucer used to auto-generate
return (MD5 (getPostBuildScript().toUTF8()).toHexString() == "265ac212a7e734c5bbd6150e1eae18a1");
}
//==============================================================================
void initialiseDependencyPathValues() override
{
vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder), Ids::vst3Path, TargetOS::osx)));
aaxPath. referTo (Value (new DependencyPathValueSource (getSetting (Ids::aaxFolder), Ids::aaxPath, TargetOS::osx)));
rtasPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::rtasFolder), Ids::rtasPath, TargetOS::osx)));
}
protected:
//==============================================================================
class XcodeBuildConfiguration : public BuildConfiguration
{
public:
XcodeBuildConfiguration (Project& p, const ValueTree& t, const bool isIOS, const ProjectExporter& e)
: BuildConfiguration (p, t, e),
iOS (isIOS),
osxSDKVersion (config, Ids::osxSDK, getUndoManager()),
osxDeploymentTarget (config, Ids::osxCompatibility, getUndoManager(), String (osxVersionDefault) + " SDK"),
iosDeploymentTarget (config, Ids::iosCompatibility, getUndoManager(), iosVersionDefault),
osxArchitecture (config, Ids::osxArchitecture, getUndoManager(), osxArch_Default),
customXcodeFlags (config, Ids::customXcodeFlags, getUndoManager()),
plistPreprocessorDefinitions (config, Ids::plistPreprocessorDefinitions, getUndoManager()),
codeSignIdentity (config, Ids::codeSigningIdentity, getUndoManager(), iOS ? "iPhone Developer" : "Mac Developer"),
fastMathEnabled (config, Ids::fastMath, getUndoManager()),
stripLocalSymbolsEnabled (config, Ids::stripLocalSymbols, getUndoManager()),
pluginBinaryCopyStepEnabled (config, Ids::enablePluginBinaryCopyStep, getUndoManager(), true),
vstBinaryLocation (config, Ids::vstBinaryLocation, getUndoManager(), "$(HOME)/Library/Audio/Plug-Ins/VST/"),
vst3BinaryLocation (config, Ids::vst3BinaryLocation, getUndoManager(), "$(HOME)/Library/Audio/Plug-Ins/VST3/"),
auBinaryLocation (config, Ids::auBinaryLocation, getUndoManager(), "$(HOME)/Library/Audio/Plug-Ins/Components/"),
rtasBinaryLocation (config, Ids::rtasBinaryLocation, getUndoManager(), "/Library/Application Support/Digidesign/Plug-Ins/"),
aaxBinaryLocation (config, Ids::aaxBinaryLocation, getUndoManager(), "/Library/Application Support/Avid/Audio/Plug-Ins/")
{
updateOldPluginBinaryLocations();
updateOldSDKDefaults();
optimisationLevelValue.setDefault (isDebug() ? gccO0 : gccO3);
}
//==========================================================================
void createConfigProperties (PropertyListBuilder& props) override
{
addXcodePluginInstallPathProperties (props);
addGCCOptimisationProperty (props);
if (iOS)
{
props.add (new ChoicePropertyComponent (iosDeploymentTarget, "iOS Deployment Target",
{ "7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "8.4",
"9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3",
"11.0" },
{ "7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "8.4",
"9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3",
"11.0" }),
"The minimum version of iOS that the target binary will run on.");
}
else
{
StringArray sdkVersionNames, osxVersionNames;
Array<var> versionValues;
for (int ver = oldestSDKVersion; ver <= currentSDKVersion; ++ver)
{
sdkVersionNames.add (getSDKName (ver));
osxVersionNames.add (getOSXVersionName (ver));
versionValues.add (getSDKName (ver));
}
props.add (new ChoicePropertyComponent (osxSDKVersion, "OSX Base SDK Version", sdkVersionNames, versionValues),
"The version of OSX to link against in the Xcode build. If \"Default\" is selected then the field will be left "
"empty and the Xcode default will be used.");
props.add (new ChoicePropertyComponent (osxDeploymentTarget, "OSX Deployment Target", osxVersionNames, versionValues),
"The minimum version of OSX that the target binary will be compatible with.");
props.add (new ChoicePropertyComponent (osxArchitecture, "OSX Architecture",
{ "Native architecture of build machine", "Universal Binary (32-bit)", "Universal Binary (32/64-bit)", "64-bit Intel" },
{ osxArch_Native, osxArch_32BitUniversal, osxArch_64BitUniversal, osxArch_64Bit }),
"The type of OSX binary that will be produced.");
}
props.add (new TextPropertyComponent (customXcodeFlags, "Custom Xcode Flags", 8192, false),
"A comma-separated list of custom Xcode setting flags which will be appended to the list of generated flags, "
"e.g. MACOSX_DEPLOYMENT_TARGET_i386 = 10.5, VALID_ARCHS = \"ppc i386 x86_64\"");
props.add (new TextPropertyComponent (plistPreprocessorDefinitions, "PList Preprocessor Definitions", 2048, true),
"Preprocessor definitions used during PList preprocessing (see PList Preprocess).");
props.add (new TextPropertyComponent (codeSignIdentity, "Code-Signing Identity", 1024, false),
"The name of a code-signing identity for Xcode to apply.");
props.add (new ChoicePropertyComponent (fastMathEnabled, "Relax IEEE Compliance"),
"Enable this to use FAST_MATH non-IEEE mode. (Warning: this can have unexpected results!)");
props.add (new ChoicePropertyComponent (stripLocalSymbolsEnabled, "Strip Local Symbols"),
"Enable this to strip any locally defined symbols resulting in a smaller binary size. Enabling this "
"will also remove any function names from crash logs. Must be disabled for static library projects.");
}
String getModuleLibraryArchName() const override
{
return "${CURRENT_ARCH}";
}
//==========================================================================
String getOSXArchitectureString() const { return osxArchitecture.get(); }
String getPListPreprocessorDefinitionsString() const { return plistPreprocessorDefinitions.get(); }
bool isFastMathEnabled() const { return fastMathEnabled.get(); }
bool isStripLocalSymbolsEnabled() const { return stripLocalSymbolsEnabled.get(); }
String getCustomXcodeFlagsString() const { return customXcodeFlags.get(); }
String getOSXSDKVersionString() const { return osxSDKVersion.get(); }
String getOSXDeploymentTargetString() const { return osxDeploymentTarget.get(); }
String getCodeSignIdentityString() const { return codeSignIdentity.get(); }
bool isUsingDefaultCodeSignIdentity() const { return codeSignIdentity.isUsingDefault(); }
String getiOSDeploymentTargetString() const { return iosDeploymentTarget.get(); }
bool isPluginBinaryCopyStepEnabled() const { return pluginBinaryCopyStepEnabled.get(); }
String getVSTBinaryLocationString() const { return vstBinaryLocation.get(); }
String getVST3BinaryLocationString() const { return vst3BinaryLocation.get(); }
String getAUBinaryLocationString() const { return auBinaryLocation.get(); }
String getRTASBinaryLocationString() const { return rtasBinaryLocation.get();}
String getAAXBinaryLocationString() const { return aaxBinaryLocation.get();}
private:
//==========================================================================
bool iOS;
ValueWithDefault osxSDKVersion, osxDeploymentTarget, iosDeploymentTarget, osxArchitecture,
customXcodeFlags, plistPreprocessorDefinitions, codeSignIdentity,
fastMathEnabled, stripLocalSymbolsEnabled, pluginBinaryCopyStepEnabled,
vstBinaryLocation, vst3BinaryLocation, auBinaryLocation, rtasBinaryLocation, aaxBinaryLocation;
//==========================================================================
void addXcodePluginInstallPathProperties (PropertyListBuilder& props)
{
auto isBuildingAnyPlugins = (project.shouldBuildVST() || project.shouldBuildVST3() || project.shouldBuildAU()
|| project.shouldBuildRTAS() || project.shouldBuildAAX());
if (isBuildingAnyPlugins)
props.add (new ChoicePropertyComponent (pluginBinaryCopyStepEnabled, "Enable Plugin Copy Step"),
"Enable this to copy plugin binaries to the specified folder after building.");
if (project.shouldBuildVST())
props.add (new TextPropertyComponentWithEnablement (vstBinaryLocation, pluginBinaryCopyStepEnabled, "VST Binary Location",
1024, false),
"The folder in which the compiled VST binary should be placed.");
if (project.shouldBuildVST3())
props.add (new TextPropertyComponentWithEnablement (vst3BinaryLocation, pluginBinaryCopyStepEnabled, "VST3 Binary Location",
1024, false),
"The folder in which the compiled VST3 binary should be placed.");
if (project.shouldBuildAU())
props.add (new TextPropertyComponentWithEnablement (auBinaryLocation, pluginBinaryCopyStepEnabled, "AU Binary Location",
1024, false),
"The folder in which the compiled AU binary should be placed.");
if (project.shouldBuildRTAS())
props.add (new TextPropertyComponentWithEnablement (rtasBinaryLocation, pluginBinaryCopyStepEnabled, "RTAS Binary Location",
1024, false),
"The folder in which the compiled RTAS binary should be placed.");
if (project.shouldBuildAAX())
props.add (new TextPropertyComponentWithEnablement (aaxBinaryLocation, pluginBinaryCopyStepEnabled, "AAX Binary Location",
1024, false),
"The folder in which the compiled AAX binary should be placed.");
}
void updateOldPluginBinaryLocations()
{
if (! config ["xcodeVstBinaryLocation"].isVoid()) vstBinaryLocation = config ["xcodeVstBinaryLocation"];
if (! config ["xcodeVst3BinaryLocation"].isVoid()) vst3BinaryLocation = config ["xcodeVst3BinaryLocation"];
if (! config ["xcodeAudioUnitBinaryLocation"].isVoid()) auBinaryLocation = config ["xcodeAudioUnitBinaryLocation"];
if (! config ["xcodeRtasBinaryLocation"].isVoid()) rtasBinaryLocation = config ["xcodeRtasBinaryLocation"];
if (! config ["xcodeAaxBinaryLocation"].isVoid()) aaxBinaryLocation = config ["xcodeAaxBinaryLocation"];
}
void updateOldSDKDefaults()
{
if (iosDeploymentTarget.get() == "default") iosDeploymentTarget.resetToDefault();
if (osxArchitecture.get() == "default") osxArchitecture.resetToDefault();
if (osxSDKVersion.get() == "default") osxSDKVersion.resetToDefault();
if (osxDeploymentTarget.get() == "default") osxDeploymentTarget.resetToDefault();
}
};
BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override
{
return new XcodeBuildConfiguration (project, v, iOS, *this);
}
public:
//==============================================================================
/* The numbers for these enum values are defined by Xcode for the different
possible destinations of a "copy files" post-build step.
*/
enum XcodeCopyFilesDestinationIDs
{
kWrapperFolder = 1,
kExecutablesFolder = 6,
kResourcesFolder = 7,
kFrameworksFolder = 10,
kSharedFrameworksFolder = 11,
kSharedSupportFolder = 12,
kPluginsFolder = 13,
kJavaResourcesFolder = 15,
kXPCServicesFolder = 16
};
//==============================================================================
struct XcodeTarget : ProjectType::Target
{
//==============================================================================
XcodeTarget (ProjectType::Target::Type targetType, const XcodeProjectExporter& exporter)
: ProjectType::Target (targetType),
owner (exporter)
{
switch (type)
{
case GUIApp:
xcodePackageType = "APPL";
xcodeBundleSignature = "????";
xcodeFileType = "wrapper.application";
xcodeBundleExtension = ".app";
xcodeProductType = "com.apple.product-type.application";
xcodeCopyToProductInstallPathAfterBuild = false;
break;
case ConsoleApp:
xcodeFileType = "compiled.mach-o.executable";
xcodeBundleExtension = String();
xcodeProductType = "com.apple.product-type.tool";
xcodeCopyToProductInstallPathAfterBuild = false;
break;
case StaticLibrary:
xcodeFileType = "archive.ar";
xcodeBundleExtension = ".a";
xcodeProductType = "com.apple.product-type.library.static";
xcodeCopyToProductInstallPathAfterBuild = false;
break;
case DynamicLibrary:
xcodeFileType = "compiled.mach-o.dylib";
xcodeProductType = "com.apple.product-type.library.dynamic";
xcodeBundleExtension = ".dylib";
xcodeCopyToProductInstallPathAfterBuild = false;
break;
case VSTPlugIn:
xcodePackageType = "BNDL";
xcodeBundleSignature = "????";
xcodeFileType = "wrapper.cfbundle";
xcodeBundleExtension = ".vst";
xcodeProductType = "com.apple.product-type.bundle";
xcodeCopyToProductInstallPathAfterBuild = true;
break;
case VST3PlugIn:
xcodePackageType = "BNDL";
xcodeBundleSignature = "????";
xcodeFileType = "wrapper.cfbundle";
xcodeBundleExtension = ".vst3";
xcodeProductType = "com.apple.product-type.bundle";
xcodeCopyToProductInstallPathAfterBuild = true;
break;
case AudioUnitPlugIn:
xcodePackageType = "BNDL";
xcodeBundleSignature = "????";
xcodeFileType = "wrapper.cfbundle";
xcodeBundleExtension = ".component";
xcodeProductType = "com.apple.product-type.bundle";
xcodeCopyToProductInstallPathAfterBuild = true;
addExtraAudioUnitTargetSettings();
break;
case StandalonePlugIn:
xcodePackageType = "APPL";
xcodeBundleSignature = "????";
xcodeFileType = "wrapper.application";
xcodeBundleExtension = ".app";
xcodeProductType = "com.apple.product-type.application";
xcodeCopyToProductInstallPathAfterBuild = false;
break;
case AudioUnitv3PlugIn:
xcodePackageType = "XPC!";
xcodeBundleSignature = "????";
xcodeFileType = "wrapper.app-extension";
xcodeBundleExtension = ".appex";
xcodeBundleIDSubPath = "AUv3";
xcodeProductType = "com.apple.product-type.app-extension";
xcodeCopyToProductInstallPathAfterBuild = false;
addExtraAudioUnitv3PlugInTargetSettings();
break;
case AAXPlugIn:
xcodePackageType = "TDMw";
xcodeBundleSignature = "PTul";
xcodeFileType = "wrapper.cfbundle";
xcodeBundleExtension = ".aaxplugin";
xcodeProductType = "com.apple.product-type.bundle";
xcodeCopyToProductInstallPathAfterBuild = true;
break;
case RTASPlugIn:
xcodePackageType = "TDMw";
xcodeBundleSignature = "PTul";
xcodeFileType = "wrapper.cfbundle";
xcodeBundleExtension = ".dpm";
xcodeProductType = "com.apple.product-type.bundle";
xcodeCopyToProductInstallPathAfterBuild = true;
break;
case SharedCodeTarget:
xcodeFileType = "archive.ar";
xcodeBundleExtension = ".a";
xcodeProductType = "com.apple.product-type.library.static";
xcodeCopyToProductInstallPathAfterBuild = false;
break;
case AggregateTarget:
xcodeCopyToProductInstallPathAfterBuild = false;
break;
default:
// unknown target type!
jassertfalse;
break;
}
}
String getXcodeSchemeName() const
{
return owner.projectName + " - " + getName();
}
String getID() const
{
return owner.createID (String ("__target") + getName());
}
String getInfoPlistName() const
{
return String ("Info-") + String (getName()).replace (" ", "_") + String (".plist");
}
String xcodePackageType, xcodeBundleSignature, xcodeBundleExtension;
String xcodeProductType, xcodeFileType;
String xcodeOtherRezFlags, xcodeBundleIDSubPath;
bool xcodeCopyToProductInstallPathAfterBuild;
StringArray xcodeFrameworks, xcodeLibs;
Array<XmlElement> xcodeExtraPListEntries;
StringArray frameworkIDs, buildPhaseIDs, configIDs, sourceIDs, rezFileIDs;
StringArray frameworkNames;
String dependencyID, mainBuildProductID;
File infoPlistFile;
struct SourceFileInfo
{
RelativePath path;
bool shouldBeCompiled = false;
};
Array<SourceFileInfo> getSourceFilesInfo (const Project::Item& projectItem) const
{
Array<SourceFileInfo> result;
auto targetType = (owner.getProject().getProjectType().isAudioPlugin() ? type : SharedCodeTarget);
if (projectItem.isGroup())
{
for (int i = 0; i < projectItem.getNumChildren(); ++i)
result.addArray (getSourceFilesInfo (projectItem.getChild (i)));
}
else if (projectItem.shouldBeAddedToTargetProject()
&& owner.getProject().getTargetTypeFromFilePath (projectItem.getFile(), true) == targetType)
{
SourceFileInfo info;
info.path = RelativePath (projectItem.getFile(), owner.getTargetFolder(), RelativePath::buildTargetFolder);
jassert (info.path.getRoot() == RelativePath::buildTargetFolder);
if (targetType == SharedCodeTarget || projectItem.shouldBeCompiled())
info.shouldBeCompiled = projectItem.shouldBeCompiled();
result.add (info);
}
return result;
}
//==============================================================================
void addMainBuildProduct() const
{
jassert (xcodeFileType.isNotEmpty());
jassert (xcodeBundleExtension.isEmpty() || xcodeBundleExtension.startsWithChar ('.'));
if (ProjectExporter::BuildConfiguration::Ptr config = owner.getConfiguration(0))
{
auto productName = owner.replacePreprocessorTokens (*config, config->getTargetBinaryNameString());
if (xcodeFileType == "archive.ar")
productName = getStaticLibbedFilename (productName);
else
productName += xcodeBundleExtension;
addBuildProduct (xcodeFileType, productName);
}
}
//==============================================================================
void addBuildProduct (const String& fileType, const String& binaryName) const
{
auto* v = new ValueTree (owner.createID (String ("__productFileID") + getName()));
v->setProperty ("isa", "PBXFileReference", nullptr);
v->setProperty ("explicitFileType", fileType, nullptr);
v->setProperty ("includeInIndex", (int) 0, nullptr);
v->setProperty ("path", sanitisePath (binaryName), nullptr);
v->setProperty ("sourceTree", "BUILT_PRODUCTS_DIR", nullptr);
owner.pbxFileReferences.add (v);
}
//==============================================================================
void addDependency()
{
jassert (dependencyID.isEmpty());
dependencyID = owner.createID (String ("__dependency") + getName());
auto* v = new ValueTree (dependencyID);
v->setProperty ("isa", "PBXTargetDependency", nullptr);
v->setProperty ("target", getID(), nullptr);
owner.misc.add (v);
}
String getDependencyID() const
{
jassert (dependencyID.isNotEmpty());
return dependencyID;
}
//==============================================================================
void addTargetConfig (const String& configName, const StringArray& buildSettings)
{
auto configID = owner.createID (String ("targetconfigid_") + getName() + String ("_") + configName);
auto* v = new ValueTree (configID);
v->setProperty ("isa", "XCBuildConfiguration", nullptr);
v->setProperty ("buildSettings", indentBracedList (buildSettings), nullptr);
v->setProperty (Ids::name, configName, nullptr);
configIDs.add (configID);
owner.targetConfigs.add (v);
}
//==============================================================================
String getTargetAttributes() const
{
auto attributes = getID() + " = { ";
auto developmentTeamID = owner.getIosDevelopmentTeamIDString();
if (developmentTeamID.isNotEmpty())
{
attributes << "DevelopmentTeam = " << developmentTeamID << "; ";
attributes << "ProvisioningStyle = Automatic; ";
}
auto appGroupsEnabled = (owner.iOS && owner.isAppGroupsEnabled() ? 1 : 0);
auto inAppPurchasesEnabled = owner.isInAppPurchasesEnabled() ? 1 : 0;
auto interAppAudioEnabled = (owner.iOS
&& type == Target::StandalonePlugIn
&& owner.getProject().shouldEnableIAA()) ? 1 : 0;
auto pushNotificationsEnabled = owner.isPushNotificationsEnabled() ? 1 : 0;
auto sandboxEnabled = (type == Target::AudioUnitv3PlugIn ? 1 : 0);
attributes << "SystemCapabilities = {";
attributes << "com.apple.ApplicationGroups.iOS = { enabled = " << appGroupsEnabled << "; }; ";
attributes << "com.apple.InAppPurchase = { enabled = " << inAppPurchasesEnabled << "; }; ";
attributes << "com.apple.InterAppAudio = { enabled = " << interAppAudioEnabled << "; }; ";
attributes << "com.apple.Push = { enabled = " << pushNotificationsEnabled << "; }; ";
attributes << "com.apple.Sandbox = { enabled = " << sandboxEnabled << "; }; ";
if (owner.iOS && owner.isiCloudPermissionsEnabled())
attributes << "com.apple.iCloud = { enabled = 1; }; ";
attributes << "}; };";
return attributes;
}
//==============================================================================
ValueTree& addBuildPhase (const String& buildPhaseType, const StringArray& fileIds, const StringRef humanReadableName = StringRef())
{
auto buildPhaseName = buildPhaseType + "_" + getName() + "_" + (humanReadableName.isNotEmpty() ? String (humanReadableName) : String ("resbuildphase"));
auto buildPhaseId (owner.createID (buildPhaseName));
int n = 0;
while (buildPhaseIDs.contains (buildPhaseId))
buildPhaseId = owner.createID (buildPhaseName + String (++n));
buildPhaseIDs.add (buildPhaseId);
auto* v = new ValueTree (buildPhaseId);
v->setProperty ("isa", buildPhaseType, nullptr);
v->setProperty ("buildActionMask", "2147483647", nullptr);
v->setProperty ("files", indentParenthesisedList (fileIds), nullptr);
v->setProperty ("runOnlyForDeploymentPostprocessing", (int) 0, nullptr);
if (humanReadableName.isNotEmpty())
v->setProperty ("name", String (humanReadableName), nullptr);
owner.misc.add (v);
return *v;
}
bool shouldCreatePList() const
{
auto fileType = getTargetFileType();
return (fileType == executable && type != ConsoleApp) || fileType == pluginBundle || fileType == macOSAppex;
}
//==============================================================================
bool shouldAddEntitlements() const
{
if (owner.isPushNotificationsEnabled() || owner.isAppGroupsEnabled() || (owner.isiOS() && owner.isiCloudPermissionsEnabled()))
return true;
if (owner.project.getProjectType().isAudioPlugin()
&& ( (owner.isOSX() && type == Target::AudioUnitv3PlugIn)
|| (owner.isiOS() && type == Target::StandalonePlugIn && owner.getProject().shouldEnableIAA())))
return true;
return false;
}
String getBundleIdentifier() const
{
auto bundleIdentifier = owner.project.getBundleIdentifierString();
if (xcodeBundleIDSubPath.isNotEmpty())
{
auto bundleIdSegments = StringArray::fromTokens (bundleIdentifier, ".", StringRef());
jassert (bundleIdSegments.size() > 0);
bundleIdentifier += String (".") + bundleIdSegments[bundleIdSegments.size() - 1] + xcodeBundleIDSubPath;
}
return bundleIdentifier;
}
//==============================================================================
StringPairArray getTargetSettings (const XcodeBuildConfiguration& config) const
{
StringPairArray s;
if (type == AggregateTarget && ! owner.isiOS())
{
// the aggregate target needs to have the deployment target set for
// pre-/post-build scripts
String sdkRoot;
s.set ("MACOSX_DEPLOYMENT_TARGET", getOSXDeploymentTarget (config, &sdkRoot));
if (sdkRoot.isNotEmpty())
s.set ("SDKROOT", sdkRoot);
return s;
}
s.set ("PRODUCT_BUNDLE_IDENTIFIER", getBundleIdentifier());
auto arch = (! owner.isiOS() && type == Target::AudioUnitv3PlugIn) ? osxArch_64Bit
: config.getOSXArchitectureString();
if (arch == osxArch_Native) s.set ("ARCHS", "\"$(NATIVE_ARCH_ACTUAL)\"");
else if (arch == osxArch_32BitUniversal) s.set ("ARCHS", "\"$(ARCHS_STANDARD_32_BIT)\"");
else if (arch == osxArch_64BitUniversal) s.set ("ARCHS", "\"$(ARCHS_STANDARD_32_64_BIT)\"");
else if (arch == osxArch_64Bit) s.set ("ARCHS", "\"$(ARCHS_STANDARD_64_BIT)\"");
s.set ("HEADER_SEARCH_PATHS", String ("(") + getHeaderSearchPaths (config).joinIntoString (", ") + ", \"$(inherited)\")");
s.set ("USE_HEADERMAP", String (static_cast<bool> (config.exporter.settings.getProperty ("useHeaderMap")) ? "YES" : "NO"));
s.set ("GCC_OPTIMIZATION_LEVEL", config.getGCCOptimisationFlag());
if (shouldCreatePList())