@@ -16,10 +16,11 @@ module XCTask
1616 class FrameworkType
1717 IOS = 'ios'
1818 OSX = 'osx'
19+ WATCHOS = 'watchos'
1920
2021 def self . verify ( type )
21- if type . nil? || ( type != IOS && type != OSX )
22- fail "Unknown framework type. Available types: 'ios', 'osx'."
22+ if type . nil? || ( type != IOS && type != OSX && type != WATCHOS )
23+ fail "Unknown framework type. Available types: 'ios', 'osx', 'watchos' ."
2324 end
2425 end
2526 end
@@ -64,6 +65,8 @@ def build
6465 build_ios_framework
6566 when FrameworkType ::OSX
6667 build_osx_framework
68+ when FrameworkType ::WATCHOS
69+ build_watchos_framework
6770 end
6871 end
6972
@@ -92,6 +95,31 @@ def build_ios_framework
9295 result
9396 end
9497
98+ def build_watchos_framework
99+ framework_paths = [ ]
100+ framework_paths << build_framework ( 'watchos' )
101+ framework_paths << build_framework ( 'watchsimulator' )
102+ final_path = final_framework_path
103+
104+ system ( "rm -rf #{ final_path } && cp -R #{ framework_paths [ 0 ] } #{ final_path } " )
105+
106+ binary_name = File . basename ( @framework_name , '.framework' )
107+ system ( "rm -rf #{ final_path } /#{ binary_name } " )
108+
109+ lipo_command = 'lipo -create'
110+ framework_paths . each do |path |
111+ lipo_command += " #{ path } /#{ binary_name } "
112+ end
113+ lipo_command += " -o #{ final_path } /#{ binary_name } "
114+
115+ result = system ( lipo_command )
116+ unless result
117+ puts 'Failed to lipo watchOS framework.'
118+ exit ( 1 )
119+ end
120+ result
121+ end
122+
95123 def build_osx_framework
96124 build_path = build_framework ( 'macosx' )
97125 final_path = final_framework_path
0 commit comments