working cocoa pod with framework

This commit is contained in:
Mautisim Munir 2022-11-05 22:28:00 +05:00
parent 2c01e84955
commit d29e3c01a9
9 changed files with 178 additions and 116 deletions

View File

@ -528,11 +528,11 @@ load("@build_bazel_rules_android//android:rules.bzl", "android_ndk_repository",
android_sdk_repository( android_sdk_repository(
name = "androidsdk", name = "androidsdk",
build_tools_version = "30.0.3", build_tools_version = "30.0.3",
path = "/Users/tj/Library/Android/sdk", # Path to Android SDK, optional if $ANDROID_HOME is set # path = "/Users/tj/Library/Android/sdk", # Path to Android SDK, optional if $ANDROID_HOME is set
) )
android_ndk_repository( android_ndk_repository(
name = "androidndk", # Required. Name *must* be "androidndk". name = "androidndk", # Required. Name *must* be "androidndk".
api_level = 21, api_level = 21,
path = "/Users/tj/Library/Android/sdk/ndk/21.4.7075529", # Optional. Can be omitted if `ANDROID_NDK_HOME` environment variable is set. # path = "/Users/tj/Library/Android/sdk/ndk/21.4.7075529", # Optional. Can be omitted if `ANDROID_NDK_HOME` environment variable is set.
) )

View File

@ -1,10 +1,12 @@
# Uncomment the next line to define a global platform for your project # Uncomment the next line to define a global platform for your project
# platform :ios, '9.0' # platform :ios, '9.0'
source 'https://github.com/copper-labs/CocoaSpecs.git'
target 'PoseTrackingLindera' do target 'PoseTrackingLindera' do
# Comment the next line if you don't want to use dynamic frameworks # Comment the next line if you don't want to use dynamic frameworks
use_frameworks! use_frameworks!
pod 'LinderaDetection', :path => 'LinderaDetection'
pod 'LinderaDetection' #, :path => 'LinderaDetection'
# Pods for PoseTrackingLindera # Pods for PoseTrackingLindera

View File

@ -6,6 +6,10 @@ load(
"ios_static_framework", "ios_static_framework",
"ios_unit_test", "ios_unit_test",
) )
load(
"@build_bazel_rules_apple//apple:apple.bzl",
"apple_static_xcframework",
)
load( load(
"//mediapipe/examples/ios:bundle_id.bzl", "//mediapipe/examples/ios:bundle_id.bzl",
"BUNDLE_ID_PREFIX", "BUNDLE_ID_PREFIX",
@ -67,10 +71,22 @@ ios_static_framework(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//mediapipe/objc/solutions/posetracking_gpu:posetracking_gpu_solution", "//mediapipe/objc/solutions/posetracking_gpu:posetracking_gpu_solution",
"//mediapipe/calculators/core:flow_limiter_calculator",
# "//third_party:opencv", # "//third_party:opencv",
"@ios_opencv//:OpencvFramework", # "@ios_opencv//:OpencvFramework",
],
)
apple_static_xcframework(
name = "MPPoseTrackingXC",
bundle_name = "MPPoseTracking",
minimum_os_versions = {"ios": "12.0"},
public_hdrs = MPP_HEADERS + MP_GEN_IOS_HEADERS,
deps = [
"//mediapipe/objc/solutions/posetracking_gpu:posetracking_gpu_solution",
# "//third_party:opencv",
# "@ios_opencv//:OpencvFramework",
], ],
) )
@ -133,10 +149,15 @@ genrule(
objc_library( objc_library(
name = "posetracking_gpu_solution", name = "posetracking_gpu_solution",
srcs = glob([ srcs = [
"*.h", "PoseTrackingOptions.mm",
"*.mm", "PoseTrackingResults.mm",
]), "PoseTracking.mm",
] + select({
"//mediapipe:ios_i386": [],
"//mediapipe:ios_x86_64": [],
"//conditions:default": [],
}),
hdrs = MPP_HEADERS + MP_GEN_IOS_HEADERS, hdrs = MPP_HEADERS + MP_GEN_IOS_HEADERS,
copts = [ copts = [
"-Wno-shorten-64-to-32", "-Wno-shorten-64-to-32",
@ -168,13 +189,13 @@ objc_library(
"//mediapipe/objc:mediapipe_framework_ios", "//mediapipe/objc:mediapipe_framework_ios",
"//mediapipe/objc:mediapipe_input_sources_ios", "//mediapipe/objc:mediapipe_input_sources_ios",
"//mediapipe/objc:mediapipe_layer_renderer", "//mediapipe/objc:mediapipe_layer_renderer",
"//mediapipe/graphs/pose_tracking:pose_tracking_gpu_deps",
"//mediapipe/framework/formats:landmark_cc_proto",
"calculator_registry",
] + select({ ] + select({
"//mediapipe:ios_i386": [], "//mediapipe:ios_i386": [],
"//mediapipe:ios_x86_64": [], "//mediapipe:ios_x86_64": [],
"//conditions:default": [ "//conditions:default": [
"//mediapipe/graphs/pose_tracking:pose_tracking_gpu_deps",
"//mediapipe/framework/formats:landmark_cc_proto",
"calculator_registry",
], ],
}), }),
alwayslink = True, alwayslink = True,

View File

@ -20,10 +20,13 @@ genrule(
srcs = [ srcs = [
"//mediapipe/objc/solutions/posetracking_gpu:MPPoseTrackingHeaderPatched", "//mediapipe/objc/solutions/posetracking_gpu:MPPoseTrackingHeaderPatched",
"LinderaDetection.podspec", "LinderaDetection.podspec",
"@ios_opencv//:OpencvFrameworkContents",
] + glob(["*.swift"]), ] + glob(["*.swift"]),
outs = ["LinderaDetection.zip"], outs = ["LinderaDetection.zip"],
cmd = """ cmd = """
mkdir mediapipe/swift/solutions/lindera/frameworks mkdir mediapipe/swift/solutions/lindera/frameworks
cp -r external/ios_opencv/opencv2.framework mediapipe/swift/solutions/lindera/frameworks
unzip $(location //mediapipe/objc/solutions/posetracking_gpu:MPPoseTrackingHeaderPatched) -d mediapipe/swift/solutions/lindera/frameworks unzip $(location //mediapipe/objc/solutions/posetracking_gpu:MPPoseTrackingHeaderPatched) -d mediapipe/swift/solutions/lindera/frameworks
cd mediapipe/swift/solutions/lindera/ cd mediapipe/swift/solutions/lindera/

View File

@ -1,6 +1,7 @@
// This is the copperlabs posetracking api built in objective c // This is the copperlabs posetracking api built in objective c
import MPPoseTracking
import UIKit import UIKit
#if arch(arm64)
import MPPoseTracking
/// A helper class to run the Pose Tracking API /// A helper class to run the Pose Tracking API
@ -265,3 +266,6 @@ extension Asensei3DPose {
// self.z = vector.y // self.z = vector.y
// } // }
//} //}
#else
final public class Lindera{}
#endif

View File

@ -16,15 +16,15 @@ Pod::Spec.new do |spec|
# #
spec.name = "LinderaDetection" spec.name = "LinderaDetection"
spec.version = "0.0.1" spec.version = "0.0.2"
spec.summary = "LinderaDetection is a simple yet powerful interface to run AI Health Solutions" spec.summary = "LinderaDetection is a simple yet powerful interface to run AI Fitness Solutions"
# This description is used to generate tags and improve search results. # This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus? # * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point. # * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below. # * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it! # * Finally, don't worry about the indent, CocoaPods strips it!
spec.description = "LinderaDetection is a simple yet powerful interface to run AI Health Solutions" spec.description = "LinderaDetection is a simple yet powerful interface to run AI Fitness Solutions. It is powered by Mediapipe."
spec.homepage = "https://github.com/udamaster/mediapipe" spec.homepage = "https://github.com/udamaster/mediapipe"
# spec.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" # spec.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
@ -37,8 +37,11 @@ Pod::Spec.new do |spec|
# Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
# #
spec.license = "MIT (example)" spec.license = { :type => 'MIT', :text => <<-LICENSE
spec.license = { :type => "MIT"} Copyright 2012
Permission is granted to...
LICENSE
}
# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
@ -59,7 +62,7 @@ Pod::Spec.new do |spec|
# If this Pod runs only on iOS or OS X, then specify the platform and # If this Pod runs only on iOS or OS X, then specify the platform and
# the deployment target. You can optionally include the target after the platform. # the deployment target. You can optionally include the target after the platform.
# #
spec.swift_versions = ["4.0"]
# spec.platform = :ios # spec.platform = :ios
spec.platform = :ios, "12.0" spec.platform = :ios, "12.0"
@ -74,9 +77,12 @@ Pod::Spec.new do |spec|
# #
# Specify the location from where the source should be retrieved. # Specify the location from where the source should be retrieved.
# Supports git, hg, bzr, svn and HTTP. # Supports git, hg, bzr, svn and HTTP.
#
spec.source = { :http => 'https://edge-engine-store.s3.amazonaws.com/libs/ios/EdgeEngine/pod/EdgeEngine.zip' } spec.source = { :http => 'https://github.com/copper-labs/iOSFramework/releases/download/0.1.0/LinderaDetection.zip' }
# for quickly testing locally
# spec.source = { :http => 'http://127.0.0.1:8000/LinderaDetection.zip' }
# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
# #
@ -128,14 +134,21 @@ Pod::Spec.new do |spec|
# spec.requires_arc = true # spec.requires_arc = true
# spec.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } # spec.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
spec.dependency "OpenCV", "3.2" # spec.dependency "OpenCV", "3.2"
spec.static_framework = true spec.static_framework = true
# spec.preserve_paths = "frameworks/**/*"
spec.ios.vendored_frameworks = 'frameworks/*.framework' spec.ios.vendored_frameworks = 'frameworks/*.framework'
# spec.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-lc++' } spec.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' ,
# spec.user_target_xcconfig = {'OTHER_LDFLAGS' => '-lc++' } 'OTHER_LDFLAGS' => '$(inherited) -force_load $(PODS_ROOT)/LinderaDetection/frameworks/MPPoseTracking.framework/MPPoseTracking' }
spec.user_target_xcconfig = {
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' ,
'OTHER_LDFLAGS' => '$(inherited) -force_load $(PODS_ROOT)/LinderaDetection/frameworks/MPPoseTracking.framework/MPPoseTracking' }
spec.libraries = 'stdc++' spec.libraries = 'stdc++'
# ――― Temporary Architecture fixes
spec.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
spec.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } # spec.xcconfig = {
# 'FRAMEWORK_SEARCH_PATH[sdk=iphoneos*]' => '$(inherited) "$(PODS_ROOT)/frameworks"',
# 'OTHERCFLAGS[sdk=iphoneos*]' => '$(inherited) -iframework "$(PODS_ROOT)/frameworks"',
# 'OTHER_LDFLAGS[sdk=iphoneos*]' => '$(inherited) -framework frameworks'
# }
end end

View File

@ -0,0 +1,13 @@
## CocoaPods
### Building Pod zipfile
```shell
bazel build -c opt --config=ios_fat --cxxopt=--std=c++17 --copt=-fembed-bitcode //mediapipe/swift/solutions/lindera:podgen
```
### Pushing Pods
here clspecs is the name of pod specs repository
```shell
pod repo push clspecs LinderaDetection.podspec --skip-import-validation
```

View File

@ -10,6 +10,12 @@ load(
"apple_static_framework_import", "apple_static_framework_import",
) )
filegroup(
name = "OpencvFrameworkContents",
srcs = glob(["opencv2.framework/**"]),
visibility = ["//visibility:public"],
)
apple_static_framework_import( apple_static_framework_import(
name = "OpencvFramework", name = "OpencvFramework",
framework_imports = glob(["opencv2.framework/**"]), framework_imports = glob(["opencv2.framework/**"]),