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 support for setting/getting main thread checker related flags for launch and test actions. #619

Merged
merged 2 commits into from
Oct 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

##### Enhancements

* None.
* Add support for disableMainThreadChecker and stopOnEveryMainThreadCheckerIssue flags
[Jacek Suliga](https://github.com/jmkk)
[#619](https://github.com/CocoaPods/Xcodeproj/pull/619)

##### Bug Fixes

Expand Down
34 changes: 34 additions & 0 deletions lib/xcodeproj/scheme/launch_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,40 @@ def allow_location_simulation=(flag)
@xml_element.attributes['allowLocationSimulation'] = bool_to_string(flag)
end

# @return [Bool]
# Whether this Build Action should disable detection of UI API misuse
# from background threads
#
def disable_main_thread_checker?
string_to_bool(@xml_element.attributes['disableMainThreadChecker'])
end

# @param [Bool] flag
# Set whether this Build Action should disable detection of UI API misuse
# from background threads
#
def disable_main_thread_checker=(flag)
@xml_element.attributes['disableMainThreadChecker'] = bool_to_string(flag)
end

# @return [Bool]
# Whether UI API misuse from background threads detection should pause execution.
# This flag is ignored when the thread checker disabled
# ([disable_main_thread_checker] flag).
#
def stop_on_every_main_thread_checker_issue?
string_to_bool(@xml_element.attributes['stopOnEveryMainThreadCheckerIssue'])
end

# @param [Bool] flag
# Set whether UI API misuse from background threads detection should pause execution.
# This flag is ignored when the thread checker disabled
# ([disable_main_thread_checker] flag).
#
def stop_on_every_main_thread_checker_issue=(flag)
@xml_element.attributes['stopOnEveryMainThreadCheckerIssue'] = bool_to_string(flag)
end

# @return [String]
# The launch automatically substyle
#
Expand Down
16 changes: 16 additions & 0 deletions lib/xcodeproj/scheme/test_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ def should_use_launch_scheme_args_env=(flag)
@xml_element.attributes['shouldUseLaunchSchemeArgsEnv'] = bool_to_string(flag)
end

# @return [Bool]
# Whether this Test Action should disable detection of UI API misuse
# from background threads
#
def disable_main_thread_checker?
string_to_bool(@xml_element.attributes['disableMainThreadChecker'])
end

# @param [Bool] flag
# Set whether this Test Action should disable detection of UI API misuse
# from background threads
#
def disable_main_thread_checker=(flag)
@xml_element.attributes['disableMainThreadChecker'] = bool_to_string(flag)
end

# @return [Bool]
# Whether Clang Code Coverage is enabled ('Gather coverage data' turned ON)
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
disableMainThreadChecker = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
Expand Down Expand Up @@ -56,6 +57,8 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
disableMainThreadChecker = "YES"
stopOnEveryMainThreadCheckerIssue = "YES"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
Expand Down
2 changes: 2 additions & 0 deletions spec/scheme/launch_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ module Xcodeproj

action.xml_element.attributes['buildConfiguration'].should == 'Debug'
action.xml_element.attributes['allowLocationSimulation'].should == 'YES'
action.xml_element.attributes['disableMainThreadChecker'].nil?
action.xml_element.attributes['stopOnEveryMainThreadCheckerIssue'].nil?
end

it 'raises if created with an invalid XML node' do
Expand Down
2 changes: 2 additions & 0 deletions spec/scheme/test_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Xcodeproj
test_action.xml_element.attributes['selectedLauncherIdentifier'].should == 'Xcode.DebuggerFoundation.Launcher.LLDB'
test_action.xml_element.attributes['shouldUseLaunchSchemeArgsEnv'].should == 'YES'
test_action.xml_element.attributes['buildConfiguration'].should == 'Debug'
test_action.xml_element.attributes['disableMainThreadChecker'].nil?
end

it 'raises if created with an invalid XML node' do
Expand All @@ -28,6 +29,7 @@ module Xcodeproj
extend SpecHelper::XCScheme
specs_for_bool_attr(:should_use_launch_scheme_args_env => 'shouldUseLaunchSchemeArgsEnv')
specs_for_bool_attr(:code_coverage_enabled => 'codeCoverageEnabled')
specs_for_bool_attr(:disable_main_thread_checker => 'disableMainThreadChecker')

it '#testables' do
project = Xcodeproj::Project.new('/foo/bar/baz.xcodeproj')
Expand Down
3 changes: 3 additions & 0 deletions spec/scheme_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module ProjectSpecs
it 'Properly map the scheme\'s TestAction' do
@scheme.test_action.should_use_launch_scheme_args_env?.should == true
@scheme.test_action.build_configuration.should == 'Debug'
@scheme.test_action.disable_main_thread_checker?.should == true

@scheme.test_action.testables.count.should == 0
@scheme.test_action.macro_expansions.count.should == 1
Expand All @@ -65,6 +66,8 @@ module ProjectSpecs
it 'Properly map the scheme\'s LaunchAction' do
@scheme.launch_action.allow_location_simulation?.should == true
@scheme.launch_action.build_configuration.should == 'Debug'
@scheme.launch_action.disable_main_thread_checker?.should == true
@scheme.launch_action.stop_on_every_main_thread_checker_issue?.should == true

bpr = @scheme.launch_action.buildable_product_runnable
bpr.class.should == Xcodeproj::XCScheme::BuildableProductRunnable
Expand Down