Skip to content

Commit

Permalink
Fix launch scheme params (#224)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
igor-makarov authored Feb 24, 2022
1 parent 462a9ae commit d32ca30
Show file tree
Hide file tree
Showing 16 changed files with 177 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Gemfile*.lock
/Gemfile*.lock
/gemfiles/Gemfile*.lock

*.gem
*.rbc
/.config
Expand Down
4 changes: 1 addition & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ Metrics/ModuleLength:
- 'spec/**/*'

Metrics/AbcSize:
Max: 30
Exclude:
- 'lib/xcake/ui.rb'
Enabled: false

Metrics/LineLength:
Max: 130
Expand Down
24 changes: 24 additions & 0 deletions example/app/CakeMania/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
*.xcscmblueprint
.DS_Store

Gemfile.lock

*.xcodeproj
2 changes: 1 addition & 1 deletion example/app/CakeMania/Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# just helper variables to use these values in a consistent way across whole file

iOSdeploymentTarget = "8.0"
currentSwiftVersion = "3.0.1" # to set "Use Legacy Swift ..." to "No"
currentSwiftVersion = "4.2"
companyIdentifier = "com.CakeMania"
developmentTeamId = "XYZXYZ" # for automatic debug signing in Xcode 8
testSuffix = "Tst"
Expand Down
5 changes: 5 additions & 0 deletions example/app/CakeMania/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

gemspec path: `git rev-parse --show-toplevel`.chomp
2 changes: 1 addition & 1 deletion example/app/CakeMania/Src/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
24 changes: 24 additions & 0 deletions example/framework/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
*.xcscmblueprint
.DS_Store

Gemfile.lock

*.xcodeproj
2 changes: 1 addition & 1 deletion example/framework/Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# http://www.rubydoc.info/github/jcampbell05/xcake/master/file/docs/Cakefile.md

iOSdeploymentTarget = "8.0"
currentSwiftVersion = "3.0.1" # to set "Use Legacy Swift ..." to "No"
currentSwiftVersion = "4.2"
companyIdentifier = "com.CakeMania"
developmentTeamId = "XYZXYZ" # for automatic debug signing in Xcode 8
testSuffix = "Tst"
Expand Down
5 changes: 5 additions & 0 deletions example/framework/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

gemspec path: `git rev-parse --show-toplevel`.chomp
38 changes: 38 additions & 0 deletions example/framework/Info/CakeFamework.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
22 changes: 22 additions & 0 deletions example/framework/Info/CakeFameworkTst.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Empty file.
36 changes: 36 additions & 0 deletions example/framework/Tst/Main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// CakeManiaTests.swift
// CakeManiaTests
//
// Created by Maxim Khatskevich on 11/25/16.
// Copyright © 2016 CakeMania Inc. All rights reserved.
//

import XCTest
@testable import CakeFamework

class CakeManiaTests: XCTestCase {

override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}

func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}

func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}

}
2 changes: 1 addition & 1 deletion lib/xcake/generator/scheme_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def visit_target(target)
native_scheme = @context.native_object_for(scheme)
native_scheme.name = scheme.name

native_scheme.configure_with_targets(native_target, nil)
native_scheme.configure_with_targets(native_target, nil, launch_target: native_target.launchable_target_type?)

native_project = @context.native_object_for(@project)
native_unit_test_target = native_project.find_unit_test_target_for_target(target)
Expand Down
19 changes: 14 additions & 5 deletions spec/generator/scheme_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module Xcake

allow(@native_project).to receive(:find_unit_test_target_for_target).and_return(@native_unit_test_target)
allow(@native_project).to receive(:find_ui_test_target_for_target).and_return(@native_ui_test_target)
allow(@native_target).to receive(:launchable_target_type?).and_return(false)
allow(@context).to receive(:native_object_for).with(@target).and_return(@native_target)
allow(@context).to receive(:native_object_for).with(@project).and_return(@native_project)
allow(@context).to receive(:native_object_for).with(@scheme).and_return(@native_scheme)
Expand All @@ -51,12 +52,20 @@ module Xcake
end

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

expect(@native_scheme).to receive(:configure_with_targets).with(@native_target, nil)
@generator.visit_target(@target)
expect(@native_scheme).to receive(:configure_with_targets).with(@native_target, nil, launch_target: true)
@generator.visit_target(@target)
end

it 'should not configure as launch target if not launchable' do
allow(@native_target).to receive(:launchable_target_type?).and_return(false)

expect(@native_scheme).to receive(:configure_with_targets).with(@native_target, nil, launch_target: false)
@generator.visit_target(@target)
end
end

it 'should configure with test action' do
Expand Down
2 changes: 1 addition & 1 deletion xcake.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
spec.add_runtime_dependency 'cork'
spec.add_runtime_dependency 'deep_merge'
spec.add_runtime_dependency 'hooks', '~> 0.4.1'
spec.add_runtime_dependency 'xcodeproj', '< 2.0.0', '>= 1.3.0'
spec.add_runtime_dependency 'xcodeproj', '< 2.0.0', '>= 1.7.0'

spec.add_development_dependency 'bundler', '>= 1.10'
spec.add_development_dependency 'os', '~> 1.0'
Expand Down

0 comments on commit d32ca30

Please sign in to comment.