diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 0000000000..034b3b1708 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,39 @@ +[default] +# Ignore patterns that match commit hashes and Git-related identifiers +extend-ignore-re = [ + # Git commit hashes in parentheses: (7553ede), (88d0ded), etc. + "\\([a-f0-9]{7,40}\\)", + # Git commit hashes in square brackets: [7553ede], [88d0ded], etc. + "\\[[a-f0-9]{7,40}\\]", + # Full GitHub commit URLs + "github\\.com/[^/]+/[^/]+/commit/[a-f0-9]{7,40}", + # Commit hash at end of markdown links: ...commit/abcd123) + "commit/[a-f0-9]{7,40}\\)", +] + +[files] +extend-exclude = [ + # Exclude lock files + "package-lock.json", + "yarn.lock", + "pnpm-lock.yaml", + # Exclude build artifacts + "dist/", + "build/", + "*.min.js", + # Exclude node_modules + "node_modules/", + # Exclude Xcode project files that contain hex identifiers - these files have + # automatically generated hex IDs that look like typos but must not be changed + "**/project.pbxproj", + "**/*.xcscheme", + "**/*.storyboard", + # Exclude all CHANGELOG files - they contain commit hashes and historical text + # that should not be modified by typo fixes + "CHANGELOG.md", + "*/CHANGELOG.md", +] + +[default.extend-words] +# `thn` is a real MIME type in ios/.../WebViewAssetHandler.swift, not a typo of "then". +thn = "thn" diff --git a/android/capacitor/src/main/java/com/getcapacitor/cordova/MockCordovaWebViewImpl.java b/android/capacitor/src/main/java/com/getcapacitor/cordova/MockCordovaWebViewImpl.java index 1115429d7b..5022948433 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/cordova/MockCordovaWebViewImpl.java +++ b/android/capacitor/src/main/java/com/getcapacitor/cordova/MockCordovaWebViewImpl.java @@ -182,8 +182,8 @@ public void handleDestroy() { @Deprecated @Override - public void sendJavascript(String statememt) { - nativeToJsMessageQueue.addJavaScript(statememt); + public void sendJavascript(String statement) { + nativeToJsMessageQueue.addJavaScript(statement); } public void eval(final String js, final ValueCallback callback) { diff --git a/cli/src/android/update.ts b/cli/src/android/update.ts index 16e8c4935f..a7c059d8fd 100644 --- a/cli/src/android/update.ts +++ b/cli/src/android/update.ts @@ -147,10 +147,10 @@ export async function installGradlePlugins( const settingsPath = config.android.platformDirAbs; const dependencyPath = config.android.appDirAbs; - const relativeCapcitorAndroidPath = convertToUnixPath(relative(settingsPath, capacitorAndroidPath)); + const relativeCapacitorAndroidPath = convertToUnixPath(relative(settingsPath, capacitorAndroidPath)); const settingsLines = `// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN include ':capacitor-android' -project(':capacitor-android').projectDir = new File('${relativeCapcitorAndroidPath}') +project(':capacitor-android').projectDir = new File('${relativeCapacitorAndroidPath}') ${capacitorPlugins .map((p) => { if (!p.android) { diff --git a/cli/src/declarations.ts b/cli/src/declarations.ts index 6c8645406d..d798cd90cc 100644 --- a/cli/src/declarations.ts +++ b/cli/src/declarations.ts @@ -597,7 +597,7 @@ export interface CapacitorConfig { * Configure the local scheme on Android. * * Custom schemes on Android are unable to change the URL path as of Webview 117. Changing this value from anything other than `http` or `https` can result in your - * application unable to resolve routing. If you must change this for some reason, consider using a hash-based url strategy, but there are no guarentees that this + * application unable to resolve routing. If you must change this for some reason, consider using a hash-based url strategy, but there are no guarantees that this * will continue to work long term as allowing non-standard schemes to modify query parameters and url fragments is only allowed for compatibility reasons. * https://ionic.io/blog/capacitor-android-customscheme-issue-with-chrome-117 * diff --git a/cli/src/definitions.ts b/cli/src/definitions.ts index 2df6398e97..cc0aa46a38 100644 --- a/cli/src/definitions.ts +++ b/cli/src/definitions.ts @@ -158,7 +158,7 @@ export interface FrameworkConfig { /** * Specific UI libraries (Ionic) and higher-level frameworks (NextJs/Gatsby) * should be prioritorized over a more generic framework like React/Angular/Vue. - * Lower the priorty number the more important it is (1 has more priority over 2). + * Lower the priority number the more important it is (1 has more priority over 2). * This helps to make sure a specific framework like "NextJs" is chosen before * the more generic "React". */ diff --git a/cli/src/ios/doctor.ts b/cli/src/ios/doctor.ts index 87bb3911f5..22f4e93e9c 100644 --- a/cli/src/ios/doctor.ts +++ b/cli/src/ios/doctor.ts @@ -16,7 +16,7 @@ export async function doctorIOS(config: Config): Promise { // check plugins versions // check native project deps are up-to-date === npm install // check if npm install was updated - // check online datebase of common errors + // check online database of common errors // check if www folder is empty (index.html does not exist) try { await check([() => checkWebDir(config), checkXcode, ...(await getCommonChecks(config))]); diff --git a/cli/src/sysconfig.ts b/cli/src/sysconfig.ts index 487095404b..b2557db3b1 100644 --- a/cli/src/sysconfig.ts +++ b/cli/src/sysconfig.ts @@ -24,7 +24,7 @@ export interface SystemConfig { readonly telemetry?: boolean; /** - * Wheter the user choose to signup or not. + * Whether the user chooses to sign up or not. * * If undefined, the prompt has not been shown. */ diff --git a/cli/src/tasks/migrate.ts b/cli/src/tasks/migrate.ts index b2c419c080..d9c6837230 100644 --- a/cli/src/tasks/migrate.ts +++ b/cli/src/tasks/migrate.ts @@ -403,12 +403,12 @@ async function getAndroidVariablesAndClasspaths(config: Config) { } deleteFolderRecursive(tempAndroidTemplateFolder); - const firstIndxOfCATBGV = buildGradleFile.indexOf(`classpath 'com.android.tools.build:gradle:`) + 42; - const firstIndxOfCGGGS = buildGradleFile.indexOf(`com.google.gms:google-services:`) + 31; + const firstIndexOfCATBGV = buildGradleFile.indexOf(`classpath 'com.android.tools.build:gradle:`) + 42; + const firstIndexOfCGGGS = buildGradleFile.indexOf(`com.google.gms:google-services:`) + 31; const comAndroidToolsBuildGradleVersion = - '' + buildGradleFile.substring(firstIndxOfCATBGV, buildGradleFile.indexOf("'", firstIndxOfCATBGV)); + '' + buildGradleFile.substring(firstIndexOfCATBGV, buildGradleFile.indexOf("'", firstIndexOfCATBGV)); const comGoogleGmsGoogleServices = - '' + buildGradleFile.substring(firstIndxOfCGGGS, buildGradleFile.indexOf("'", firstIndxOfCGGGS)); + '' + buildGradleFile.substring(firstIndexOfCGGGS, buildGradleFile.indexOf("'", firstIndexOfCGGGS)); const variablesGradleAsJSON = JSON.parse( variablesGradleFile diff --git a/cli/src/util/emoji.ts b/cli/src/util/emoji.ts index f86b7166b6..9791dad0aa 100644 --- a/cli/src/util/emoji.ts +++ b/cli/src/util/emoji.ts @@ -1,4 +1,4 @@ -// Emoji falback, right now just uses fallback on windows, +// Emoji fallback, right now just uses fallback on windows, // but could expand to be more sophisticated to allow emoji // on Hyper term on windows, for example. export const emoji = (x: string, fallback: string): string => { diff --git a/cli/src/util/spm.ts b/cli/src/util/spm.ts index 3e2e515293..7aa3f95076 100644 --- a/cli/src/util/spm.ts +++ b/cli/src/util/spm.ts @@ -1,4 +1,4 @@ -import { pathExists, existsSync, readFileSync, writeFileSync, remove, move, mkdtemp } from 'fs-extra'; +import { ensureSymlink, pathExists, existsSync, readFileSync, writeFileSync, remove, move, mkdtemp } from 'fs-extra'; import { tmpdir } from 'os'; import { join, relative, resolve } from 'path'; import type { PlistObject } from 'plist'; @@ -11,7 +11,8 @@ import { fatal } from '../errors'; import { getMajoriOSVersion } from '../ios/common'; import { logger } from '../log'; import type { Plugin } from '../plugin'; -import { getPluginType, PluginType } from '../plugin'; +import { getPlatformElement, getPluginPlatform, getPluginType, PluginType } from '../plugin'; +import { convertToUnixPath } from '../util/fs'; import { runCommand } from '../util/subprocess'; export interface SwiftPlugin { @@ -52,14 +53,15 @@ export async function generatePackageFile(config: Config, plugins: Plugin[]): Pr export async function checkPluginsForPackageSwift(config: Config, plugins: Plugin[]): Promise { const iOSCapacitorPlugins = plugins.filter((p) => getPluginType(p, 'ios') === PluginType.Core); - const packageSwiftPluginList = await pluginsWithPackageSwift(iOSCapacitorPlugins); - if (plugins.length == packageSwiftPluginList.length) { - logger.debug(`Found ${plugins.length} iOS plugins, ${packageSwiftPluginList.length} have a Package.swift file`); - logger.info('All plugins have a Package.swift file and will be included in Package.swift'); + if (iOSCapacitorPlugins.length == packageSwiftPluginList.length) { + logger.debug( + `Found ${iOSCapacitorPlugins.length} Capacitor iOS plugins, ${packageSwiftPluginList.length} have a Package.swift file`, + ); + logger.info('All Capacitor plugins have a Package.swift file and will be included in Package.swift'); } else { - logger.warn('Some installed packages are not compatable with SPM'); + logger.warn('Some installed Capacitor plugins are not compatible with SPM'); } return packageSwiftPluginList; @@ -99,6 +101,7 @@ export async function generatePackageText(config: Config, plugins: Plugin[]): Pr const iosPlatformVersion = await getCapacitorPackageVersion(config, config.ios.name); const iosVersion = getMajoriOSVersion(config); const packageTraits = config.app.extConfig.experimental?.ios?.spm?.packageTraits ?? {}; + const packageOptions = config.app.extConfig.experimental?.ios?.spm?.packageOptions ?? {}; const swiftToolsVersion = config.app.extConfig.experimental?.ios?.spm?.swiftToolsVersion ?? '5.9'; let packageSwiftText = `// swift-tools-version: ${swiftToolsVersion} @@ -118,15 +121,34 @@ let package = Package( for (const plugin of plugins) { if (getPluginType(plugin, config.ios.name) === PluginType.Cordova) { - packageSwiftText += `,\n .package(name: "${plugin.name}", path: "../../capacitor-cordova-ios-plugins/sources/${plugin.name}")`; + const platformTag = getPluginPlatform(plugin, config.ios.name); + if (platformTag.$?.package) { + const relPath = convertToUnixPath(relative(config.ios.nativeXcodeProjDirAbs, plugin.rootPath)); + packageSwiftText += `,\n .package(name: "${plugin.id}", path: "${relPath}")`; + } else { + const sourceFiles = getPlatformElement(plugin, config.ios.name, 'source-file'); + const headerFiles = getPlatformElement(plugin, config.ios.name, 'header-file'); + if (sourceFiles.length === 0 && headerFiles.length === 0) { + continue; + } + packageSwiftText += `,\n .package(name: "${plugin.name}", path: "../../capacitor-cordova-ios-plugins/sources/${plugin.name}")`; + } } else { - const relPath = relative(config.ios.nativeXcodeProjDirAbs, plugin.rootPath); + const options = packageOptions[plugin.id]; + const symlink = options?.symlink; + const symlinkFolder = join('symlinks', plugin.name); + const relPath = symlink + ? symlinkFolder + : convertToUnixPath(relative(config.ios.nativeXcodeProjDirAbs, plugin.rootPath)); + if (symlink) { + await ensureSymlink(plugin.rootPath, resolve(config.ios.nativeProjectDirAbs, 'CapApp-SPM', symlinkFolder)); + } const traits = packageTraits[plugin.id]; const traitsSuffix = traits?.length ? `, traits: [${traits .map((t) => { // Any trait is written with quotes, with the exception of .defaults - return /^\.?defaults?$/i.test(t) ? '.defaults' : `"${t}"`; + return /^\\.?defaults?$/i.test(t) ? '.defaults' : `"${t}"`; }) .join(', ')}]` : ''; @@ -144,7 +166,28 @@ let package = Package( .product(name: "Cordova", package: "capacitor-swift-pm")`; for (const plugin of plugins) { - packageSwiftText += `,\n .product(name: "${plugin.ios?.name}", package: "${plugin.ios?.name}")`; + const aliases = Object.entries(packageOptions[plugin.id]?.moduleAliases ?? {}); + const aliasText = aliases?.length + ? `, moduleAliases: [${aliases + .map(([target, replacement]) => { + return `"${target}": "${replacement}"`; + }) + .join(', ')}]` + : ''; + let pluginText = `,\n .product(name: "${plugin.ios?.name}", package: "${plugin.ios?.name}"${aliasText})`; + if (getPluginType(plugin, config.ios.name) === PluginType.Cordova) { + const platformTag = getPluginPlatform(plugin, config.ios.name); + if (platformTag.$?.package) { + pluginText = `,\n .product(name: "${plugin.id}", package: "${plugin.id}")`; + } else { + const sourceFiles = getPlatformElement(plugin, config.ios.name, 'source-file'); + const headerFiles = getPlatformElement(plugin, config.ios.name, 'header-file'); + if (sourceFiles.length === 0 && headerFiles.length === 0) { + pluginText = ''; + } + } + } + packageSwiftText += pluginText; } packageSwiftText += ` @@ -199,12 +242,54 @@ export async function addInfoPlistDebugIfNeeded(config: Config): Promise { } } +export function hasSceneManifest(config: Config): boolean { + const infoPlist = resolve(config.ios.nativeTargetDirAbs, 'Info.plist'); + if (!existsSync(infoPlist)) { + return false; + } + const entries = parse(readFileSync(infoPlist, 'utf-8')) as PlistObject; + return entries['UIApplicationSceneManifest'] !== undefined; +} + +export async function addSceneManifestIfNeeded(config: Config): Promise { + type Mutable = { -readonly [P in keyof T]: T[P] }; + + const infoPlist = resolve(config.ios.nativeTargetDirAbs, 'Info.plist'); + + if (!existsSync(infoPlist)) { + logger.warn(infoPlist + ' not found.'); + return; + } + + const entries = parse(readFileSync(infoPlist, 'utf-8')) as Mutable; + + if (entries['UIApplicationSceneManifest'] !== undefined) { + logger.warn('Found UIApplicationSceneManifest in ' + infoPlist + ', skipping.'); + return; + } + + entries['UIApplicationSceneManifest'] = { + UIApplicationSupportsMultipleScenes: false, + UISceneConfigurations: { + UIWindowSceneSessionRoleApplication: [ + { + UISceneConfigurationName: 'Default Configuration', + UISceneDelegateClassName: '$(PRODUCT_MODULE_NAME).SceneDelegate', + UISceneStoryboardFile: 'Main', + }, + ], + }, + }; + + writeFileSync(infoPlist, build(entries)); +} + export async function checkSwiftToolsVersion(config: Config, version: string | undefined): Promise { if (!version) { return null; } - const swiftToolsVersionRegex = /^[0-9]+\.[0-9]+(\.[0-9]+)?$/; + const swiftToolsVersionRegex = /^[0-9]+\\.[0-9]+(\\.[0-9]+)?$/; if (!swiftToolsVersionRegex.test(version)) { return ( diff --git a/core/cordova.js b/core/cordova.js index b0219ff5a5..908ce41c57 100644 --- a/core/cordova.js +++ b/core/cordova.js @@ -1014,7 +1014,7 @@ } capacitorExec.nativeFetchMessages = function () { - // Stop listing for window detatch once native side confirms poke. + // Stop listening for window detach once native side confirms poke. if (failSafeTimerId) { clearTimeout(failSafeTimerId); failSafeTimerId = 0; diff --git a/ios/Capacitor/Capacitor/CAPBridgeViewController.swift b/ios/Capacitor/Capacitor/CAPBridgeViewController.swift index a7285213d8..f9c36d9ed3 100644 --- a/ios/Capacitor/Capacitor/CAPBridgeViewController.swift +++ b/ios/Capacitor/Capacitor/CAPBridgeViewController.swift @@ -302,7 +302,7 @@ extension CAPBridgeViewController { aWebView.scrollView.contentInsetAdjustmentBehavior = configuration.contentInsetAdjustmentBehavior aWebView.allowsLinkPreview = configuration.allowLinkPreviews aWebView.scrollView.isScrollEnabled = configuration.scrollingEnabled - if let overrideUserAgent = configuration.overridenUserAgentString { + if let overrideUserAgent = configuration.overriddenUserAgentString { aWebView.customUserAgent = overrideUserAgent } if let backgroundColor = configuration.backgroundColor { diff --git a/ios/Capacitor/Capacitor/CAPInstanceConfiguration.h b/ios/Capacitor/Capacitor/CAPInstanceConfiguration.h index 171dbb4634..8d35a6705b 100644 --- a/ios/Capacitor/Capacitor/CAPInstanceConfiguration.h +++ b/ios/Capacitor/Capacitor/CAPInstanceConfiguration.h @@ -8,7 +8,8 @@ NS_SWIFT_NAME(InstanceConfiguration) @interface CAPInstanceConfiguration: NSObject @property (nonatomic, readonly, nullable) NSString *appendedUserAgentString; -@property (nonatomic, readonly, nullable) NSString *overridenUserAgentString; +@property (nonatomic, readonly, nullable) NSString *overriddenUserAgentString; +@property (nonatomic, readonly, nullable, getter=overriddenUserAgentString) NSString *overridenUserAgentString DEPRECATED_MSG_ATTRIBUTE("Use overriddenUserAgentString instead"); @property (nonatomic, readonly, nullable) UIColor *backgroundColor; @property (nonatomic, readonly, nonnull) NSArray *allowedNavigationHostnames; @property (nonatomic, readonly, nonnull) NSURL *localURL; diff --git a/ios/Capacitor/Capacitor/CAPInstanceConfiguration.m b/ios/Capacitor/Capacitor/CAPInstanceConfiguration.m index d6b7785e34..092f4d2f08 100644 --- a/ios/Capacitor/Capacitor/CAPInstanceConfiguration.m +++ b/ios/Capacitor/Capacitor/CAPInstanceConfiguration.m @@ -14,7 +14,7 @@ - (instancetype)initWithDescriptor:(CAPInstanceDescriptor *)descriptor isDebug:( [descriptor normalize]; // now copy the simple properties _appendedUserAgentString = descriptor.appendedUserAgentString; - _overridenUserAgentString = descriptor.overridenUserAgentString; + _overriddenUserAgentString = descriptor.overriddenUserAgentString; _backgroundColor = descriptor.backgroundColor; _allowedNavigationHostnames = descriptor.allowedNavigationHostnames; switch (descriptor.loggingBehavior) { @@ -59,7 +59,7 @@ - (instancetype)initWithDescriptor:(CAPInstanceDescriptor *)descriptor isDebug:( - (instancetype)initWithConfiguration:(CAPInstanceConfiguration*)configuration andLocation:(NSURL*)location { if (self = [super init]) { _appendedUserAgentString = [[configuration appendedUserAgentString] copy]; - _overridenUserAgentString = [[configuration overridenUserAgentString] copy]; + _overriddenUserAgentString = [[configuration overriddenUserAgentString] copy]; _backgroundColor = configuration.backgroundColor; _allowedNavigationHostnames = [[configuration allowedNavigationHostnames] copy]; _localURL = [[configuration localURL] copy]; diff --git a/ios/Capacitor/Capacitor/CAPInstanceDescriptor.h b/ios/Capacitor/Capacitor/CAPInstanceDescriptor.h index f477ef55be..bf699dcddd 100644 --- a/ios/Capacitor/Capacitor/CAPInstanceDescriptor.h +++ b/ios/Capacitor/Capacitor/CAPInstanceDescriptor.h @@ -29,7 +29,7 @@ extern NSString * _Nonnull const CAPInstanceDescriptorDefaultHostname NS_SWIFT_U NS_SWIFT_NAME(InstanceDescriptor) @interface CAPInstanceDescriptor : NSObject /** - @brief A value to append to the @c User-Agent string. Ignored if @c overridenUserAgentString is set. + @brief A value to append to the @c User-Agent string. Ignored if @c overriddenUserAgentString is set. @discussion Set by @c appendUserAgent in the configuration file. */ @property (nonatomic, copy, nullable) NSString *appendedUserAgentString; @@ -37,7 +37,11 @@ NS_SWIFT_NAME(InstanceDescriptor) @brief A value that will completely replace the @c User-Agent string. Overrides @c appendedUserAgentString. @discussion Set by @c overrideUserAgent in the configuration file. */ -@property (nonatomic, copy, nullable) NSString *overridenUserAgentString; +@property (nonatomic, copy, nullable) NSString *overriddenUserAgentString; +/** + @brief Deprecated, misspelled alias for @c overriddenUserAgentString. + */ +@property (nonatomic, copy, nullable, getter=overriddenUserAgentString, setter=setOverriddenUserAgentString:) NSString *overridenUserAgentString __attribute__((deprecated("Use overriddenUserAgentString instead"))); /** @brief The background color to set on the web view where content is not visible. @discussion Set by @c backgroundColor in the configuration file. @@ -120,7 +124,7 @@ NS_SWIFT_NAME(InstanceDescriptor) */ @property (nonatomic, copy, nonnull) NSURL *appLocation; /** - @brief The path (relative to @c appLocation) which Capacitor will use for the inital URL at launch. + @brief The path (relative to @c appLocation) which Capacitor will use for the initial URL at launch. @discussion Defaults to nil, in which case Capacitor will attempt to load @c index.html. */ @property (nonatomic, copy, nullable) NSString *appStartPath; @@ -135,7 +139,7 @@ NS_SWIFT_NAME(InstanceDescriptor) */ @property (nonatomic, copy, nullable) NSString *preferredContentMode; /** - @brief The parser used to load the cofiguration for Cordova plugins. + @brief The parser used to load the configuration for Cordova plugins. */ @property (nonatomic, copy, nonnull) CDVConfigParser *cordovaConfiguration; /** diff --git a/ios/Capacitor/Capacitor/CAPInstanceDescriptor.swift b/ios/Capacitor/Capacitor/CAPInstanceDescriptor.swift index a7eff5f623..423e24a8c9 100644 --- a/ios/Capacitor/Capacitor/CAPInstanceDescriptor.swift +++ b/ios/Capacitor/Capacitor/CAPInstanceDescriptor.swift @@ -78,7 +78,7 @@ internal extension InstanceDescriptor { appendedUserAgentString = agentString } if let agentString = (config[keyPath: "ios.overrideUserAgent"] as? String) ?? (config[keyPath: "overrideUserAgent"] as? String) { - overridenUserAgentString = agentString + overriddenUserAgentString = agentString } if let colorString = (config[keyPath: "ios.backgroundColor"] as? String) ?? (config[keyPath: "backgroundColor"] as? String), let color = UIColor.capacitor.color(fromHex: colorString) { diff --git a/ios/Capacitor/Capacitor/CAPNotifications.swift b/ios/Capacitor/Capacitor/CAPNotifications.swift index 03d80aa87b..f372213d03 100644 --- a/ios/Capacitor/Capacitor/CAPNotifications.swift +++ b/ios/Capacitor/Capacitor/CAPNotifications.swift @@ -1,5 +1,5 @@ /** - Notificaton types for NotificationCenter and NSNotificationCenter + Notification types for NotificationCenter and NSNotificationCenter We want to include `capacitor` in the name(s) to uniquely identify these even though it can make the names long and the deprecated notifications are only here for backwards compatibility. diff --git a/ios/Capacitor/Capacitor/Codable/JSValueDecoder.swift b/ios/Capacitor/Capacitor/Codable/JSValueDecoder.swift index 43042e4f42..dc3966e4f5 100644 --- a/ios/Capacitor/Capacitor/Codable/JSValueDecoder.swift +++ b/ios/Capacitor/Capacitor/Codable/JSValueDecoder.swift @@ -16,7 +16,7 @@ public final class JSValueDecoder: TopLevelDecoder { /// The strategies available for decoding raw data. public typealias DataDecodingStrategy = JSONDecoder.DataDecodingStrategy - /// The strategies availble for decoding NaN, Infinity, and -Infinity + /// The strategies available for decoding NaN, Infinity, and -Infinity public enum NonConformingFloatDecodingStrategy { /// Decodes directly into the floating point type as .infinity, -.infinity, or .nan case deferred @@ -127,7 +127,7 @@ extension _JSValueDecoder: Decoder { SingleValueContainer(data: data, codingPath: codingPath, userInfo: userInfo, options: options) } - // force casting is fine becasue we've already determined that T is the type in the case + // force casting is fine because we've already determined that T is the type in the case // the swift standard library also force casts in their similar functions // https://github.com/swiftlang/swift-foundation/blob/da80d51fa3e77f3e7ed57c4300a870689e755713/Sources/FoundationEssentials/JSON/JSONEncoder.swift#L1140 // swiftlint:disable force_cast diff --git a/ios/Capacitor/Capacitor/Codable/JSValueEncoder.swift b/ios/Capacitor/Capacitor/Codable/JSValueEncoder.swift index 926aa118d7..c1c9a878ac 100644 --- a/ios/Capacitor/Capacitor/Codable/JSValueEncoder.swift +++ b/ios/Capacitor/Capacitor/Codable/JSValueEncoder.swift @@ -72,18 +72,34 @@ public final class JSValueEncoder: TopLevelEncoder { /// - Parameter optionalEncodingStrategy: The strategy to use when encoding `nil` values. Defaults to ``OptionalEncodingStrategy-swift.enum/undefined`` /// - Parameter dateEncodingStrategy: Defaults to `DateEncodingStrategy.deferredToDate` /// - Parameter dataEncodingStrategy: Defaults to `DataEncodingStrategy.deferredToData` - /// - Parameter nonConformingFloatEncodingStategy: Defaults to ``NonConformingFloatEncodingStrategy-swift.enum/deferred`` + /// - Parameter nonConformingFloatEncodingStrategy: Defaults to ``NonConformingFloatEncodingStrategy-swift.enum/deferred`` public init( optionalEncodingStrategy: OptionalEncodingStrategy = .undefined, dateEncodingStrategy: DateEncodingStrategy = .deferredToDate, dataEncodingStrategy: DataEncodingStrategy = .deferredToData, - nonConformingFloatEncodingStategy: NonConformingFloatEncodingStrategy = .deferred + nonConformingFloatEncodingStrategy: NonConformingFloatEncodingStrategy = .deferred ) { self.options = .init( optionalStrategy: optionalEncodingStrategy, dateStrategy: dateEncodingStrategy, dataStrategy: dataEncodingStrategy, - nonConformingFloatStrategy: nonConformingFloatEncodingStategy + nonConformingFloatStrategy: nonConformingFloatEncodingStrategy + ) + } + + /// Deprecated misspelled initializer label kept so existing call sites compile. + @available(*, deprecated, renamed: "init(optionalEncodingStrategy:dateEncodingStrategy:dataEncodingStrategy:nonConformingFloatEncodingStrategy:)") + public convenience init( + optionalEncodingStrategy: OptionalEncodingStrategy = .undefined, + dateEncodingStrategy: DateEncodingStrategy = .deferredToDate, + dataEncodingStrategy: DataEncodingStrategy = .deferredToData, + nonConformingFloatEncodingStategy: NonConformingFloatEncodingStrategy + ) { + self.init( + optionalEncodingStrategy: optionalEncodingStrategy, + dateEncodingStrategy: dateEncodingStrategy, + dataEncodingStrategy: dataEncodingStrategy, + nonConformingFloatEncodingStrategy: nonConformingFloatEncodingStategy ) } diff --git a/ios/Capacitor/Capacitor/Plugins/HttpRequestHandler.swift b/ios/Capacitor/Capacitor/Plugins/HttpRequestHandler.swift index 651c1b76b5..cc58600b5c 100644 --- a/ios/Capacitor/Capacitor/Plugins/HttpRequestHandler.swift +++ b/ios/Capacitor/Capacitor/Plugins/HttpRequestHandler.swift @@ -194,7 +194,7 @@ open class HttpRequestHandler { .openConnection() .build() - if let userAgentString = config?.overridenUserAgentString, headers["User-Agent"] == nil, headers["user-agent"] == nil { + if let userAgentString = config?.overriddenUserAgentString, headers["User-Agent"] == nil, headers["user-agent"] == nil { headers["User-Agent"] = userAgentString } diff --git a/ios/Capacitor/Capacitor/UIStatusBarManager+CAPHandleTapAction.m b/ios/Capacitor/Capacitor/UIStatusBarManager+CAPHandleTapAction.m index 44272a33ba..47c0adc8f2 100644 --- a/ios/Capacitor/Capacitor/UIStatusBarManager+CAPHandleTapAction.m +++ b/ios/Capacitor/Capacitor/UIStatusBarManager+CAPHandleTapAction.m @@ -9,7 +9,7 @@ + (void)load { dispatch_once(&onceToken, ^{ Class class = [self class]; SEL originalSelector = NSSelectorFromString(@"handleTapAction:"); - SEL swizzledSelector = @selector(nofity_handleTapAction:); + SEL swizzledSelector = @selector(notify_handleTapAction:); Method originalMethod = class_getInstanceMethod(class, originalSelector); Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); @@ -29,9 +29,9 @@ + (void)load { }); } --(void)nofity_handleTapAction:(id)arg1 { +-(void)notify_handleTapAction:(id)arg1 { [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:NSNotification.capacitorStatusBarTapped object:nil]]; - [self nofity_handleTapAction:arg1]; + [self notify_handleTapAction:arg1]; } @end diff --git a/ios/Capacitor/Capacitor/WebViewDelegationHandler.swift b/ios/Capacitor/Capacitor/WebViewDelegationHandler.swift index 2b4a256d00..9c782741a1 100644 --- a/ios/Capacitor/Capacitor/WebViewDelegationHandler.swift +++ b/ios/Capacitor/Capacitor/WebViewDelegationHandler.swift @@ -27,7 +27,7 @@ open class WebViewDelegationHandler: NSObject, WKNavigationDelegate, WKUIDelegat } open func willLoadWebview(_ webView: WKWebView?) { - // Set the webview to be not opaque on the inital load. This prevents + // Set the webview to be not opaque on the initial load. This prevents // the webview from showing a white background, which is its default // loading display, as that can appear as a screen flash. The opacity // might have been set by something else, like a plugin, so we want diff --git a/ios/Capacitor/CapacitorTests/BridgedTypesTests.swift b/ios/Capacitor/CapacitorTests/BridgedTypesTests.swift index f88b4e320e..23695ab65c 100644 --- a/ios/Capacitor/CapacitorTests/BridgedTypesTests.swift +++ b/ios/Capacitor/CapacitorTests/BridgedTypesTests.swift @@ -25,7 +25,7 @@ class BridgedTypesTests: XCTestCase { override class func setUp() { let formatter = ISO8601DateFormatter() // an ISO 8601 string does not necessarily include subsecond precision, so we can't just capture the current date - // or else we won't be able to compare the objects since they could differ by milliseconds or nanoseonds. so instead + // or else we won't be able to compare the objects since they could differ by milliseconds or nanoseconds. so instead // we use a fixed timestamp at a whole hour. let date = NSDate(timeIntervalSinceReferenceDate: 632854800) let subDictionary: [AnyHashable: Any] = ["testIntArray": [0, 1, 2], "testStringArray": ["1", "2", "3"], "testDictionary":["foo":"bar"]] diff --git a/ios/Capacitor/CapacitorTests/ConfigurationTests.swift b/ios/Capacitor/CapacitorTests/ConfigurationTests.swift index 778bfd688d..2457818e46 100644 --- a/ios/Capacitor/CapacitorTests/ConfigurationTests.swift +++ b/ios/Capacitor/CapacitorTests/ConfigurationTests.swift @@ -81,7 +81,7 @@ class ConfigurationTests: XCTestCase { let url = Bundle.main.url(forResource: "configurations", withExtension: "")! let descriptor = InstanceDescriptor.init(at: url, configuration: ConfigurationTests.files[.flat], cordovaConfiguration: nil) XCTAssertEqual(descriptor.backgroundColor, UIColor(red: 1, green: 1, blue: 1, alpha: 1)) - XCTAssertEqual(descriptor.overridenUserAgentString, "level 1 override") + XCTAssertEqual(descriptor.overriddenUserAgentString, "level 1 override") XCTAssertEqual(descriptor.appendedUserAgentString, "level 1 append") XCTAssertEqual(descriptor.loggingBehavior, .debug) } @@ -90,7 +90,7 @@ class ConfigurationTests: XCTestCase { let url = Bundle.main.url(forResource: "configurations", withExtension: "")! let descriptor = InstanceDescriptor.init(at: url, configuration: ConfigurationTests.files[.nested], cordovaConfiguration: nil) XCTAssertEqual(descriptor.backgroundColor, UIColor(red: 0, green: 0, blue: 0, alpha: 1)) - XCTAssertEqual(descriptor.overridenUserAgentString, "level 2 override") + XCTAssertEqual(descriptor.overriddenUserAgentString, "level 2 override") XCTAssertEqual(descriptor.appendedUserAgentString, "level 2 append") XCTAssertEqual(descriptor.loggingBehavior, .none) XCTAssertFalse(descriptor.scrollingEnabled) diff --git a/ios/Capacitor/CapacitorTests/RouterTests.swift b/ios/Capacitor/CapacitorTests/RouterTests.swift index 181551ee72..7923dbc0f6 100644 --- a/ios/Capacitor/CapacitorTests/RouterTests.swift +++ b/ios/Capacitor/CapacitorTests/RouterTests.swift @@ -15,7 +15,7 @@ class RouterTests: XCTestCase { checkRouter(path: "", expected: "/index.html") } - func testRouterReturnsIndexWhenProviedPathWithoutExtension() { + func testRouterReturnsIndexWhenProvidedPathWithoutExtension() { checkRouter(path: "/a/valid/path/no/ext", expected: "/index.html") } diff --git a/ios/Capacitor/CodableTests/CodableTests.swift b/ios/Capacitor/CodableTests/CodableTests.swift index bfdbe57162..9e4dfb8284 100644 --- a/ios/Capacitor/CodableTests/CodableTests.swift +++ b/ios/Capacitor/CodableTests/CodableTests.swift @@ -161,7 +161,7 @@ final class JSValueEncoderTest: XCTestCase { XCTAssertEqual(person.family?[1].age as? NSNumber, leiaAge) } - func testEncode__when_provided_an_instance_of_a_nested_unkeyed_container__encoding_succedds() throws { + func testEncode__when_provided_an_instance_of_a_nested_unkeyed_container__encoding_succeeds() throws { let encoder = JSValueEncoder() let encodedValue = try encoder.encode([person.family, person.family]) let encodedArray = try XCTUnwrap(encodedValue as? [[JSObject]]) diff --git a/ios/Capacitor/CodableTests/NonconformingFloatCodableTests.swift b/ios/Capacitor/CodableTests/NonconformingFloatCodableTests.swift index 9cfdb36156..e9dc9d956b 100644 --- a/ios/Capacitor/CodableTests/NonconformingFloatCodableTests.swift +++ b/ios/Capacitor/CodableTests/NonconformingFloatCodableTests.swift @@ -38,7 +38,7 @@ class JSValueEncoderNonConformingFloatTests: XCTestCase { func testEncode_float__convertToString_root() throws { let encoder = JSValueEncoder( - nonConformingFloatEncodingStategy: .convertToString( + nonConformingFloatEncodingStrategy: .convertToString( positiveInfinity: "pos", negativeInfinity: "neg", nan: "nan" @@ -60,7 +60,7 @@ class JSValueEncoderNonConformingFloatTests: XCTestCase { func testEncode_float__convertToString_array() throws { let encoder = JSValueEncoder( - nonConformingFloatEncodingStategy: .convertToString( + nonConformingFloatEncodingStrategy: .convertToString( positiveInfinity: "pos", negativeInfinity: "neg", nan: "nan" @@ -74,7 +74,7 @@ class JSValueEncoderNonConformingFloatTests: XCTestCase { func testEncode_float__convertToString_struct() throws { let encoder = JSValueEncoder( - nonConformingFloatEncodingStategy: .convertToString( + nonConformingFloatEncodingStrategy: .convertToString( positiveInfinity: "pos", negativeInfinity: "neg", nan: "nan" @@ -95,17 +95,17 @@ class JSValueEncoderNonConformingFloatTests: XCTestCase { } func testEncode_float__throw_root() throws { - let encoder = JSValueEncoder(nonConformingFloatEncodingStategy: .throw) + let encoder = JSValueEncoder(nonConformingFloatEncodingStrategy: .throw) XCTAssertThrowsError(try encoder.encode(Double.infinity)) } func testEncode_float__throw_array() throws { - let encoder = JSValueEncoder(nonConformingFloatEncodingStategy: .throw) + let encoder = JSValueEncoder(nonConformingFloatEncodingStrategy: .throw) XCTAssertThrowsError(try encoder.encode([Double.infinity, -.infinity, .nan])) } func testEncode_float__throw_struct() throws { - let encoder = JSValueEncoder(nonConformingFloatEncodingStategy: .throw) + let encoder = JSValueEncoder(nonConformingFloatEncodingStrategy: .throw) XCTAssertThrowsError(try encoder.encode(Foo(number: .infinity))) } }