From ca8c1e2eda06ef4b9d438ee200e5ffd797eba654 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Mon, 29 Apr 2024 02:11:43 +0200 Subject: [PATCH] Revert "WIP: Add CordovaPluginsSPM to template" This reverts commit 7ae36eeb56fba5beea9d693db855fb48631285be. --- lib/create.js | 43 +++ .../project/CordovaPluginsSPM/Package.swift | 43 --- .../CordovaPluginsSPM/CordovaPluginsSPM.swift | 1 - .../project.pbxproj | 134 ++++++--- .../contents.xcworkspacedata | 18 ++ .../xcshareddata/swiftpm/Package.resolved | 15 -- .../AppIcon.appiconset/Contents.json | 254 ++++++++---------- 7 files changed, 267 insertions(+), 241 deletions(-) delete mode 100644 templates/project/CordovaPluginsSPM/Package.swift delete mode 100644 templates/project/CordovaPluginsSPM/Sources/CordovaPluginsSPM/CordovaPluginsSPM.swift delete mode 100644 templates/project/__PROJECT_NAME__.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/lib/create.js b/lib/create.js index 111b958c6..5e0f630e6 100755 --- a/lib/create.js +++ b/lib/create.js @@ -71,6 +71,7 @@ class ProjectCreator { create () { this.provideProjectTemplate(); this.provideCordovaJs(); + this.provideCordovaLib(); this.provideBuildScripts(); this.expandTokens(); } @@ -91,6 +92,11 @@ class ProjectCreator { ); } + provideCordovaLib () { + this.copyOrLinkCordovaLib(); + this.configureCordovaLibPath(); + } + provideBuildScripts () { const srcScriptsDir = path.join(ROOT, 'templates', 'cordova'); const destScriptsDir = this.projectPath('cordova'); @@ -116,6 +122,43 @@ class ProjectCreator { } } + configureCordovaLibPath () { + // CordovaLib could be a symlink, so we resolve it + const cdvLibRealPath = fs.realpathSync(this.projectPath('CordovaLib')); + + const cdvLibXcodeAbsPath = path.join(cdvLibRealPath, 'CordovaLib.xcodeproj'); + let cdvLibXcodePath = path.relative(this.project.path, cdvLibXcodeAbsPath); + + if (path.sep !== path.posix.sep) { + // If the Cordova project is being created on Windows, we need to + // make sure the Xcode project file uses POSIX-style paths or else + // Xcode considers it invalid + cdvLibXcodePath = cdvLibXcodePath.replace(path.sep, path.posix.sep); + } + + // Replace magic line in project.pbxproj + const pbxprojPath = this.projectPath('__PROJECT_NAME__.xcodeproj', 'project.pbxproj'); + transformFileContents(pbxprojPath, contents => { + const regex = /(.+CordovaLib.xcodeproj.+PBXFileReference.+wrapper.pb-project.+)(path = .+?;)(.*)(sourceTree.+;)(.+)/; + const line = contents.split(/\r?\n/) + .find(l => regex.test(l)); + + if (!line) { + throw new Error(`Entry not found in project file for sub-project: ${cdvLibXcodePath}`); + } + + let newLine = line + .replace(/path = .+?;/, `path = ${cdvLibXcodePath};`) + .replace(/sourceTree.+?;/, 'sourceTree = "";'); + + if (!newLine.match('name')) { + newLine = newLine.replace('path = ', 'name = CordovaLib.xcodeproj; path = '); + } + + return contents.replace(line, newLine); + }); + } + expandTokensInFileContents () { // Expand __PROJECT_ID__ token in file contents transformFileContents( diff --git a/templates/project/CordovaPluginsSPM/Package.swift b/templates/project/CordovaPluginsSPM/Package.swift deleted file mode 100644 index 5e864f7fb..000000000 --- a/templates/project/CordovaPluginsSPM/Package.swift +++ /dev/null @@ -1,43 +0,0 @@ -// swift-tools-version:5.5 - -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - */ - -import PackageDescription - -let package = Package( - name: "CordovaPluginsSPM", - platforms: [.iOS(.v11)], - products: [ - .library( - name: "CordovaPluginsSPM", - targets: ["CordovaPluginsSPM"]) - ], - dependencies: [ - .package(url: "https://github.com/apache/cordova-ios.git", branch: "master") - ], - targets: [ - .target( - name: "CordovaPluginsSPM", - dependencies: [ - .product(name: "CordovaLib", package: "cordova-ios") - ] - ) - ] -) \ No newline at end of file diff --git a/templates/project/CordovaPluginsSPM/Sources/CordovaPluginsSPM/CordovaPluginsSPM.swift b/templates/project/CordovaPluginsSPM/Sources/CordovaPluginsSPM/CordovaPluginsSPM.swift deleted file mode 100644 index 900bcf05b..000000000 --- a/templates/project/CordovaPluginsSPM/Sources/CordovaPluginsSPM/CordovaPluginsSPM.swift +++ /dev/null @@ -1 +0,0 @@ -public let isCordovaApp = true \ No newline at end of file diff --git a/templates/project/__PROJECT_NAME__.xcodeproj/project.pbxproj b/templates/project/__PROJECT_NAME__.xcodeproj/project.pbxproj index cd4781d50..b703cacfc 100755 --- a/templates/project/__PROJECT_NAME__.xcodeproj/project.pbxproj +++ b/templates/project/__PROJECT_NAME__.xcodeproj/project.pbxproj @@ -1,16 +1,34 @@ // !$*UTF8*$! +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ { archiveVersion = 1; classes = { }; - objectVersion = 60; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ 0207DA581B56EA530066E2B4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0207DA571B56EA530066E2B4 /* Assets.xcassets */; }; 1D3623260D0F684500981E51 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* AppDelegate.m */; }; 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; - 2F4DE0C52BDD172A00B7D5E7 /* CordovaPluginsSPM in Frameworks */ = {isa = PBXBuildFile; productRef = 2F4DE0C42BDD172A00B7D5E7 /* CordovaPluginsSPM */; }; + 301BF552109A68D80062928A /* libCordova.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF535109A57CC0062928A /* libCordova.a */; settings = {ATTRIBUTES = (Required, ); }; }; 302D95F114D2391D003F00A1 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 302D95EF14D2391D003F00A1 /* MainViewController.m */; }; 302D95F214D2391D003F00A1 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 302D95F014D2391D003F00A1 /* MainViewController.xib */; }; 4E7CA2B6272ABB0D00177EF9 /* config.xml in Copy Staging Resources */ = {isa = PBXBuildFile; fileRef = F840E1F0165FE0F500CFE078 /* config.xml */; }; @@ -19,6 +37,30 @@ 90B630EF2AECBBD0009EF368 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 90B630EE2AECBBD0009EF368 /* PrivacyInfo.xcprivacy */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 301BF534109A57CC0062928A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = D2AAC07E0554694100DB518D; + remoteInfo = CordovaLib; + }; + 301BF550109A68C00062928A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = D2AAC07D0554694100DB518D; + remoteInfo = CordovaLib; + }; + 907D8123214C687600058A10 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = C0C01EB21E3911D50056E6CB; + remoteInfo = Cordova; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXCopyFilesBuildPhase section */ 857339E32710CC9700A1C74C /* Copy Staging Resources */ = { isa = PBXCopyFilesBuildPhase; @@ -38,8 +80,9 @@ 0207DA571B56EA530066E2B4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 1D3623240D0F684500981E51 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 1D3623250D0F684500981E51 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 1D6058910D05DD3D006BFB54 /* __PROJECT_NAME__.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = __PROJECT_NAME__.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1D6058910D05DD3D006BFB54 /* __PROJECT_NAME__.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "__PROJECT_NAME__.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = CordovaLib/CordovaLib.xcodeproj; sourceTree = ""; }; 301BF56E109A69640062928A /* www */ = {isa = PBXFileReference; lastKnownFileType = folder; path = www; sourceTree = SOURCE_ROOT; }; 302D95EE14D2391D003F00A1 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = ""; }; 302D95EF14D2391D003F00A1 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = ""; }; @@ -54,7 +97,7 @@ EB87FDF31871DA8E0020F90C /* www */ = {isa = PBXFileReference; lastKnownFileType = folder; name = www; path = ../../www; sourceTree = ""; }; EB87FDF41871DAF40020F90C /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = ../../config.xml; sourceTree = ""; }; ED33DF2A687741AEAF9F8254 /* Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bridging-Header.h"; sourceTree = ""; }; - F840E1F0165FE0F500CFE078 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = __PROJECT_NAME__/config.xml; sourceTree = ""; }; + F840E1F0165FE0F500CFE078 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = "__PROJECT_NAME__/config.xml"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -62,7 +105,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 2F4DE0C52BDD172A00B7D5E7 /* CordovaPluginsSPM in Frameworks */, + 301BF552109A68D80062928A /* libCordova.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -84,6 +127,7 @@ 3047A50E1AB8057F00498E2A /* config */, EB87FDF31871DA8E0020F90C /* www */, EB87FDF11871DA420020F90C /* Staging */, + 301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */, 29B97315FDCFA39411CA2CEA /* __PROJECT_NAME__ */, 307C750510C5A3420062BCA9 /* Plugins */, 29B97317FDCFA39411CA2CEA /* Resources */, @@ -109,15 +153,15 @@ 1D3623250D0F684500981E51 /* AppDelegate.m */, 29B97316FDCFA39411CA2CEA /* main.m */, ); - path = __PROJECT_NAME__; + name = "__PROJECT_NAME__"; + path = "__PROJECT_NAME__"; sourceTree = ""; }; 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; - children = ( - ); + children = (); name = Resources; - path = __PROJECT_NAME__/Resources; + path = "__PROJECT_NAME__/Resources"; sourceTree = ""; }; 29B97323FDCFA39411CA2CEA /* Frameworks */ = { @@ -127,6 +171,15 @@ name = Frameworks; sourceTree = ""; }; + 301BF52E109A57CC0062928A /* Products */ = { + isa = PBXGroup; + children = ( + 301BF535109A57CC0062928A /* libCordova.a */, + 907D8124214C687600058A10 /* Cordova.framework */, + ); + name = Products; + sourceTree = ""; + }; 3047A50E1AB8057F00498E2A /* config */ = { isa = PBXGroup; children = ( @@ -142,7 +195,7 @@ children = ( ); name = Plugins; - path = __PROJECT_NAME__/Plugins; + path = "__PROJECT_NAME__/Plugins"; sourceTree = SOURCE_ROOT; }; EB87FDF11871DA420020F90C /* Staging */ = { @@ -169,12 +222,10 @@ buildRules = ( ); dependencies = ( + 301BF551109A68C00062928A /* PBXTargetDependency */, ); - name = __PROJECT_NAME__; - packageProductDependencies = ( - 2F4DE0C42BDD172A00B7D5E7 /* CordovaPluginsSPM */, - ); - productName = __PROJECT_NAME__; + name = "__PROJECT_NAME__"; + productName = "__PROJECT_NAME__"; productReference = 1D6058910D05DD3D006BFB54 /* __PROJECT_NAME__.app */; productType = "com.apple.product-type.application"; }; @@ -184,6 +235,7 @@ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; attributes = { + BuildIndependentTargetsInParallel = YES; LastUpgradeCheck = 1130; TargetAttributes = { 1D6058900D05DD3D006BFB54 = { @@ -200,10 +252,13 @@ Base, ); mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; - packageReferences = ( - 2F4DE0C32BDD172A00B7D5E7 /* XCLocalSwiftPackageReference "CordovaPluginsSPM" */, - ); projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 301BF52E109A57CC0062928A /* Products */; + ProjectRef = 301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */; + }, + ); projectRoot = ""; targets = ( 1D6058900D05DD3D006BFB54 /* __PROJECT_NAME__ */, @@ -211,6 +266,23 @@ }; /* End PBXProject section */ +/* Begin PBXReferenceProxy section */ + 301BF535109A57CC0062928A /* libCordova.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libCordova.a; + remoteRef = 301BF534109A57CC0062928A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 907D8124214C687600058A10 /* Cordova.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = Cordova.framework; + remoteRef = 907D8123214C687600058A10 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + /* Begin PBXResourcesBuildPhase section */ 1D60588D0D05DD3D006BFB54 /* Resources */ = { isa = PBXResourcesBuildPhase; @@ -238,6 +310,14 @@ }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 301BF551109A68C00062928A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = CordovaLib; + targetProxy = 301BF550109A68C00062928A /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin XCBuildConfiguration section */ 1D6058940D05DD3E006BFB54 /* Debug */ = { isa = XCBuildConfiguration; @@ -257,7 +337,7 @@ INFOPLIST_FILE = "__PROJECT_NAME__/__PROJECT_NAME__-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = __PROJECT_ID__; + PRODUCT_BUNDLE_IDENTIFIER = "__PROJECT_ID__"; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; TARGETED_DEVICE_FAMILY = "1,2"; @@ -281,7 +361,7 @@ INFOPLIST_FILE = "__PROJECT_NAME__/__PROJECT_NAME__-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = __PROJECT_ID__; + PRODUCT_BUNDLE_IDENTIFIER = "__PROJECT_ID__"; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; TARGETED_DEVICE_FAMILY = "1,2"; @@ -403,20 +483,6 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ - -/* Begin XCLocalSwiftPackageReference section */ - 2F4DE0C32BDD172A00B7D5E7 /* XCLocalSwiftPackageReference "CordovaPluginsSPM" */ = { - isa = XCLocalSwiftPackageReference; - relativePath = CordovaPluginsSPM; - }; -/* End XCLocalSwiftPackageReference section */ - -/* Begin XCSwiftPackageProductDependency section */ - 2F4DE0C42BDD172A00B7D5E7 /* CordovaPluginsSPM */ = { - isa = XCSwiftPackageProductDependency; - productName = CordovaPluginsSPM; - }; -/* End XCSwiftPackageProductDependency section */ }; rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; } diff --git a/templates/project/__PROJECT_NAME__.xcworkspace/contents.xcworkspacedata b/templates/project/__PROJECT_NAME__.xcworkspace/contents.xcworkspacedata index a8b8bb4ba..48a0b2724 100644 --- a/templates/project/__PROJECT_NAME__.xcworkspace/contents.xcworkspacedata +++ b/templates/project/__PROJECT_NAME__.xcworkspace/contents.xcworkspacedata @@ -1,4 +1,22 @@ +