瀏覽代碼

Merge pull request #2 from ParsePlatform/nlutsenko.tvos

Add ability to build tvOS framework with xctask.
Nikita Lutsenko 10 年之前
父節點
當前提交
3da75864b2
共有 1 個文件被更改,包括 30 次插入2 次删除
  1. 30 2
      Scripts/xctask/build_framework_task.rb

+ 30 - 2
Scripts/xctask/build_framework_task.rb

@@ -17,10 +17,11 @@ module XCTask
     IOS = 'ios'
     OSX = 'osx'
     WATCHOS = 'watchos'
+    TVOS = 'tvos'
 
     def self.verify(type)
-      if type.nil? || (type != IOS && type != OSX && type != WATCHOS)
-        fail "Unknown framework type. Available types: 'ios', 'osx', 'watchos'."
+      if type.nil? || (type != IOS && type != OSX && type != WATCHOS && type != TVOS)
+        fail "Unknown framework type. Available types: 'ios', 'osx', 'watchos', 'tvos'."
       end
     end
   end
@@ -67,6 +68,8 @@ module XCTask
         build_osx_framework
       when FrameworkType::WATCHOS
         build_watchos_framework
+      when FrameworkType::TVOS
+        build_tvos_framework
       end
     end
 
@@ -119,6 +122,31 @@ module XCTask
       end
       result
     end
+    
+    def build_tvos_framework
+      framework_paths = []
+      framework_paths << build_framework('appletvos')
+      framework_paths << build_framework('appletvsimulator')
+      final_path = final_framework_path
+
+      system("rm -rf #{final_path} && cp -R #{framework_paths[0]} #{final_path}")
+
+      binary_name = File.basename(@framework_name, '.framework')
+      system("rm -rf #{final_path}/#{binary_name}")
+
+      lipo_command = 'lipo -create'
+      framework_paths.each do |path|
+        lipo_command += " #{path}/#{binary_name}"
+      end
+      lipo_command += " -o #{final_path}/#{binary_name}"
+
+      result = system(lipo_command)
+      unless result
+        puts 'Failed to lipo tvOS framework.'
+        exit(1)
+      end
+      result
+    end
 
     def build_osx_framework
       build_path = build_framework('macosx')