8000 Allow app/test targets to not contain empty .swift files when their d… · CocoaPods/CocoaPods@6985cbf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 6985cbf

Browse files
committed
Allow app/test targets to not contain empty .swift files when their deps use swift
1 parent 0c940a3 commit 6985cbf

File tree

4 files changed

+31
-41
lines changed

4 files changed

+31
-41
lines changed

lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -651,10 +651,6 @@ def create_test_xcconfig_files(test_native_targets, test_resource_bundle_targets
651651
scoped_test_resource_bundle_targets = test_resource_bundle_targets[test_spec.name]
652652
apply_xcconfig_file_ref_to_targets([test_native_target] + scoped_test_resource_bundle_targets, test_xcconfig_file_ref, names)
653653
end
654-
655-
test_native_target.build_configurations.each do |test_native_target_bc|
656-
test_target_swift_debug_hack(test_spec, test_native_target_bc)
657-
end
658654
end
659655
end
660656

@@ -833,18 +829,6 @@ def create_copy_xcframeworks_script
833829
add_file_to_support_group(path)
834830
end
835831

836-
# Manually add `libswiftSwiftOnoneSupport.dylib` as it seems there is an issue with tests that do not include it for Debug configurations.
837-
# Possibly related to Swift module optimization.
838-
#
839-
# @return [void]
840-
#
841-
def test_target_swift_debug_hack(test_spec, test_target_bc)
842-
return unless test_target_bc.debug?
843-
return unless target.dependent_targets_for_test_spec(test_spec).any?(&:uses_swift?)
844-
ldflags = test_target_bc.build_settings['OTHER_LDFLAGS'] ||= '$(inherited)'
845-
ldflags << ' -lswiftSwiftOnoneSupport'
846-
end
847-
848832
# Creates a build phase which links the versioned header folders
849833
# of the OS X into the framework bundle's root root directory.
850834
# This is only necessary because the way how headers are copied

lib/cocoapods/target/build_settings.rb

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -346,18 +346,26 @@ def other_swift_flags_without_swift?
346346
#
347347
# @param [Boolean] test_bundle
348348
#
349-
def _ld_runpath_search_paths(requires_host_target: false, test_bundle: false)
349+
def _ld_runpath_search_paths(requires_host_target: false, test_bundle: false, uses_swift: false)
350+
paths = []
351+
if uses_swift
352+
paths << '/usr/lib/swift'
353+
paths << '$(PLATFORM_DIR)/Developer/Library/Frameworks' if test_bundle
354+
end
350355
if target.platform.symbolic_name == :osx
351-
["'@executable_path/../Frameworks'",
352-
test_bundle ? "'@loader_path/../Frameworks'" : "'@loader_path/Frameworks'"]
356+
paths << "'@executable_path/../Frameworks'"
357+
paths << if test_bundle
358+
"'@loader_path/../Frameworks'"
359+
else
360+
"'@loader_path/Frameworks'"
361+
end
362+
paths << '${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}' if uses_swift
353363
else
354-
paths = [
355-
"'@executable_path/Frameworks'",
356-
"'@loader_path/Frameworks'",
357-
]
364+
paths << "'@executable_path/Frameworks'"
365+
paths << "'@loader_path/Frameworks'"
358366
paths << "'@executable_path/../../Frameworks'" if requires_host_target
359-
paths
360367
end
368+
paths
361369
end
362370
private :_ld_runpath_search_paths
363371

@@ -840,10 +848,15 @@ def linker_names_from_libraries(libraries)
840848

841849
# @return [Array<String>]
842850
define_build_settings_method :library_search_paths_to_import, :memoized => true do
843-
vendored_library_search_paths = vendored_static_library_search_paths + vendored_dynamic_library_search_paths
844-
return vendored_library_search_paths if target.build_as_framework? || !target.should_build?
851+
search_paths = vendored_static_library_search_paths + vendored_dynamic_library_search_paths
852+
if target.uses_swift? || other_swift_flags_without_swift?
853+
search_paths << '/usr/lib/swift'
854+
search_paths << '${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}'
855+
search_paths << '$(PLATFORM_DIR)/Developer/Library/Frameworks' if test_xcconfig?
856+
end
857+
return search_paths if target.build_as_framework? || !target.should_build?
845858

846-
vendored_library_search_paths << target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)
859+
search_paths << target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE)
847860
end
848861

