diff --git a/Package.swift b/Package.swift deleted file mode 100644 index f8bf33001ea24..0000000000000 --- a/Package.swift +++ /dev/null @@ -1,109 +0,0 @@ -// swift-tools-version: 5.6 -// The swift-tools-version declares the minimum version of Swift required to build this package and MUST be the first -// line of this file. 5.6 is required to support zip files for the pod archive binaryTarget. -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// -// A user of the Swift Package Manager (SPM) package will consume this file directly from the ORT github repository. -// For context, the end user's config will look something like: -// -// dependencies: [ -// .package(url: "https://github.com/microsoft/onnxruntime", branch: "rel-1.15.0"), -// ... -// ], -// -// NOTE: The direct consumption creates a somewhat complicated setup to 'release' a new version of the ORT SPM package. -// TBD: how to manage the release process - -import PackageDescription -import class Foundation.ProcessInfo - -let package = Package( - name: "onnxruntime", - platforms: [.iOS(.v12)], - products: [ - .library(name: "onnxruntime", - type: .static, - targets: ["OnnxRuntimeBindings"]), - ], - dependencies: [], - targets: [ - .target(name: "OnnxRuntimeBindings", - dependencies: ["onnxruntime"], - path: "objectivec", - exclude: ["test", "docs", "ReadMe.md", "format_objc.sh", - "ort_checkpoint.mm", - "ort_checkpoint_internal.h", - "ort_training_session_internal.h", - "ort_training_session.mm", - "include/ort_checkpoint.h", - "include/ort_training_session.h", - "include/onnxruntime_training.h"], - cxxSettings: [ - .define("SPM_BUILD"), - .unsafeFlags(["-std=c++17", - "-fobjc-arc-exceptions" - ]), - ], linkerSettings: [ - .unsafeFlags(["-ObjC"]), - ]), - .testTarget(name: "OnnxRuntimeBindingsTests", - dependencies: ["OnnxRuntimeBindings"], - path: "swift/OnnxRuntimeBindingsTests", - resources: [ - .copy("Resources/single_add.basic.ort") - ]), - ] -) - -// Add the ORT iOS Pod archive as a binary target. -// -// There are 2 scenarios: -// -// Release branch of ORT github repo: -// Target will be set to the released pod archive and its checksum. -// -// Any other branch/tag of ORT github repo: -// Invalid by default. We do not have a pod archive that is guaranteed to work -// as the objective-c bindings may have changed since the pod archive was released. - -// CI or local testing where you have built/obtained the iOS Pod archive matching the current source code. -// Requires the ORT_IOS_POD_LOCAL_PATH environment variable to be set to specify the location of the pod. -if let pod_archive_path = ProcessInfo.processInfo.environment["ORT_IOS_POD_LOCAL_PATH"] { - // ORT_IOS_POD_LOCAL_PATH MUST be a path that is relative to Package.swift. - // - // To build locally, tools/ci_build/github/apple/build_and_assemble_ios_pods.py can be used - // See https://onnxruntime.ai/docs/build/custom.html#ios - // Example command: - // python3 tools/ci_build/github/apple/build_and_assemble_ios_pods.py \ - // --variant Full \ - // --build-settings-file tools/ci_build/github/apple/default_full_ios_framework_build_settings.json - // - // This should produce the pod archive in build/ios_pod_staging, and ORT_IOS_POD_LOCAL_PATH can be set to - // "build/ios_pod_staging/pod-archive-onnxruntime-c-???.zip" where '???' is replaced by the version info in the - // actual filename. - package.targets.append(Target.binaryTarget(name: "onnxruntime", path: pod_archive_path)) - -} else { - // When creating the release version: - // - remove the fatalError - // - uncomment the package.targets.append call - // - update the major/minor/patch version info in the url - // - insert the checksum info from the onnxruntime-ios-packaging-pipeline CI's 'Print ORT iOS Pod checksum' - // stage output (or download the pod archive artifact from the CI and run `shasum -a 256 ` - // to manually calculate it). - // The checksum length and chars should look something like - // "c89cd106ff02eb3892243acd7c4f2bd8e68c2c94f2751b5e35f98722e10c042b" - // - // package.targets.append( - // Target.binaryTarget(name: "onnxruntime", - // url: "https://onnxruntimepackages.z14.web.core.windows.net/pod-archive-onnxruntime-c-.zip", - // checksum: "Insert checksum here") - // ) - - fatalError("It is not valid to use a non-release branch from https://github.com/microsoft/onnxruntime.\n" + - "Please use a release branch (e.g. rel-1.15.0), or build the ONNX Runtime iOS pod archive locally " + - "and set the ORT_IOS_POD_LOCAL_PATH environment variable.\n" + - "See Package.swift for more information on using a local pod archive.") -} diff --git a/swift/OnnxRuntimeBindingsTests/Resources/single_add.basic.ort b/swift/OnnxRuntimeBindingsTests/Resources/single_add.basic.ort deleted file mode 100644 index f622784b35366..0000000000000 Binary files a/swift/OnnxRuntimeBindingsTests/Resources/single_add.basic.ort and /dev/null differ diff --git a/swift/OnnxRuntimeBindingsTests/SwiftOnnxRuntimeBindingsTests.swift b/swift/OnnxRuntimeBindingsTests/SwiftOnnxRuntimeBindingsTests.swift deleted file mode 100644 index 48e276487e281..0000000000000 --- a/swift/OnnxRuntimeBindingsTests/SwiftOnnxRuntimeBindingsTests.swift +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import XCTest -import Foundation -@testable import OnnxRuntimeBindings - -final class SwiftOnnxRuntimeBindingsTests: XCTestCase { - let modelPath: String = Bundle.module.url(forResource: "single_add.basic", withExtension: "ort")!.path - - func testGetVersionString() throws { - do { - let version = ORTVersion() - XCTAssertNotNil(version) - } catch let error { - XCTFail(error.localizedDescription) - } - } - - func testCreateSession() throws { - do { - let env = try ORTEnv(loggingLevel: ORTLoggingLevel.verbose) - let options = try ORTSessionOptions() - try options.setLogSeverityLevel(ORTLoggingLevel.verbose) - try options.setIntraOpNumThreads(1) - // Create the ORTSession - _ = try ORTSession(env: env, modelPath: modelPath, sessionOptions: options) - } catch let error { - XCTFail(error.localizedDescription) - } - } - - func testAppendCoreMLEP() throws { - do { - let env = try ORTEnv(loggingLevel: ORTLoggingLevel.verbose) - let sessionOptions: ORTSessionOptions = try ORTSessionOptions() - let coreMLOptions: ORTCoreMLExecutionProviderOptions = ORTCoreMLExecutionProviderOptions() - coreMLOptions.enableOnSubgraphs = true - try sessionOptions.appendCoreMLExecutionProvider(with: coreMLOptions) - - XCTAssertTrue(ORTIsCoreMLExecutionProviderAvailable()) - _ = try ORTSession(env: env, modelPath: modelPath, sessionOptions: sessionOptions) - } catch let error { - XCTFail(error.localizedDescription) - } - } - - func testAppendXnnpackEP() throws { - do { - let env = try ORTEnv(loggingLevel: ORTLoggingLevel.verbose) - let sessionOptions: ORTSessionOptions = try ORTSessionOptions() - let XnnpackOptions: ORTXnnpackExecutionProviderOptions = ORTXnnpackExecutionProviderOptions() - XnnpackOptions.intra_op_num_threads = 2 - try sessionOptions.appendXnnpackExecutionProvider(with: XnnpackOptions) - - XCTAssertTrue(ORTIsCoreMLExecutionProviderAvailable()) - _ = try ORTSession(env: env, modelPath: modelPath, sessionOptions: sessionOptions) - } catch let error { - XCTFail(error.localizedDescription) - } - } -} diff --git a/tools/ci_build/github/azure-pipelines/mac-ios-packaging-pipeline.yml b/tools/ci_build/github/azure-pipelines/mac-ios-packaging-pipeline.yml index 20263974af24a..5fd15b64e03b6 100644 --- a/tools/ci_build/github/azure-pipelines/mac-ios-packaging-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/mac-ios-packaging-pipeline.yml @@ -100,50 +100,3 @@ stages: - template: templates/stages/mac-ios-packaging-build-stage.yml parameters: packageVariant: Training - -- stage: IosPackaging_TestPackageSwift_Full - dependsOn: - - IosPackaging_SetCommonVariables - - IosPackaging_Build_Full - - jobs: - - job: j - displayName: "Test Package.swift with full package" - - pool: - vmImage: "macOS-13" - - variables: - xcodeVersion: "14.3" - ortPodVersion: $[stageDependencies.IosPackaging_SetCommonVariables.j.outputs['SetCommonVariables.ORT_POD_VERSION']] - skipComponentGovernanceDetection: true - - timeoutInMinutes: 10 - - steps: - - template: templates/use-xcode-version.yml - parameters: - xcodeVersion: ${{ variables.xcodeVersion }} - - - download: current - artifact: ios_packaging_artifacts_full - displayName: "Download full build artifacts" - - - script: | - set -e -x - shasum -a 256 "$(Pipeline.Workspace)/ios_packaging_artifacts_full/pod-archive-onnxruntime-c-$(ortPodVersion).zip" - displayName: "Print ORT iOS Pod checksum" - - # copy the pod archive to a path relative to Package.swift and set the env var required by Package.swift to use that. - # xcodebuild will implicitly use Package.swift and build/run the .testTarget (tests in swift/onnxTests). - # once that's done cleanup the copy of the pod zip file - - script: | - set -e -x - - SIMULATOR_DEVICE_ID=$(set -o pipefail; python3 tools/ci_build/github/apple/get_simulator_device_info.py | jq --raw-output '.device_udid') - - cp "$(Pipeline.Workspace)/ios_packaging_artifacts_full/pod-archive-onnxruntime-c-$(ortPodVersion).zip" swift/ - export ORT_IOS_POD_LOCAL_PATH="swift/pod-archive-onnxruntime-c-$(ortPodVersion).zip" - xcodebuild test -scheme onnxruntime -destination "platform=iOS Simulator,id=${SIMULATOR_DEVICE_ID}" - rm swift/pod-archive-onnxruntime-c-$(ortPodVersion).zip - displayName: "Test Package.swift usage"