diff --git a/.changes/plugin-ios-xcode-project.md b/.changes/plugin-ios-xcode-project.md new file mode 100644 index 000000000..ecfc3afd8 --- /dev/null +++ b/.changes/plugin-ios-xcode-project.md @@ -0,0 +1,9 @@ +--- +"tauri-cli": patch:feat +"@tauri-apps/cli": patch:feat +"tauri-plugin": patch:feat +"tauri-utils": patch:feat +"tauri": patch:feat +--- + +Added an option to use a Xcode project for the iOS plugin instead of a plain SwiftPM project. diff --git a/core/tauri-plugin/src/build/mobile.rs b/core/tauri-plugin/src/build/mobile.rs index af6535f31..3d4d3cec6 100644 --- a/core/tauri-plugin/src/build/mobile.rs +++ b/core/tauri-plugin/src/build/mobile.rs @@ -90,7 +90,7 @@ pub(crate) fn setup( &[".build", "Package.resolved", "Tests"], ) .context("failed to copy tauri-api to the plugin project")?; - tauri_utils::build::link_swift_library( + tauri_utils::build::link_apple_library( &std::env::var("CARGO_PKG_NAME").unwrap(), manifest_dir.join(path), ); diff --git a/core/tauri-utils/src/build.rs b/core/tauri-utils/src/build.rs index 510d47762..4db034591 100644 --- a/core/tauri-utils/src/build.rs +++ b/core/tauri-utils/src/build.rs @@ -6,7 +6,17 @@ /// Link a Swift library. #[cfg(target_os = "macos")] -pub fn link_swift_library(name: &str, source: impl AsRef) { +pub fn link_apple_library(name: &str, source: impl AsRef) { + if source.as_ref().join("Package.swift").exists() { + link_swift_library(name, source); + } else { + link_xcode_library(name, source); + } +} + +/// Link a Swift library. +#[cfg(target_os = "macos")] +fn link_swift_library(name: &str, source: impl AsRef) { let source = source.as_ref(); let sdk_root = std::env::var_os("SDKROOT"); @@ -23,3 +33,59 @@ pub fn link_swift_library(name: &str, source: impl AsRef) { std::env::set_var("SDKROOT", root); } } + +/// Link a Xcode library. +#[cfg(target_os = "macos")] +fn link_xcode_library(name: &str, source: impl AsRef) { + use std::{path::PathBuf, process::Command}; + + let source = source.as_ref(); + let configuration = if std::env::var("DEBUG") + .map(|v| v == "true") + .unwrap_or_default() + { + "Debug" + } else { + "Release" + }; + + let (sdk, arch) = match std::env::var("TARGET").unwrap().as_str() { + "aarch64-apple-ios" => ("iphoneos", "arm64"), + "aarch64-apple-ios-sim" => ("iphonesimulator", "arm64"), + "x86_64-apple-ios" => ("iphonesimulator", "x86_64"), + _ => return, + }; + + let out_dir = std::env::var_os("OUT_DIR").map(PathBuf::from).unwrap(); + let derived_data_path = out_dir.join(format!("derivedData-{name}")); + + let status = Command::new("xcodebuild") + .arg("build") + .arg("-scheme") + .arg(name) + .arg("-configuration") + .arg(configuration) + .arg("-sdk") + .arg(sdk) + .arg("-arch") + .arg(arch) + .arg("-derivedDataPath") + .arg(&derived_data_path) + .arg("BUILD_LIBRARY_FOR_DISTRIBUTION=YES") + .arg("OTHER_SWIFT_FLAGS=-no-verify-emitted-module-interface") + .current_dir(source) + .env_clear() + .status() + .unwrap(); + + assert!(status.success()); + + let lib_out_dir = derived_data_path + .join("Build") + .join("Products") + .join(format!("{configuration}-{sdk}")); + + println!("cargo:rerun-if-changed={}", source.display()); + println!("cargo:rustc-link-search=native={}", lib_out_dir.display()); + println!("cargo:rustc-link-lib=static={name}"); +} diff --git a/core/tauri/build.rs b/core/tauri/build.rs index 6c3ccb4f1..39142c3f4 100644 --- a/core/tauri/build.rs +++ b/core/tauri/build.rs @@ -312,7 +312,7 @@ fn main() { if target_os == "ios" { let lib_path = PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("mobile/ios-api"); - tauri_utils::build::link_swift_library("Tauri", &lib_path); + tauri_utils::build::link_apple_library("Tauri", &lib_path); println!("cargo:ios_library_path={}", lib_path.display()); } } diff --git a/core/tauri/mobile/ios-api/Package.swift b/core/tauri/mobile/ios-api/Package.swift index 5e72c9339..c7a733230 100644 --- a/core/tauri/mobile/ios-api/Package.swift +++ b/core/tauri/mobile/ios-api/Package.swift @@ -6,35 +6,35 @@ import PackageDescription let package = Package( - name: "Tauri", - platforms: [ - .macOS(.v10_13), - .iOS(.v11), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "Tauri", - type: .static, - targets: ["Tauri"]), - ], - dependencies: [ - // Dependencies declare other packages that this package depends on. - .package(name: "SwiftRs", url: "https://github.com/Brendonovich/swift-rs", from: "1.0.0"), - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target( - name: "Tauri", - dependencies: [ - .byName(name: "SwiftRs"), - ], - path: "Sources" - ), - .testTarget( - name: "TauriTests", - dependencies: ["Tauri"] - ), - ] + name: "Tauri", + platforms: [ + .macOS(.v10_13), + .iOS(.v11), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "Tauri", + type: .static, + targets: ["Tauri"]) + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + .package(name: "SwiftRs", url: "https://github.com/Brendonovich/swift-rs", from: "1.0.0") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "Tauri", + dependencies: [ + .byName(name: "SwiftRs") + ], + path: "Sources" + ), + .testTarget( + name: "TauriTests", + dependencies: ["Tauri"] + ), + ] ) diff --git a/examples/api/src-tauri/Cargo.lock b/examples/api/src-tauri/Cargo.lock index 5ec6656a1..fac2805fa 100644 --- a/examples/api/src-tauri/Cargo.lock +++ b/examples/api/src-tauri/Cargo.lock @@ -107,6 +107,7 @@ dependencies = [ "tauri", "tauri-build", "tauri-plugin-sample", + "tauri-plugin-xcode", "tiny_http", ] @@ -3139,6 +3140,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "tauri-plugin-xcode" +version = "0.0.0" +dependencies = [ + "serde", + "tauri", + "tauri-plugin", + "thiserror", +] + [[package]] name = "tauri-runtime" version = "2.0.0-beta.16" diff --git a/examples/api/src-tauri/Cargo.toml b/examples/api/src-tauri/Cargo.toml index 3bb338938..fd489ff2d 100644 --- a/examples/api/src-tauri/Cargo.toml +++ b/examples/api/src-tauri/Cargo.toml @@ -11,11 +11,14 @@ name = "api_lib" crate-type = ["staticlib", "cdylib", "rlib"] [build-dependencies] -tauri-build = { path = "../../../core/tauri-build", features = ["codegen", "isolation"] } +tauri-build = { path = "../../../core/tauri-build", features = [ + "codegen", + "isolation", +] } [dependencies] serde_json = "1.0" -serde = { version = "1.0", features = [ "derive" ] } +serde = { version = "1.0", features = ["derive"] } tiny_http = "0.11" log = "0.4" tauri-plugin-sample = { path = "./tauri-plugin-sample/" } @@ -28,7 +31,7 @@ features = [ "image-png", "isolation", "macos-private-api", - "tray-icon" + "tray-icon", ] [dev-dependencies.tauri] @@ -36,7 +39,7 @@ path = "../../../core/tauri" features = ["test"] [features] -prod = [ "tauri/custom-protocol" ] +prod = ["tauri/custom-protocol"] # default to small, optimized release binaries [profile.release] diff --git a/tooling/cli/src/mobile/ios/dev.rs b/tooling/cli/src/mobile/ios/dev.rs index 95ecfb48c..fa766ad24 100644 --- a/tooling/cli/src/mobile/ios/dev.rs +++ b/tooling/cli/src/mobile/ios/dev.rs @@ -234,7 +234,7 @@ fn run_dev( } Err(e) => { crate::dev::kill_before_dev_process(); - Err(e.into()) + Err(e) } } } else { diff --git a/tooling/cli/src/plugin/init.rs b/tooling/cli/src/plugin/init.rs index 6566e0c37..236041ed7 100644 --- a/tooling/cli/src/plugin/init.rs +++ b/tooling/cli/src/plugin/init.rs @@ -9,7 +9,7 @@ use crate::{ VersionMetadata, }; use anyhow::Context; -use clap::Parser; +use clap::{Parser, ValueEnum}; use handlebars::{to_json, Handlebars}; use heck::{ToKebabCase, ToPascalCase, ToSnakeCase}; use include_dir::{include_dir, Dir}; @@ -53,6 +53,17 @@ pub struct Options { /// Whether to initialize Android and iOS projects for the plugin. #[clap(long)] pub(crate) mobile: bool, + /// Type of framework to use for the iOS project. + #[clap(long)] + pub(crate) ios_framework: Option, +} + +#[derive(Debug, Clone, ValueEnum)] +pub enum IosFrameworkKind { + /// Swift Package Manager project + Spm, + /// Xcode project + Xcode, } impl Options { @@ -155,6 +166,8 @@ pub fn command(mut options: Options) -> Result<()> { None }; + let ios_framework = options.ios_framework.unwrap_or(IosFrameworkKind::Spm); + let mut created_dirs = Vec::new(); template::render_with_generator( &handlebars, @@ -193,7 +206,18 @@ pub fn command(mut options: Options) -> Result<()> { return Ok(None); } } - "ios" if !(options.ios || options.mobile) => return Ok(None), + "ios-spm" | "ios-xcode" if !(options.ios || options.mobile) => return Ok(None), + "ios-spm" if !matches!(ios_framework, IosFrameworkKind::Spm) => return Ok(None), + "ios-xcode" if !matches!(ios_framework, IosFrameworkKind::Xcode) => return Ok(None), + "ios-spm" | "ios-xcode" => { + let folder_name = components.next().unwrap().as_os_str().to_string_lossy(); + + path = Path::new("ios") + .join(Component::Normal(&std::ffi::OsString::from( + &folder_name.replace("{{ plugin_name }}", &plugin_name), + ))) + .join(components.collect::()); + } "guest-js" | "rollup.config.js" | "tsconfig.json" | "package.json" if options.no_api => { diff --git a/tooling/cli/src/plugin/new.rs b/tooling/cli/src/plugin/new.rs index ccd3ed80b..71be79f44 100644 --- a/tooling/cli/src/plugin/new.rs +++ b/tooling/cli/src/plugin/new.rs @@ -35,6 +35,9 @@ pub struct Options { /// Whether to initialize Android and iOS projects for the plugin. #[clap(long)] mobile: bool, + /// Type of framework to use for the iOS project. + #[clap(long)] + pub(crate) ios_framework: Option, } impl From for super::init::Options { @@ -49,6 +52,7 @@ impl From for super::init::Options { android: o.android, ios: o.ios, mobile: o.mobile, + ios_framework: o.ios_framework, } } } diff --git a/tooling/cli/templates/plugin/ios/.gitignore b/tooling/cli/templates/plugin/ios-spm/.gitignore similarity index 100% rename from tooling/cli/templates/plugin/ios/.gitignore rename to tooling/cli/templates/plugin/ios-spm/.gitignore diff --git a/tooling/cli/templates/plugin/ios/Package.swift b/tooling/cli/templates/plugin/ios-spm/Package.swift similarity index 100% rename from tooling/cli/templates/plugin/ios/Package.swift rename to tooling/cli/templates/plugin/ios-spm/Package.swift diff --git a/tooling/cli/templates/plugin/ios/README.md b/tooling/cli/templates/plugin/ios-spm/README.md similarity index 100% rename from tooling/cli/templates/plugin/ios/README.md rename to tooling/cli/templates/plugin/ios-spm/README.md diff --git a/tooling/cli/templates/plugin/ios/Sources/ExamplePlugin.swift b/tooling/cli/templates/plugin/ios-spm/Sources/ExamplePlugin.swift similarity index 100% rename from tooling/cli/templates/plugin/ios/Sources/ExamplePlugin.swift rename to tooling/cli/templates/plugin/ios-spm/Sources/ExamplePlugin.swift diff --git a/tooling/cli/templates/plugin/ios/Tests/PluginTests/PluginTests.swift b/tooling/cli/templates/plugin/ios-spm/Tests/PluginTests/PluginTests.swift similarity index 100% rename from tooling/cli/templates/plugin/ios/Tests/PluginTests/PluginTests.swift rename to tooling/cli/templates/plugin/ios-spm/Tests/PluginTests/PluginTests.swift diff --git a/tooling/cli/templates/plugin/ios-xcode/tauri-plugin-{{ plugin_name }}.xcodeproj/project.pbxproj b/tooling/cli/templates/plugin/ios-xcode/tauri-plugin-{{ plugin_name }}.xcodeproj/project.pbxproj new file mode 100644 index 000000000..7f48b46ec --- /dev/null +++ b/tooling/cli/templates/plugin/ios-xcode/tauri-plugin-{{ plugin_name }}.xcodeproj/project.pbxproj @@ -0,0 +1,319 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 60; + objects = { + +/* Begin PBXBuildFile section */ + A0E2115A2BF552D2003BCF4D /* ExamplePlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0E211592BF552D2003BCF4D /* ExamplePlugin.swift */; }; + A0E211622BF55305003BCF4D /* Tauri in Frameworks */ = {isa = PBXBuildFile; productRef = A0E211612BF55305003BCF4D /* Tauri */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + A0E211542BF552D2003BCF4D /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + A0E211562BF552D2003BCF4D /* libtauri-plugin-{{ plugin_name }}.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libtauri-plugin-{{ plugin_name }}.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + A0E211592BF552D2003BCF4D /* ExamplePlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExamplePlugin.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + A0E211532BF552D2003BCF4D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A0E211622BF55305003BCF4D /* Tauri in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + A0E2114D2BF552D2003BCF4D = { + isa = PBXGroup; + children = ( + A0E211582BF552D2003BCF4D /* tauri-plugin-{{ plugin_name }} */, + A0E211572BF552D2003BCF4D /* Products */, + ); + sourceTree = ""; + }; + A0E211572BF552D2003BCF4D /* Products */ = { + isa = PBXGroup; + children = ( + A0E211562BF552D2003BCF4D /* libtauri-plugin-{{ plugin_name }}.a */, + ); + name = Products; + sourceTree = ""; + }; + A0E211582BF552D2003BCF4D /* tauri-plugin-{{ plugin_name }} */ = { + isa = PBXGroup; + children = ( + A0E211592BF552D2003BCF4D /* ExamplePlugin.swift */, + ); + path = "tauri-plugin-{{ plugin_name }}"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + A0E211552BF552D2003BCF4D /* tauri-plugin-{{ plugin_name }} */ = { + isa = PBXNativeTarget; + buildConfigurationList = A0E2115D2BF552D2003BCF4D /* Build configuration list for PBXNativeTarget "tauri-plugin-{{ plugin_name }}" */; + buildPhases = ( + A0E211522BF552D2003BCF4D /* Sources */, + A0E211532BF552D2003BCF4D /* Frameworks */, + A0E211542BF552D2003BCF4D /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "tauri-plugin-{{ plugin_name }}"; + packageProductDependencies = ( + A0E211612BF55305003BCF4D /* Tauri */, + ); + productName = "tauri-plugin-{{ plugin_name }}"; + productReference = A0E211562BF552D2003BCF4D /* libtauri-plugin-{{ plugin_name }}.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + A0E2114E2BF552D2003BCF4D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1540; + LastUpgradeCheck = 1540; + TargetAttributes = { + A0E211552BF552D2003BCF4D = { + CreatedOnToolsVersion = 15.4; + }; + }; + }; + buildConfigurationList = A0E211512BF552D2003BCF4D /* Build configuration list for PBXProject "tauri-plugin-{{ plugin_name }}" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = A0E2114D2BF552D2003BCF4D; + packageReferences = ( + A0E211602BF55305003BCF4D /* XCLocalSwiftPackageReference "../.tauri/tauri-api" */, + ); + productRefGroup = A0E211572BF552D2003BCF4D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + A0E211552BF552D2003BCF4D /* tauri-plugin-{{ plugin_name }} */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + A0E211522BF552D2003BCF4D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A0E2115A2BF552D2003BCF4D /* ExamplePlugin.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + A0E2115B2BF552D2003BCF4D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.5; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + A0E2115C2BF552D2003BCF4D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.5; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + A0E2115E2BF552D2003BCF4D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + A0E2115F2BF552D2003BCF4D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + A0E211512BF552D2003BCF4D /* Build configuration list for PBXProject "tauri-plugin-{{ plugin_name }}" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A0E2115B2BF552D2003BCF4D /* Debug */, + A0E2115C2BF552D2003BCF4D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A0E2115D2BF552D2003BCF4D /* Build configuration list for PBXNativeTarget "tauri-plugin-{{ plugin_name }}" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A0E2115E2BF552D2003BCF4D /* Debug */, + A0E2115F2BF552D2003BCF4D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + A0E211602BF55305003BCF4D /* XCLocalSwiftPackageReference "../.tauri/tauri-api" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = "../.tauri/tauri-api"; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + A0E211612BF55305003BCF4D /* Tauri */ = { + isa = XCSwiftPackageProductDependency; + productName = Tauri; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = A0E2114E2BF552D2003BCF4D /* Project object */; +} diff --git a/tooling/cli/templates/plugin/ios-xcode/tauri-plugin-{{ plugin_name }}.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/tooling/cli/templates/plugin/ios-xcode/tauri-plugin-{{ plugin_name }}.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/tooling/cli/templates/plugin/ios-xcode/tauri-plugin-{{ plugin_name }}.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/tooling/cli/templates/plugin/ios-xcode/tauri-plugin-{{ plugin_name }}.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/tooling/cli/templates/plugin/ios-xcode/tauri-plugin-{{ plugin_name }}.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/tooling/cli/templates/plugin/ios-xcode/tauri-plugin-{{ plugin_name }}.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/tooling/cli/templates/plugin/ios-xcode/tauri-plugin-{{ plugin_name }}/ExamplePlugin.swift b/tooling/cli/templates/plugin/ios-xcode/tauri-plugin-{{ plugin_name }}/ExamplePlugin.swift new file mode 100644 index 000000000..526d73063 --- /dev/null +++ b/tooling/cli/templates/plugin/ios-xcode/tauri-plugin-{{ plugin_name }}/ExamplePlugin.swift @@ -0,0 +1,20 @@ +import SwiftRs +import Tauri +import UIKit +import WebKit + +class PingArgs: Decodable { + let value: String? +} + +class ExamplePlugin: Plugin { + @objc public func ping(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(PingArgs.self) + invoke.resolve(["value": args.value ?? ""]) + } +} + +@_cdecl("init_plugin_{{ plugin_name_snake_case }}") +func initPlugin() -> Plugin { + return ExamplePlugin() +}