From 4eeca92437ceac731b477d37c57583d8b27e2c75 Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 9 Jan 2019 14:33:21 +0000 Subject: [PATCH] Projucer: Add a blank launch screen storyboard to iOS projects if no custom xcassets folder is set so that the latest iOS device resolutions are supported and add a field to the iOS exporter which allows a custom storyboard file to be used instead --- .../ProjectSaving/jucer_ProjectExport_Xcode.h | 67 ++++++++++++++++++- .../Source/Utility/Helpers/jucer_PresetIDs.h | 1 + 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h index d47299d99f..0ff39a5764 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h @@ -94,7 +94,8 @@ public: iosDevelopmentTeamIDValue (settings, Ids::iosDevelopmentTeamID, getUndoManager()), iosAppGroupsIDValue (settings, Ids::iosAppGroupsId, getUndoManager()), keepCustomXcodeSchemesValue (settings, Ids::keepCustomXcodeSchemes, getUndoManager()), - useHeaderMapValue (settings, Ids::useHeaderMap, getUndoManager()) + useHeaderMapValue (settings, Ids::useHeaderMap, getUndoManager()), + customLaunchStoryboardValue (settings, Ids::customLaunchStoryboard, getUndoManager()) { name = iOS ? getNameiOS() : getNameMac(); @@ -133,6 +134,7 @@ public: String getCustomResourceFoldersString() const { return customXcodeResourceFoldersValue.get().toString().replaceCharacters ("\r\n", "::"); } String getCustomXcassetsFolderString() const { return customXcassetsFolderValue.get(); } + String getCustomLaunchStoryboardString() const { return customLaunchStoryboardValue.get(); } bool isMicrophonePermissionEnabled() const { return microphonePermissionNeededValue.get(); } String getMicrophonePermissionsTextString() const { return microphonePermissionsTextValue.get(); } @@ -153,6 +155,8 @@ public: String getIosDevelopmentTeamIDString() const { return iosDevelopmentTeamIDValue.get(); } String getAppGroupIdString() const { return iosAppGroupsIDValue.get(); } + String getDefaultLaunchStoryboardName() const { jassert (iOS); return "LaunchScreen.storyboard"; } + //============================================================================== bool usesMMFiles() const override { return true; } bool canCopeWithDuplicateFiles() override { return true; } @@ -204,7 +208,13 @@ public: { 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."); + "for the app icons and launchimages, and will ignore the Icon files specified above. This will also prevent " + "a launch storyboard from being used."); + + props.add (new TextPropertyComponent (customLaunchStoryboardValue, "Custom Launch Storyboard", 256, false), + "If this field is not empty then the specified launch storyboard will be used for the app's launch screen, " + "otherwise a default blank launch storyboard will be generated. This should just be the file name and the " + "file should be added to the project's Xcode resources."); } props.add (new TextPropertyComponent (customXcodeResourceFoldersValue, "Custom Xcode Resource Folders", 8192, true), @@ -1376,6 +1386,14 @@ public: if (type != AudioUnitv3PlugIn) addPlistDictionaryKeyBool (dict, "UIViewControllerBasedStatusBarAppearance", false); + + if (owner.getCustomXcassetsFolderString().isEmpty()) + { + auto customStoryboard = owner.getCustomLaunchStoryboardString(); + + addPlistDictionaryKey (dict, "UILaunchStoryboardName", customStoryboard.isNotEmpty() ? customStoryboard + : owner.getDefaultLaunchStoryboardName()); + } } addPlistDictionaryKey (dict, "CFBundleExecutable", "${EXECUTABLE_NAME}"); @@ -1804,7 +1822,7 @@ private: microphonePermissionNeededValue, microphonePermissionsTextValue, cameraPermissionNeededValue, cameraPermissionTextValue, uiFileSharingEnabledValue, uiSupportsDocumentBrowserValue, uiStatusBarHiddenValue, documentExtensionsValue, iosInAppPurchasesValue, iosBackgroundAudioValue, iosBackgroundBleValue, iosPushNotificationsValue, iosAppGroupsValue, iCloudPermissionsValue, - iosDevelopmentTeamIDValue, iosAppGroupsIDValue, keepCustomXcodeSchemesValue, useHeaderMapValue; + iosDevelopmentTeamIDValue, iosAppGroupsIDValue, keepCustomXcodeSchemesValue, useHeaderMapValue, customLaunchStoryboardValue; static String sanitisePath (const String& path) { @@ -1838,9 +1856,16 @@ private: addPlistFileReferences(); if (iOS && ! projectType.isStaticLibrary()) + { addXcassets(); + + if (getCustomXcassetsFolderString().isEmpty() && getCustomLaunchStoryboardString().isEmpty()) + writeDefaultLaunchStoryboardFile(); + } else + { addNibFiles(); + } addIcons(); addBuildConfigurations(); @@ -3396,6 +3421,42 @@ private: return JSON::toString (var (v.get())); } + void writeDefaultLaunchStoryboardFile() const + { + auto storyboardFile = getTargetFolder().getChildFile (getDefaultLaunchStoryboardName()); + + MemoryOutputStream mo; + mo.setNewLineString ("\n"); + + mo << "" << newLine + << "" << newLine + << " " << newLine + << " " << newLine + << " " << newLine + << " " << newLine + << " " << newLine + << " " << newLine + << " " << newLine + << " " << newLine + << " " << newLine + << " " << newLine + << " " << newLine + << " " << newLine + << " " << newLine + << "" << newLine; + + overwriteFileIfDifferentOrThrow (storyboardFile, mo); + + auto path = RelativePath (storyboardFile, getTargetFolder(), RelativePath::buildTargetFolder).toUnixStyle(); + auto refID = addFileReference (path); + auto fileID = addBuildFile (path, refID, false, false); + + resourceIDs.add (fileID); + resourceFileRefs.add (refID); + } + void createXcassetsFolderFromIcons() const { auto assets = getTargetFolder().getChildFile (project.getProjectFilenameRootString()) diff --git a/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h b/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h index 5930a9d8e5..d9cb0a3580 100644 --- a/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h +++ b/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h @@ -98,6 +98,7 @@ namespace Ids DECLARE_ID (libraryPath); DECLARE_ID (customXcodeFlags); DECLARE_ID (customXcassetsFolder); + DECLARE_ID (customLaunchStoryboard); DECLARE_ID (customXcodeResourceFolders); DECLARE_ID (plistPreprocessorDefinitions); DECLARE_ID (customPList);