Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tvOS support #187

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 42 additions & 3 deletions .travis.yml
@@ -1,6 +1,45 @@
os: osx
osx_image: xcode8.3

language: objective-c
osx_image: xcode611

before_install:
- gem install xcpretty -N --no-ri --no-rdoc

env:
global:
- PROJECT=Expecta.xcodeproj
- IOS_SCHEME="Expecta-iOS"
- IOS_SCHEME_STATIC="libExpecta-iOS"
- MACOS_SCHEME="Expecta"
- MACOS_SCHEME_STATIC="libExpecta"
- TVOS_SCHEME="Expecta-tvOS"

- IOS_SDK=iphonesimulator10.3
- MACOS_SDK=macosx10.12
- TVOS_SDK=appletvsimulator10.2

matrix:
- SCHEME="$IOS_SCHEME" SDK="$IOS_SDK" DESTINATION="OS=10.3,name=iPhone 7"
- SCHEME="$IOS_SCHEME_STATIC" SDK="$IOS_SDK" DESTINATION="OS=10.3,name=iPhone 7"

- SCHEME="$MACOS_SCHEME" SDK="$MACOS_SDK" DESTINATION="arch=x86_64"
- SCHEME="$MACOS_SCHEME_STATIC" SDK="$MACOS_SDK" DESTINATION="arch=x86_64"

- SCHEME="$TVOS_SCHEME" SDK="$TVOS_SDK" DESTINATION="OS=10.0,name=Apple TV 1080p"

script:
- rake clean
- Tests/Support/objc-build-scripts/cibuild
- set -o pipefail
- xcodebuild -version
- xcodebuild -showsdks
- instruments -s devices

# Build and Test for Debug
- |
xcodebuild build-for-testing -configuration Debug -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" | xcpretty
xcodebuild test-without-building -configuration Debug -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" | xcpretty

# Build and Test for Release
- |
xcodebuild build-for-testing -configuration Release -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" | xcpretty
xcodebuild test-without-building -configuration Release -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" | xcpretty
729 changes: 683 additions & 46 deletions Expecta.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
99 changes: 99 additions & 0 deletions Expecta.xcodeproj/xcshareddata/xcschemes/Expecta-tvOS.xcscheme
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ADCD45551E9650BC006C8106"
BuildableName = "Expecta-tvOS.framework"
BlueprintName = "Expecta-tvOS"
ReferencedContainer = "container:Expecta.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ADCD455D1E9650BC006C8106"
BuildableName = "Expecta-tvOSTests.xctest"
BlueprintName = "Expecta-tvOSTests"
ReferencedContainer = "container:Expecta.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ADCD45551E9650BC006C8106"
BuildableName = "Expecta-tvOS.framework"
BlueprintName = "Expecta-tvOS"
ReferencedContainer = "container:Expecta.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ADCD45551E9650BC006C8106"
BuildableName = "Expecta-tvOS.framework"
BlueprintName = "Expecta-tvOS"
ReferencedContainer = "container:Expecta.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ADCD45551E9650BC006C8106"
BuildableName = "Expecta-tvOS.framework"
BlueprintName = "Expecta-tvOS"
ReferencedContainer = "container:Expecta.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion Expecta.xcodeproj/xcshareddata/xcschemes/Expecta.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
88 changes: 66 additions & 22 deletions Rakefile
Expand Up @@ -64,6 +64,34 @@ def lipo(bin1, bin2, output)
execute "xcrun lipo -create '#{bin1}' '#{bin2}' -output '#{output}'"
end

def generate_universal_framework(platform, output_dir, framework_simulator, framework_device)
puts_green "\n=== GENERATE UNIVERSAL #{platform} FRAMEWORK (Device/Simulator) ==="
execute "mkdir -p '#{output_dir}'"
execute "cp -a '#{framework_device}' '#{output_dir}'"

framework_name = Pathname.new(framework_device).basename.to_s
universal_framework = File.join(output_dir, framework_name)

lipo("#{framework_device}/Expecta", "#{framework_simulator}/Expecta", "#{universal_framework}/Expecta")

puts_green "\n=== CODESIGN #{platform} FRAMEWORK ==="
execute "xcrun codesign --force --sign \"#{code_signing_identity}\" '#{universal_framework}'"

"#{universal_framework}"
end

def generate_universal_static_library(platform, output_dir, static_library_simulator, static_library_device)
puts_green "\n=== GENERATE UNIVERSAL #{platform} STATIC LIBRARY (Device/Simulator) ==="
execute "mkdir -p '#{output_dir}'"
execute "cp -a '#{static_library_device}' '#{output_dir}'"

static_library_name = Pathname.new(static_library_device).basename.to_s
universal_static_library = File.join(output_dir, static_library_name)
lipo(static_library_device, static_library_simulator, universal_static_library)

"#{universal_static_library}"
end

def puts_green(str)
puts "#{GREEN_COLOR}#{str}#{NO_COLOR}"
end
Expand All @@ -85,42 +113,54 @@ desc 'build'
task :build => :clean do |t|
puts_green "=== BUILD ==="

