Skip to content

Commit d32ca30

Browse files
authored
Fix launch scheme params (#224)
* update CakeMania demo to Swift 4.2 * add separate `.gitignore` for CakeMania example * bump `xcodeproj` minimum version to 1.7.0 * add launch target if launchable * make the framework example complete * disable annoying lint * fix tests + add test
1 parent 462a9ae commit d32ca30

16 files changed

+177
-14
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Gemfile*.lock
1+
/Gemfile*.lock
2+
/gemfiles/Gemfile*.lock
3+
24
*.gem
35
*.rbc
46
/.config

.rubocop.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ Metrics/ModuleLength:
2222
- 'spec/**/*'
2323

2424
Metrics/AbcSize:
25-
Max: 30
26-
Exclude:
27-
- 'lib/xcake/ui.rb'
25+
Enabled: false
2826

2927
Metrics/LineLength:
3028
Max: 130

example/app/CakeMania/.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Xcode
2+
#
3+
build/
4+
*.pbxuser
5+
!default.pbxuser
6+
*.mode1v3
7+
!default.mode1v3
8+
*.mode2v3
9+
!default.mode2v3
10+
*.perspectivev3
11+
!default.perspectivev3
12+
xcuserdata
13+
*.xccheckout
14+
*.moved-aside
15+
DerivedData
16+
*.hmap
17+
*.ipa
18+
*.xcuserstate
19+
*.xcscmblueprint
20+
.DS_Store
21+
22+
Gemfile.lock
23+
24+
*.xcodeproj

example/app/CakeMania/Cakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# just helper variables to use these values in a consistent way across whole file
99

1010
iOSdeploymentTarget = "8.0"
11-
currentSwiftVersion = "3.0.1" # to set "Use Legacy Swift ..." to "No"
11+
currentSwiftVersion = "4.2"
1212
companyIdentifier = "com.CakeMania"
1313
developmentTeamId = "XYZXYZ" # for automatic debug signing in Xcode 8
1414
testSuffix = "Tst"

example/app/CakeMania/Gemfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gemspec path: `git rev-parse --show-toplevel`.chomp

example/app/CakeMania/Src/AppDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1818
// Override point for customization after application launch.
1919
return true
2020
}

example/framework/.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Xcode
2+
#
3+
build/
4+
*.pbxuser
5+
!default.pbxuser
6+
*.mode1v3
7+
!default.mode1v3
8+
*.mode2v3
9+
!default.mode2v3
10+
*.perspectivev3
11+
!default.perspectivev3
12+
xcuserdata
13+
*.xccheckout
14+
*.moved-aside
15+
DerivedData
16+
*.hmap
17+
*.ipa
18+
*.xcuserstate
19+
*.xcscmblueprint
20+
.DS_Store
21+
22+
Gemfile.lock
23+
24+
*.xcodeproj

example/framework/Cakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# http://www.rubydoc.info/github/jcampbell05/xcake/master/file/docs/Cakefile.md
33

44
iOSdeploymentTarget = "8.0"
5-
currentSwiftVersion = "3.0.1" # to set "Use Legacy Swift ..." to "No"
5+
currentSwiftVersion = "4.2"
66
companyIdentifier = "com.CakeMania"
77
developmentTeamId = "XYZXYZ" # for automatic debug signing in Xcode 8
88
testSuffix = "Tst"

example/framework/Gemfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gemspec path: `git rev-parse --show-toplevel`.chomp
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>APPL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
<key>LSRequiresIPhoneOS</key>
22+
<true/>
23+
<key>UILaunchStoryboardName</key>
24+
<string>LaunchScreen</string>
25+
<key>UIMainStoryboardFile</key>
26+
<string>Main</string>
27+
<key>UIRequiredDeviceCapabilities</key>
28+
<array>
29+
<string>armv7</string>
30+
</array>
31+
<key>UISupportedInterfaceOrientations</key>
32+
<array>
33+
<string>UIInterfaceOrientationPortrait</string>
34+
<string>UIInterfaceOrientationLandscapeLeft</string>
35+
<string>UIInterfaceOrientationLandscapeRight</string>
36+
</array>
37+
</dict>
38+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>BNDL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
</dict>
22+
</plist>

