-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Move iOS package from framework to xcframework #8198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,18 @@ Pod::Spec.new do |spec| | |
spec.name = "onnxruntime-mobile-c" | ||
spec.version = "${ORT_VERSION}" | ||
spec.authors = { "ONNX Runtime" => "[email protected]" } | ||
spec.license = { :type => "MIT" } | ||
spec.license = { :type => "MIT", :file => 'LICENSE' } | ||
spec.homepage = "https://github.com/microsoft/onnxruntime" | ||
spec.source = { :http => "_ORT_DOWNLOAD_URL_" } | ||
spec.summary = "ONNX Runtime Mobile C/C++ Pod" | ||
spec.platform = :ios, "${CMAKE_OSX_DEPLOYMENT_TARGET}" | ||
spec.vendored_frameworks = "onnxruntime.framework" | ||
spec.vendored_frameworks = "onnxruntime.xcframework" | ||
spec.weak_framework = 'CoreML' | ||
spec.source_files = 'onnxruntime.framework/Headers/*.h' | ||
|
||
# arm64 iphonesimulator is not supported in this release | ||
spec.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } | ||
spec.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } | ||
|
||
spec.description = <<-DESC | ||
A preview pod for ONNX Runtime Mobile C/C++ library. Pods for Objective-C and Swift coming soon. | ||
DESC | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,17 @@ def _test_ios_packages(args): | |
if not c_framework_dir.is_dir(): | ||
raise FileNotFoundError('c_framework_dir {} is not a folder.'.format(c_framework_dir)) | ||
|
||
framework_path = os.path.join(c_framework_dir, 'onnxruntime.framework') | ||
if not pathlib.Path(framework_path).exists(): | ||
raise FileNotFoundError('{} does not have onnxruntime.framework'.format(c_framework_dir)) | ||
has_framework = pathlib.Path(os.path.join(c_framework_dir, 'onnxruntime.framework')).exists() | ||
has_xcframework = pathlib.Path(os.path.join(c_framework_dir, 'onnxruntime.xcframework')).exists() | ||
|
||
if not has_framework and not has_xcframework: | ||
raise FileNotFoundError('{} does not have onnxruntime.framework/xcframework'.format(c_framework_dir)) | ||
|
||
if has_framework and has_xcframework: | ||
raise ValueError('Cannot proceed when both onnxruntime.framework ' | ||
'and onnxruntime.xcframework exist') | ||
|
||
framework_name = 'onnxruntime.framework' if has_framework else 'onnxruntime.xcframework' | ||
|
||
# create a temp folder | ||
import tempfile | ||
|
@@ -41,7 +49,7 @@ def _test_ios_packages(args): | |
# shutil.make_archive require target file as full path without extension | ||
zip_base_filename = os.path.join(local_pods_dir, 'onnxruntime-mobile') | ||
zip_file_path = zip_base_filename + '.zip' | ||
shutil.make_archive(zip_base_filename, 'zip', root_dir=c_framework_dir, base_dir='onnxruntime.framework') | ||
shutil.make_archive(zip_base_filename, 'zip', root_dir=c_framework_dir, base_dir=framework_name) | ||
|
||
# copy the test project to the temp_dir | ||
test_proj_path = os.path.join(REPO_DIR, 'onnxruntime', 'test', 'platform', 'ios', 'ios_package_test') | ||
|
@@ -56,6 +64,7 @@ def _test_ios_packages(args): | |
|
||
# replace the target strings | ||
file_data = file_data.replace('${ORT_BASE_FRAMEWORK_ARCHIVE}', 'file:' + zip_file_path) | ||
file_data = file_data.replace('${ORT_FRAMEWORK_NAME}', framework_name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could potentially specify the local pod directory in the Podfile There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do in a future PR |
||
with open(os.path.join(REPO_DIR, 'VERSION_NUMBER')) as version_file: | ||
file_data = file_data.replace('${ORT_VERSION}', version_file.readline().strip()) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we still want to support the old style here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I don't think cmake can generate xcframework by itself, will still keep the framework for individual ABI, since we will also need it go generate xcframework