849862
#-------------------------------------------------------------------------#
@@ -939,7 +952,8 @@ def requires_objc_linker_flag?
939952
# @return [Array<String>]
940953
define_build_settings_method :ld_runpath_search_paths, :build_setting => true, :memoized => true do
941954
return if library_xcconfig?
942-
_ld_runpath_search_paths(:test_bundle => test_xcconfig?)
955+
_ld_runpath_search_paths(:test_bundle => test_xcconfig?,
956+
:uses_swift => other_swift_flags_without_swift? || dependent_targets.any?(&:uses_swift?))
943957
end
944958

945959
#-------------------------------------------------------------------------#
@@ -1242,7 +1256,8 @@ def other_swift_flags_without_swift?
12421256
return unless pod_targets.any?(&:build_as_dynamic?) || any_vendored_dynamic_artifacts?
12431257
symbol_type = target.user_targets.map(&:symbol_type).uniq.first
12441258
test_bundle = symbol_type == :octest_bundle || symbol_type == :unit_test_bundle || symbol_type == :ui_test_bundle
1245-
_ld_runpath_search_paths(:requires_host_target => target.requires_host_target?, :test_bundle => test_bundle)
1259+
_ld_runpath_search_paths(:requires_host_target => target.requires_host_target?, :test_bundle => test_bundle,
1260+
:uses_swift => pod_targets.any?(&:uses_swift?))
12461261
end
12471262

12481263
# @return [Boolean]

spec/unit/installer/xcode/pods_project_generator/pod_target_installer_spec.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,6 @@ class PodsProjectGenerator
360360
include 'Unable to install the `WatermelonLib` pod, because the `WatermelonLib-App` target in Xcode would have no sources to compile.'
361361
end
362362

363-
it 'adds swiftSwiftOnoneSupport ld flag to the debug configuration' do
364-
@watermelon_ios_pod_target.stubs(:uses_swift?).returns(true)
365-
@ios_installer.install!
366-
test_native_target = @project.targets[1]
367-
debug_configuration = test_native_target.build_configurations.find(&:debug?)
368-
debug_configuration.build_settings['OTHER_LDFLAGS'].should == '$(inherited) -lswiftSwiftOnoneSupport'
369-
release_configuration = test_native_target.build_configurations.find { |bc| bc.type == :release }
370-
release_configuration.build_settings['OTHER_LDFLAGS'].should.be.nil
371-
end
372-
373363
it 'adds files to build phases correctly depending on the native target' do
374364
@ios_installer.install!
375365
@project.targets.count.should == 9

spec/unit/target/build_settings/aggregate_target_settings_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,15 +404,16 @@ def pod_target(spec, target_definition)
404404

405405
it 'includes default runpath search path list for a host target' do
406406
@target.stubs(:requires_host_target?).returns(true)
407-
@generator.generate.to_hash['LD_RUNPATH_SEARCH_PATHS'].should == "$(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' '@executable_path/../../Frameworks'"
407+
@generator.generate.to_hash['LD_RUNPATH_SEARCH_PATHS'].should == "$(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' '@executable_path/../../Frameworks' " \
408+
'"${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" "$(PLATFORM_DIR)/Developer/Library/Frameworks"'
408409
end
409410

410411
it 'includes correct default runpath search path list for OSX unit test bundle user target' do
411412
@target.stubs(:platform).returns(Platform.new(:osx, '10.10'))
412413
mock_user_target = mock('usertarget')
413414
mock_user_target.stubs(:symbol_type).returns(:unit_test_bundle)
414415
@target.stubs(:user_targets).returns([mock_user_target])
415-
@generator.generate.to_hash['LD_RUNPATH_SEARCH_PATHS'].should == "$(inherited) '@executable_path/../Frameworks' '@loader_path/../Frameworks'"
416+
@generator.generate.to_hash['LD_RUNPATH_SEARCH_PATHS'].should == "$(inherited) '@executable_path/../Frameworks' '@loader_path/../Frameworks' \"${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}\""
416417
end
417418

418419
it 'includes correct default runpath search path list for OSX application user target' do

0 commit comments

Comments
 (0)
0