osx_framework = build_framework('Expecta', 'macosx')
ios_sim_framework = build_framework('Expecta-iOS', 'iphonesimulator')
ios_framework = build_framework('Expecta-iOS', 'iphoneos')
osx_framework = build_framework('Expecta', 'macosx')
ios_sim_framework = build_framework('Expecta-iOS', 'iphonesimulator')
ios_framework = build_framework('Expecta-iOS', 'iphoneos')
tvos_sim_framework = build_framework('Expecta-tvOS', 'appletvsimulator')
tvos_framework = build_framework('Expecta-tvOS', 'appletvos')

osx_static_lib = build_static_lib('libExpecta', 'macosx')
ios_sim_static_lib = build_static_lib('libExpecta-iOS', 'iphonesimulator')
ios_static_lib = build_static_lib('libExpecta-iOS', 'iphoneos')
osx_static_lib = build_static_lib('libExpecta', 'macosx')
ios_sim_static_lib = build_static_lib('libExpecta-iOS', 'iphonesimulator')
ios_static_lib = build_static_lib('libExpecta-iOS', 'iphoneos')

ios_build_path = Pathname.new(ios_framework).parent.to_s
# ios_build_path = Pathname.new(ios_framework).parent.to_s
ios_univ_build_path = "Expecta/build/#{CONFIGURATION}-ios-universal"
ios_univ_framework = generate_universal_framework("iOS", ios_univ_build_path, ios_sim_framework, ios_framework)
ios_univ_static_lib = generate_universal_static_library("iOS", ios_univ_build_path, ios_sim_static_lib, ios_static_lib)
tvos_univ_build_path = "Expecta/build/#{CONFIGURATION}-tvos-universal"
tvos_univ_framework = generate_universal_framework("tvOS", tvos_univ_build_path, tvos_sim_framework, tvos_framework)

# puts_green "\n=== GENERATE UNIVERSAL iOS BINARY (Device/Simulator) ==="
# execute "mkdir -p '#{ios_univ_build_path}'"
# execute "cp -a '#{ios_framework}' '#{ios_univ_build_path}'"
# execute "cp -a '#{ios_static_lib}' '#{ios_univ_build_path}'"
#
# ios_framework_name = Pathname.new(ios_framework).basename.to_s
# ios_static_lib_name = Pathname.new(ios_static_lib).basename.to_s
#
# ios_univ_framework = File.join(ios_univ_build_path, ios_framework_name)
# ios_univ_static_lib = File.join(ios_univ_build_path, ios_static_lib_name)
#
# lipo("#{ios_framework}/Expecta", "#{ios_sim_framework}/Expecta", "#{ios_univ_framework}/Expecta")
# lipo(ios_static_lib, ios_sim_static_lib, ios_univ_static_lib)
#
# puts_green "\n=== CODESIGN iOS FRAMEWORK ==="
# execute "xcrun codesign --force --sign \"#{code_sign_identity}\" '#{ios_univ_framework}'"

puts_green "\n=== GENERATE UNIVERSAL iOS BINARY (Device/Simulator) ==="
execute "mkdir -p '#{ios_univ_build_path}'"
execute "cp -a '#{ios_framework}' '#{ios_univ_build_path}'"
execute "cp -a '#{ios_static_lib}' '#{ios_univ_build_path}'"

ios_framework_name = Pathname.new(ios_framework).basename.to_s
ios_static_lib_name = Pathname.new(ios_static_lib).basename.to_s

ios_univ_framework = File.join(ios_univ_build_path, ios_framework_name)
ios_univ_static_lib = File.join(ios_univ_build_path, ios_static_lib_name)

lipo("#{ios_framework}/Expecta", "#{ios_sim_framework}/Expecta", "#{ios_univ_framework}/Expecta")
lipo(ios_static_lib, ios_sim_static_lib, ios_univ_static_lib)

puts_green "\n=== CODESIGN iOS FRAMEWORK ==="
execute "xcrun codesign --force --sign \"#{code_sign_identity}\" '#{ios_univ_framework}'"

puts_green "\n=== COPY PRODUCTS ==="
execute "yes | rm -rf Products"
execute "mkdir -p Products/ios"
execute "mkdir -p Products/osx"
execute "mkdir -p Products/tvos"

execute "cp -a #{osx_framework} Products/osx"
execute "cp -a #{osx_static_lib} Products/osx"
execute "cp -a #{ios_univ_framework} Products/ios"
execute "cp -a #{ios_univ_static_lib} Products/ios"
execute "cp -a #{tvos_univ_framework} Products/tvos"

execute "cp -a #{osx_framework}/Headers/* Products"
puts "\n** BUILD SUCCEEDED **"
end
Expand All @@ -133,6 +173,10 @@ namespace 'specs' do
task :osx => :clean do |t|
test("Expecta")
end

task :tvos => :clean do |t|
test("Expecta-tvOS")
end
end

task :default => [:build]