diff --git a/js/README.md b/js/README.md index 1055d92725..69b66dcc6d 100644 --- a/js/README.md +++ b/js/README.md @@ -379,17 +379,17 @@ By default, ONNX Runtime React Native leverages ONNX Runtime Mobile package with python tools/ci_build/github/apple/build_ios_framework.py tools/ci_build/github/apple/default_mobile_ios_framework_build_settings.json --config MinSizeRel --include_ops_by_config tools/ci_build/github/android/mobile_package.required_operators.config ``` - It creates `onnxruntime.framework` in `build/iOS_framework/framework_out` directory. Create an archive file of `onnxruntime.framework` directory as follows and copy to `/js/react_native/local_pods` directory. + It creates `Headers`, `LICENSE`, and `onnxruntime.xcframework` in `build/iOS_framework/framework_out` directory. From `framework_out` directory, create an archive file named `onnxruntime-mobile-c.zip` as follows and copy to `/js/react_native/local_pods` directory. ```sh - zip -r onnxruntime-mobile-c.zip onnxruntime.framework + zip -r onnxruntime-mobile-c.zip . ``` 4. To verify, open iOS Simulator and run this command from `/js/react_native/ios`. Change a destination to specify a running iOS Simulator. ```sh pod install - xcodebuild test -workspace OnnxruntimeModule.xcworkspace -scheme OnnxruntimeModuleTest -destination 'platform=iOS Simulator,name=iPhone 11,OS=14.5' + xcodebuild test -workspace OnnxruntimeModule.xcworkspace -scheme OnnxruntimeModuleTest -destination 'platform=iOS Simulator,name=iPhone 11,OS=15.0' ``` 4. Test an example for Android and iOS. In Windows, open Android Emulator first. diff --git a/js/react_native/example/ios/OnnxruntimeModuleExample.xcodeproj/project.pbxproj b/js/react_native/example/ios/OnnxruntimeModuleExample.xcodeproj/project.pbxproj index a79a06abdf..43a2dafa43 100644 --- a/js/react_native/example/ios/OnnxruntimeModuleExample.xcodeproj/project.pbxproj +++ b/js/react_native/example/ios/OnnxruntimeModuleExample.xcodeproj/project.pbxproj @@ -240,8 +240,6 @@ "${BUILT_PRODUCTS_DIR}/ReactCommon/ReactCommon.framework", "${BUILT_PRODUCTS_DIR}/Yoga/yoga.framework", "${BUILT_PRODUCTS_DIR}/glog/glog.framework", - "${PODS_ROOT}/onnxruntime-mobile-c/onnxruntime.framework", - "${BUILT_PRODUCTS_DIR}/onnxruntime-react-native/onnxruntime_react_native.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( @@ -266,8 +264,6 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ReactCommon.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/yoga.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/onnxruntime.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/onnxruntime_react_native.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/js/react_native/example/ios/Podfile b/js/react_native/example/ios/Podfile index 86f4afd679..d497c6e229 100644 --- a/js/react_native/example/ios/Podfile +++ b/js/react_native/example/ios/Podfile @@ -9,7 +9,10 @@ target 'OnnxruntimeModuleExample' do use_react_native!(:path => config["reactNativePath"]) use_frameworks! - pod 'onnxruntime-mobile-c', :podspec => '../../onnxruntime-mobile-c.podspec' + + if File.exist?('../../local_pods/onnxruntime-mobile-c.zip') + pod 'onnxruntime-mobile-c', :podspec => '../../onnxruntime-mobile-c.podspec' + end pod 'onnxruntime-react-native', :path => '../..' inherit! :search_paths diff --git a/js/react_native/ios/OnnxruntimeModule.xcodeproj/project.pbxproj b/js/react_native/ios/OnnxruntimeModule.xcodeproj/project.pbxproj index 3792eece99..55e1f08e6d 100644 --- a/js/react_native/ios/OnnxruntimeModule.xcodeproj/project.pbxproj +++ b/js/react_native/ios/OnnxruntimeModule.xcodeproj/project.pbxproj @@ -237,7 +237,7 @@ "${PODS_ROOT}/Target Support Files/Pods-OnnxruntimeModuleTest/Pods-OnnxruntimeModuleTest-frameworks.sh", "${BUILT_PRODUCTS_DIR}/DoubleConversion/DoubleConversion.framework", "${BUILT_PRODUCTS_DIR}/FBReactNativeSpec/FBReactNativeSpec.framework", - "${BUILT_PRODUCTS_DIR}/Folly/folly.framework", + "${BUILT_PRODUCTS_DIR}/RCT-Folly/folly.framework", "${BUILT_PRODUCTS_DIR}/RCTTypeSafety/RCTTypeSafety.framework", "${BUILT_PRODUCTS_DIR}/React-Core/React.framework", "${BUILT_PRODUCTS_DIR}/React-CoreModules/CoreModules.framework", @@ -253,10 +253,12 @@ "${BUILT_PRODUCTS_DIR}/React-jsi/jsi.framework", "${BUILT_PRODUCTS_DIR}/React-jsiexecutor/jsireact.framework", "${BUILT_PRODUCTS_DIR}/React-jsinspector/jsinspector.framework", + "${BUILT_PRODUCTS_DIR}/React-logger/logger.framework", + "${BUILT_PRODUCTS_DIR}/React-perflogger/reactperflogger.framework", "${BUILT_PRODUCTS_DIR}/ReactCommon/ReactCommon.framework", "${BUILT_PRODUCTS_DIR}/Yoga/yoga.framework", + "${BUILT_PRODUCTS_DIR}/fmt/fmt.framework", "${BUILT_PRODUCTS_DIR}/glog/glog.framework", - "${PODS_ROOT}/onnxruntime-mobile-c/onnxruntime.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( @@ -278,10 +280,12 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/jsi.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/jsireact.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/jsinspector.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/logger.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/reactperflogger.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ReactCommon.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/yoga.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/fmt.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/onnxruntime.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/js/react_native/onnxruntime-mobile-c.podspec b/js/react_native/onnxruntime-mobile-c.podspec index 22754a18cb..41400be8ce 100644 --- a/js/react_native/onnxruntime-mobile-c.podspec +++ b/js/react_native/onnxruntime-mobile-c.podspec @@ -5,17 +5,24 @@ package = JSON.parse(File.read(File.join(__dir__, "package.json"))) Pod::Spec.new do |spec| spec.name = "onnxruntime-mobile-c" spec.version = package["version"] - spec.summary = "ONNX Runtime C/C++ Package" + spec.summary = "ONNX Runtime Mobile C/C++ Pod" spec.description = <<-DESC - ONNX Runtime C/C++ framework pod. - DESC + A pod for the ONNX Runtime Mobile C/C++ library. + DESC spec.homepage = "https://github.com/microsoft/onnxruntime" - spec.license = { :type => 'MIT' } + spec.license = { :type => "MIT", :file => "LICENSE" } spec.authors = { "ONNX Runtime" => "onnxruntime@microsoft.com" } - spec.platform = :ios, '13.0' + spec.platform = :ios, '11.0' # if you are going to use a file as the spec.source, add 'file:' before your file path spec.source = { :http => 'file:' + __dir__ + '/local_pods/onnxruntime-mobile-c.zip' } - spec.vendored_frameworks = 'onnxruntime.framework' - spec.source_files = 'onnxruntime.framework/Headers/*.h' -end + spec.vendored_frameworks = "onnxruntime.xcframework" + spec.static_framework = true + spec.weak_framework = [ "CoreML" ] + spec.source_files = "Headers/*.h" + spec.preserve_paths = [ "LICENSE" ] + spec.library = "c++" + spec.pod_target_xcconfig = { + "OTHER_CPLUSPLUSFLAGS" => "-fvisibility=hidden -fvisibility-inlines-hidden", + } +end \ No newline at end of file diff --git a/js/react_native/onnxruntime-react-native.podspec b/js/react_native/onnxruntime-react-native.podspec index 27b56dd6dc..6e3e55b34c 100644 --- a/js/react_native/onnxruntime-react-native.podspec +++ b/js/react_native/onnxruntime-react-native.podspec @@ -3,6 +3,8 @@ require "json" package = JSON.parse(File.read(File.join(__dir__, "package.json"))) Pod::Spec.new do |spec| + spec.static_framework = true + spec.name = "onnxruntime-react-native" spec.version = package["version"] spec.summary = package["description"]