Skip to content

Commit

Permalink
Revert "WIP: Add CordovaPluginsSPM to template"
Browse files Browse the repository at this point in the history
This reverts commit 7ae36ee.
  • Loading branch information
jcesarmobile committed Apr 29, 2024
1 parent f643968 commit ca8c1e2
Show file tree
Hide file tree
Showing 7 changed files with 267 additions and 241 deletions.
43 changes: 43 additions & 0 deletions lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class ProjectCreator {
create () {
this.provideProjectTemplate();
this.provideCordovaJs();
this.provideCordovaLib();
this.provideBuildScripts();
this.expandTokens();
}
Expand All @@ -91,6 +92,11 @@ class ProjectCreator {
);
}

provideCordovaLib () {
this.copyOrLinkCordovaLib();
this.configureCordovaLibPath();
}

provideBuildScripts () {
const srcScriptsDir = path.join(ROOT, 'templates', 'cordova');
const destScriptsDir = this.projectPath('cordova');
Expand All @@ -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 = "<group>";');

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(
Expand Down
43 changes: 0 additions & 43 deletions templates/project/CordovaPluginsSPM/Package.swift

This file was deleted.

This file was deleted.

134 changes: 100 additions & 34 deletions templates/project/__PROJECT_NAME__.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -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 */; };
Expand All @@ -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;
Expand All @@ -38,8 +80,9 @@
0207DA571B56EA530066E2B4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
1D3623240D0F684500981E51 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
1D3623250D0F684500981E51 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
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 = "<group>"; };
301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = CordovaLib/CordovaLib.xcodeproj; sourceTree = "<group>"; };
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 = "<group>"; };
302D95EF14D2391D003F00A1 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = "<group>"; };
Expand All @@ -54,15 +97,15 @@
EB87FDF31871DA8E0020F90C /* www */ = {isa = PBXFileReference; lastKnownFileType = folder; name = www; path = ../../www; sourceTree = "<group>"; };
EB87FDF41871DAF40020F90C /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = ../../config.xml; sourceTree = "<group>"; };
ED33DF2A687741AEAF9F8254 /* Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bridging-Header.h"; sourceTree = "<group>"; };
F840E1F0165FE0F500CFE078 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = __PROJECT_NAME__/config.xml; sourceTree = "<group>"; };
F840E1F0165FE0F500CFE078 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = "__PROJECT_NAME__/config.xml"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
1D60588F0D05DD3D006BFB54 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2F4DE0C52BDD172A00B7D5E7 /* CordovaPluginsSPM in Frameworks */,
301BF552109A68D80062928A /* libCordova.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -84,6 +127,7 @@
3047A50E1AB8057F00498E2A /* config */,
EB87FDF31871DA8E0020F90C /* www */,
EB87FDF11871DA420020F90C /* Staging */,
301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */,
29B97315FDCFA39411CA2CEA /* __PROJECT_NAME__ */,
307C750510C5A3420062BCA9 /* Plugins */,
29B97317FDCFA39411CA2CEA /* Resources */,
Expand All @@ -109,15 +153,15 @@
1D3623250D0F684500981E51 /* AppDelegate.m */,
29B97316FDCFA39411CA2CEA /* main.m */,
);
path = __PROJECT_NAME__;
name = "__PROJECT_NAME__";
path = "__PROJECT_NAME__";
sourceTree = "<group>";
};
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
);
children = ();
name = Resources;
path = __PROJECT_NAME__/Resources;
path = "__PROJECT_NAME__/Resources";
sourceTree = "<group>";
};
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
Expand All @@ -127,6 +171,15 @@
name = Frameworks;
sourceTree = "<group>";
};
301BF52E109A57CC0062928A /* Products */ = {
isa = PBXGroup;
children = (
301BF535109A57CC0062928A /* libCordova.a */,
907D8124214C687600058A10 /* Cordova.framework */,
);
name = Products;
sourceTree = "<group>";
};
3047A50E1AB8057F00498E2A /* config */ = {
isa = PBXGroup;
children = (
Expand All @@ -142,7 +195,7 @@
children = (
);
name = Plugins;
path = __PROJECT_NAME__/Plugins;
path = "__PROJECT_NAME__/Plugins";
sourceTree = SOURCE_ROOT;
};
EB87FDF11871DA420020F90C /* Staging */ = {
Expand All @@ -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";
};
Expand All @@ -184,6 +235,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1130;
TargetAttributes = {
1D6058900D05DD3D006BFB54 = {
Expand All @@ -200,17 +252,37 @@
Base,
);
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
packageReferences = (
2F4DE0C32BDD172A00B7D5E7 /* XCLocalSwiftPackageReference "CordovaPluginsSPM" */,
);
projectDirPath = "";
projectReferences = (
{
ProductGroup = 301BF52E109A57CC0062928A /* Products */;
ProjectRef = 301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */;
},
);
projectRoot = "";
targets = (
1D6058900D05DD3D006BFB54 /* __PROJECT_NAME__ */,
);
};
/* 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;
Expand Down Expand Up @@ -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;
Expand All @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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 */;
}
Loading

0 comments on commit ca8c1e2

Please sign in to comment.