X-Git-Url: http://nitlanguage.org diff --git a/src/platform/xcode_templates.nit b/src/platform/xcode_templates.nit index e4ebbdf..62768a2 100644 --- a/src/platform/xcode_templates.nit +++ b/src/platform/xcode_templates.nit @@ -85,6 +85,9 @@ class PbxFile # Path to `self` var path: String + # Compiler flags for this source file + var cflags: String = "" is writable + # UUID for build elements private var build_uuid: String = sys.pbx_uuid_generator.next_uuid is lazy @@ -104,15 +107,22 @@ class PbxFile end # PBX description of this file - private fun description: Writable do return """ + private fun description: Writable + do + var extra = "" + var cflags = cflags + if not cflags.is_empty then extra = "\nsettings = \{COMPILER_FLAGS = \"{cflags}\"; \};" + + return """ {{{ref_uuid}}} /* {{{doc}}} */ = { isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = {{{file_type}}}; - path = {{{path}}}; - sourceTree = ""; + path = '{{{path}}}'; + sourceTree = "";{{{extra}}} }; """ + end private fun add_to_project(project: PbxprojectTemplate) do @@ -139,6 +149,9 @@ class PbxprojectTemplate # Name of the project var name: String + # OTHER_CFLAGS + var cflags = "" is writable + # All body/implementation source files to be compiled private var source_files = new Array[PbxFile] @@ -174,18 +187,10 @@ class PbxprojectTemplate """ add """ + 0F4688411FDF8748004F34D4 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 0F4688401FDF8748004F34D4 /* assets */; }; + 0FDD07A21C6F8E0E006FF70E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0FDD07A11C6F8E0E006FF70E /* LaunchScreen.storyboard */; }; /* End PBXBuildFile section */ -/* Begin PBXContainerItemProxy section */ - AF9F83EA1A5F0D21004B62C0 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = AF9F83C41A5F0D21004B62C0 /* Project object */; - proxyType = 1; - remoteGlobalIDString = AF9F83CB1A5F0D21004B62C0; - remoteInfo = {{{name}}}; - }; -/* End PBXContainerItemProxy section */ - /* Begin PBXFileReference section */ /* Static generated files */ AF9F83CC1A5F0D21004B62C0 /* {{{name}}}.app */ = { @@ -221,25 +226,6 @@ class PbxprojectTemplate path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; - AF9F83E91A5F0D21004B62C0 /* {{{name}}}Tests.xctest */ = { - isa = PBXFileReference; - explicitFileType = wrapper.cfbundle; - includeInIndex = 0; - path = {{{name}}}Tests.xctest; - sourceTree = BUILT_PRODUCTS_DIR; - }; - AF9F83EE1A5F0D21004B62C0 /* Info.plist */ = { - isa = PBXFileReference; - lastKnownFileType = text.plist.xml; - path = Info.plist; - sourceTree = ""; - }; - AF9F83EF1A5F0D21004B62C0 /* {{{name}}}Tests.m */ = { - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.objc; - path = {{{name}}}Tests.m; - sourceTree = ""; - }; /* Changing generated files */ """ @@ -247,6 +233,8 @@ class PbxprojectTemplate for file in files do add file.description add """ + 0F4688401FDF8748004F34D4 /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = assets; path = {{{name}}}/assets; sourceTree = SOURCE_ROOT; }; + 0FDD07A11C6F8E0E006FF70E /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -257,13 +245,6 @@ class PbxprojectTemplate ); runOnlyForDeploymentPostprocessing = 0; }; - AF9F83E61A5F0D21004B62C0 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -271,8 +252,8 @@ class PbxprojectTemplate isa = PBXGroup; children = ( AF9F83CE1A5F0D21004B62C0 /* {{{name}}} */, - AF9F83EC1A5F0D21004B62C0 /* {{{name}}}Tests */, AF9F83CD1A5F0D21004B62C0 /* Products */, + 0FDD07A11C6F8E0E006FF70E /* LaunchScreen.storyboard */, ); sourceTree = ""; }; @@ -280,7 +261,6 @@ class PbxprojectTemplate isa = PBXGroup; children = ( AF9F83CC1A5F0D21004B62C0 /* {{{name}}}.app */, - AF9F83E91A5F0D21004B62C0 /* {{{name}}}Tests.xctest */, ); name = Products; sourceTree = ""; @@ -288,6 +268,7 @@ class PbxprojectTemplate AF9F83CE1A5F0D21004B62C0 /* {{{name}}} */ = { isa = PBXGroup; children = ( + 0F4688401FDF8748004F34D4 /* assets */, """ # Reference all known files for file in files do add """ @@ -299,32 +280,6 @@ class PbxprojectTemplate path = {{{name}}}; sourceTree = ""; }; - AF9F83CF1A5F0D21004B62C0 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - AF9F83D01A5F0D21004B62C0 /* Info.plist */, - AF9F83D11A5F0D21004B62C0 /* main.m */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; - AF9F83EC1A5F0D21004B62C0 /* {{{name}}}Tests */ = { - isa = PBXGroup; - children = ( - AF9F83EF1A5F0D21004B62C0 /* {{{name}}}Tests.m */, - AF9F83ED1A5F0D21004B62C0 /* Supporting Files */, - ); - path = {{{name}}}Tests; - sourceTree = ""; - }; - AF9F83ED1A5F0D21004B62C0 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - AF9F83EE1A5F0D21004B62C0 /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -345,24 +300,6 @@ class PbxprojectTemplate productReference = AF9F83CC1A5F0D21004B62C0 /* {{{name}}}.app */; productType = "com.apple.product-type.application"; }; - AF9F83E81A5F0D21004B62C0 /* {{{name}}}Tests */ = { - isa = PBXNativeTarget; - buildConfigurationList = AF9F83F61A5F0D21004B62C0 /* Build configuration list for PBXNativeTarget "{{{name}}}Tests" */; - buildPhases = ( - AF9F83E51A5F0D21004B62C0 /* Sources */, - AF9F83E61A5F0D21004B62C0 /* Frameworks */, - AF9F83E71A5F0D21004B62C0 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - AF9F83EB1A5F0D21004B62C0 /* PBXTargetDependency */, - ); - name = {{{name}}}Tests; - productName = {{{name}}}Tests; - productReference = AF9F83E91A5F0D21004B62C0 /* {{{name}}}Tests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -374,10 +311,6 @@ class PbxprojectTemplate AF9F83CB1A5F0D21004B62C0 = { CreatedOnToolsVersion = 6.1.1; }; - AF9F83E81A5F0D21004B62C0 = { - CreatedOnToolsVersion = 6.1.1; - TestTargetID = AF9F83CB1A5F0D21004B62C0; - }; }; }; buildConfigurationList = AF9F83C71A5F0D21004B62C0 /* Build configuration list for PBXProject "{{{name}}}" */; @@ -394,7 +327,6 @@ class PbxprojectTemplate projectRoot = ""; targets = ( AF9F83CB1A5F0D21004B62C0 /* {{{name}}} */, - AF9F83E81A5F0D21004B62C0 /* {{{name}}}Tests */, ); }; /* End PBXProject section */ @@ -411,13 +343,8 @@ class PbxprojectTemplate """ add """ - ); - runOnlyForDeploymentPostprocessing = 0; - }; - AF9F83E71A5F0D21004B62C0 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( + 0FDD07A21C6F8E0E006FF70E /* LaunchScreen.storyboard in Resources */, + 0F4688411FDF8748004F34D4 /* assets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -437,43 +364,8 @@ class PbxprojectTemplate ); runOnlyForDeploymentPostprocessing = 0; }; - AF9F83E51A5F0D21004B62C0 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - AF9F83F01A5F0D21004B62C0 /* {{{name}}}Tests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXTargetDependency section */ - AF9F83EB1A5F0D21004B62C0 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = AF9F83CB1A5F0D21004B62C0 /* {{{name}}} */; - targetProxy = AF9F83EA1A5F0D21004B62C0 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin PBXVariantGroup section */ - AF9F83DD1A5F0D21004B62C0 /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - AF9F83DE1A5F0D21004B62C0 /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; - AF9F83E21A5F0D21004B62C0 /* LaunchScreen.xib */ = { - isa = PBXVariantGroup; - children = ( - AF9F83E31A5F0D21004B62C0 /* Base */, - ); - name = LaunchScreen.xib; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - /* Begin XCBuildConfiguration section */ AF9F83F11A5F0D21004B62C0 /* Debug */ = { isa = XCBuildConfiguration; @@ -539,6 +431,7 @@ class PbxprojectTemplate ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = {{{name}}}/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + OTHER_CFLAGS = "{{{cflags.escape_to_c}}}"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -549,44 +442,11 @@ class PbxprojectTemplate ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = {{{name}}}/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + OTHER_CFLAGS = "{{{cflags.escape_to_c}}}"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; }; - AF9F83F71A5F0D21004B62C0 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - INFOPLIST_FILE = {{{name}}}Tests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/{{{name}}}.app/{{{name}}}"; - }; - name = Debug; - }; - AF9F83F81A5F0D21004B62C0 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - INFOPLIST_FILE = {{{name}}}Tests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/{{{name}}}.app/{{{name}}}"; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -607,14 +467,6 @@ class PbxprojectTemplate ); defaultConfigurationIsVisible = 0; }; - AF9F83F61A5F0D21004B62C0 /* Build configuration list for PBXNativeTarget "{{{name}}}Tests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - AF9F83F71A5F0D21004B62C0 /* Debug */, - AF9F83F81A5F0D21004B62C0 /* Release */, - ); - defaultConfigurationIsVisible = 0; - }; /* End XCConfigurationList section */ }; rootObject = AF9F83C41A5F0D21004B62C0 /* Project object */; @@ -661,7 +513,7 @@ class PlistTemplate CFBundleShortVersionString {{{short_version}}} CFBundleSignature - \\?\\?\\?\\? + ???? CFBundleVersion {{{bundle_version}}} LSRequiresIPhoneOS @@ -683,8 +535,85 @@ class PlistTemplate UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + + UILaunchStoryboardName + LaunchScreen + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + """ end end + +# Template for the loading screen to generate `LaunchScreen.storyboard` +class LaunchScreenStoryboardTemplate + super Template + + # Large text to show in the center of the loading screen + var title = "" is writable + + # Text to show at the bottom of the loading screen + var subtitle = "" is writable + + # TODO make this more customizable by moving the subviews block as an attribute + # or by allowing to pass a custom file from the ` res/` folder. + + redef fun rendering + do + add """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +""" + end +end