Skip to content

Commit

Permalink
Merge 148b958 into 7abb5df
Browse files Browse the repository at this point in the history
  • Loading branch information
ericksli committed Sep 23, 2016
2 parents 7abb5df + 148b958 commit b954891
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/cocoapods-packager/builder.rb
Expand Up @@ -73,6 +73,8 @@ def build_dynamic_framework(platform, defines, output)
clean_directory_for_dynamic_build
if platform.name == :ios
build_dynamic_framework_for_ios(platform, defines, output)
elsif platform.name == :tvos
build_dynamic_framework_for_tvos(platform, defines, output)
else
build_dynamic_framework_for_mac(platform, defines, output)
end
Expand Down Expand Up @@ -109,6 +111,27 @@ def build_dynamic_framework_for_ios(platform, defines, output)
`mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{platform.name}`
end

def build_dynamic_framework_for_tvos(platform, defines, output)
# Specify frameworks to link and search paths
linker_flags = static_linker_flags_in_sandbox
defines = "#{defines} OTHER_LDFLAGS='$(inherited) #{linker_flags.join(' ')}'"

# Build Target Dynamic Framework for both device and Simulator
device_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\""
device_options = tvos_build_options << ' -sdk appletvos'
xcodebuild(device_defines, device_options, 'build', @spec.name.to_s, @dynamic_sandbox_root.to_s)

sim_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build-sim\" ONLY_ACTIVE_ARCH=NO"
xcodebuild(sim_defines, '-sdk appletvsimulator', 'build-sim', @spec.name.to_s, @dynamic_sandbox_root.to_s)

# Combine architectures
`lipo #{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name} #{@dynamic_sandbox_root}/build-sim/#{@spec.name}.framework/#{@spec.name} -create -output #{output}`

FileUtils.mkdir(platform.name.to_s)
`mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{platform.name}`
`mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{platform.name}`
end

def build_dynamic_framework_for_mac(platform, defines, _output)
# Specify frameworks to link and search paths
linker_flags = static_linker_flags_in_sandbox
Expand All @@ -126,6 +149,8 @@ def build_dynamic_framework_for_mac(platform, defines, _output)
def build_sim_libraries(platform, defines)
if platform.name == :ios
xcodebuild(defines, '-sdk iphonesimulator', 'build-sim')
elsif platform.name == :tvos
xcodebuild(defines, '-sdk appletvsimulator', 'build-sim')
end
end

Expand Down Expand Up @@ -169,6 +194,8 @@ def compile(platform)

if platform.name == :ios
options = ios_build_options
elsif platform == :tvos
options = tvos_build_options
end

xcodebuild(defines, options)
Expand Down Expand Up @@ -275,6 +302,10 @@ def ios_build_options
"ARCHS=\'x86_64 i386 arm64 armv7 armv7s\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
end

def tvos_build_options
"ARCHS=\'x86_64 arm64\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
end

def xcodebuild(defines = '', args = '', build_dir = 'build', target = 'Pods-packager', project_root = @static_sandbox_root, config = @config)
if defined?(Pod::DONT_CODESIGN)
args = "#{args} CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO"
Expand Down

0 comments on commit b954891

Please sign in to comment.