example/framework/Src/FrameworkSource.swift

Whitespace-only changes.

example/framework/Tst/Main.swift

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// CakeManiaTests.swift
3+
// CakeManiaTests
4+
//
5+
// Created by Maxim Khatskevich on 11/25/16.
6+
// Copyright © 2016 CakeMania Inc. All rights reserved.
7+
//
8+
9+
import XCTest
10+
@testable import CakeFamework
11+
12+
class CakeManiaTests: XCTestCase {
13+
14+
override func setUp() {
15+
super.setUp()
16+
// Put setup code here. This method is called before the invocation of each test method in the class.
17+
}
18+
19+
override func tearDown() {
20+
// Put teardown code here. This method is called after the invocation of each test method in the class.
21+
super.tearDown()
22+
}
23+
24+
func testExample() {
25+
// This is an example of a functional test case.
26+
// Use XCTAssert and related functions to verify your tests produce the correct results.
27+
}
28+
29+
func testPerformanceExample() {
30+
// This is an example of a performance test case.
31+
self.measure {
32+
// Put the code you want to measure the time of here.
33+
}
34+
}
35+
36+
}

lib/xcake/generator/scheme_generator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def visit_target(target)
1919
native_scheme = @context.native_object_for(scheme)
2020
native_scheme.name = scheme.name
2121

22-
native_scheme.configure_with_targets(native_target, nil)
22+
native_scheme.configure_with_targets(native_target, nil, launch_target: native_target.launchable_target_type?)
2323

2424
native_project = @context.native_object_for(@project)
2525
native_unit_test_target = native_project.find_unit_test_target_for_target(target)

spec/generator/scheme_generator_spec.rb

+14-5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module Xcake
2525

2626
allow(@native_project).to receive(:find_unit_test_target_for_target).and_return(@native_unit_test_target)
2727
allow(@native_project).to receive(:find_ui_test_target_for_target).and_return(@native_ui_test_target)
28+
allow(@native_target).to receive(:launchable_target_type?).and_return(false)
2829
allow(@context).to receive(:native_object_for).with(@target).and_return(@native_target)
2930
allow(@context).to receive(:native_object_for).with(@project).and_return(@native_project)
3031
allow(@context).to receive(:native_object_for).with(@scheme).and_return(@native_scheme)
@@ -51,12 +52,20 @@ module Xcake
5152
end
5253

5354
context 'when configuring native scheme' do
54-
it 'should configure with build target' do
55-
allow(@native_project).to receive(:find_unit_test_target_for_target).and_return(nil)
56-
allow(@native_project).to receive(:find_ui_test_target_for_target).and_return(nil)
55+
context 'should configure with build target' do
56+
it 'should configure as launch target if launchable' do
57+
allow(@native_target).to receive(:launchable_target_type?).and_return(true)
5758

58-
expect(@native_scheme).to receive(:configure_with_targets).with(@native_target, nil)
59-
@generator.visit_target(@target)
59+
expect(@native_scheme).to receive(:configure_with_targets).with(@native_target, nil, launch_target: true)
60+
@generator.visit_target(@target)
61+
end
62+
63+
it 'should not configure as launch target if not launchable' do
64+
allow(@native_target).to receive(:launchable_target_type?).and_return(false)
65+
66+
expect(@native_scheme).to receive(:configure_with_targets).with(@native_target, nil, launch_target: false)
67+
@generator.visit_target(@target)
68+
end
6069
end
6170

6271
it 'should configure with test action' do

xcake.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
2525
spec.add_runtime_dependency 'cork'
2626
spec.add_runtime_dependency 'deep_merge'
2727
spec.add_runtime_dependency 'hooks', '~> 0.4.1'
28-
spec.add_runtime_dependency 'xcodeproj', '< 2.0.0', '>= 1.3.0'
28+
spec.add_runtime_dependency 'xcodeproj', '< 2.0.0', '>= 1.7.0'
2929

3030
spec.add_development_dependency 'bundler', '>= 1.10'
3131
spec.add_development_dependency 'os', '~> 1.0'

0 commit comments

Comments
 (0)