Skip to content

Commit

Permalink
[WIP] feat(spm): Support linked cordova-ios
Browse files Browse the repository at this point in the history
TODO: Unit tests
  • Loading branch information
dpogue committed Jan 21, 2025
1 parent d02c9ab commit b62809b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/SwiftPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const fs = require('node:fs');
const path = require('node:path');
const CordovaError = require('cordova-common').CordovaError;

const ROOT = path.join(__dirname, '..');

class SwiftPackage {
constructor (projectRoot) {
this.root = projectRoot;
Expand Down Expand Up @@ -49,8 +51,10 @@ package.targets.first?.dependencies.append(.product(name: "${plugin.id}", packag
const pkgSwiftPath = path.join(this.root, 'packages', plugin.id, 'Package.swift');
const pkg_fd = fs.openSync(pkgSwiftPath, 'r+');

const cordovaPath = path.relative(pluginPath, path.join(this.root, 'packages', 'cordova-ios'));
// TODO: Detect if cordova-ios was linked and use that path
let cordovaPath = path.relative(pluginPath, path.join(this.root, 'packages', 'cordova-ios'));
if (!fs.existsSync(cordovaPath)) {
cordovaPath = path.relative(pluginPath, ROOT);
}

let packageContent = fs.readFileSync(pkg_fd, 'utf8');
packageContent = packageContent.replace(/package\(.+cordova-ios.+\)/gm, `package(name: "cordova-ios", path: "${cordovaPath.replaceAll(path.sep, path.posix.sep)}")`);
Expand Down

0 comments on commit b62809b

Please sign in to comment.