Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cli/src/ios/update.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { copy, remove, pathExists, readFile, realpath, writeFile } from 'fs-extra';
import { basename, dirname, join, relative } from 'path';
import { major } from 'semver';
import { major, prerelease } from 'semver';

import c from '../colors';
import { checkPlatformVersions, getCapacitorPackageVersion, runTask } from '../common';
Expand Down Expand Up @@ -70,11 +70,13 @@ async function updatePluginFiles(config: Config, plugins: Plugin[], deployment:
const version = content.match(regex)?.[1];
const majorCapVersion = major(iosPlatformVersion);
if (version && major(version) != majorCapVersion) {
const preCapVersion = prerelease(iosPlatformVersion);
const forceVersion = preCapVersion ? iosPlatformVersion : `${majorCapVersion}.0.0`;
Comment on lines +73 to +74

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also makes the change for dev and nightly builds of capacitor, which I'm unsure if we want that since those aren't available as capacitor-swift-pm versions. We could check the output of prerelease and check if it contains alpha, beta, or rc, but would like to get your thoughts if such a thing is useful to have or not.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should start publishing those then, since we already set the exact version in ios/App/CapApp-SPM/Package.swift, setting the Capacitor dependency value on the installed @capacitor/ios dependency, so that functionality is already broken.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point then, it doesn't impact solely this PR; I tested it with a capacitor app and seems to work fine! Approving it ✅

content = setAllStringIn(
content,
`url: "https://github.com/ionic-team/capacitor-swift-pm.git",`,
`)`,
` from: "${majorCapVersion}.0.0"`,
` from: "${forceVersion}"`,
);
await writeFile(packageSwiftPath, content);
logger.warn(`${plugin.id} is built for Capacitor ${major(version)}, it might cause issues`);
Expand Down
Loading