@@ -28,43 +28,53 @@ def self.integrate(pod_bundle, targets)
28
28
# @!group Integration steps
29
29
#-------------------------------------------------------------------#
30
30
31
- # Creates a file reference to the xcconfig generated by
32
- # CocoaPods (if needed) and sets it as the base configuration of
33
- # build configuration of the user target.
31
+ # Integrates the user target by creating or updating the base
32
+ # configuration reference to point at the CocoaPods-generated xcconfig,
33
+ # while preserving any existing custom xcconfig (including folder-based
34
+ # references via anchor + relative path).
34
35
#
35
36
# @param [Target::AggregateTarget] pod_bundle
36
- # The Pods bundle .
37
+ # The Pods aggregate target, providing sandbox and xcconfig paths .
37
38
#
38
39
# @param [PBXNativeTarget] target
39
- # The native target.
40
+ # The native Xcode target to configure .
40
41
#
41
42
# @param [Xcodeproj::XCBuildConfiguration] config
42
- # The build configuration.
43
- #
43
+ # The build configuration on which to set the base configuration.
44
44
def self . set_target_xcconfig ( pod_bundle , target , config )
45
45
file_ref = create_xcconfig_ref ( pod_bundle , config )
46
- path = file_ref . path
46
+ path = file_ref . path
47
47
48
- existing = config . base_configuration_reference
48
+ if config . base_configuration_reference
49
+ existing_path = config . base_configuration_reference . real_path
50
+ elsif config . base_configuration_reference_anchor && config . base_configuration_reference_relative_path
51
+ existing_path = Pathname . new (
52
+ File . join (
53
+ config . base_configuration_reference_anchor . path ,
54
+ config . base_configuration_reference_relative_path
55
+ )
56
+ )
57
+ end
49
58
50
- if existing && existing != file_ref
51
- if existing . real_path . to_path . start_with? ( pod_bundle . sandbox . root . to_path << '/' )
59
+ if existing_path
60
+ if existing_path . to_path . start_with? ( pod_bundle . sandbox . root . to_path + '/' )
52
61
config . base_configuration_reference = file_ref
53
- elsif !xcconfig_includes_target_xcconfig? ( config . base_configuration_reference , path )
54
- unless existing_config_is_identical_to_pod_config? ( existing . real_path , pod_bundle . xcconfig_path ( config . name ) )
55
- UI . warn 'CocoaPods did not set the base configuration of your ' \
56
- 'project because your project already has a custom ' \
57
- 'config set. In order for CocoaPods integration to work at ' \
58
- 'all, please either set the base configurations of the target ' \
59
- "`#{ target . name } ` to `#{ path } ` or include the `#{ path } ` in your " \
60
- "build configuration (#{ UI . path ( existing . real_path ) } )."
61
- end
62
+ return
62
63
end
63
- elsif config . base_configuration_reference . nil? || file_ref . nil?
64
+
65
+ unless xcconfig_includes_target_xcconfig? ( existing_path , path ) ||
66
+ existing_config_is_identical_to_pod_config? ( existing_path , pod_bundle . xcconfig_path ( config . name ) )
67
+ UI . warn "Detected a custom base configuration for target `#{ target . name } ` " \
68
+ "(#{ UI . path ( existing_path ) } ). CocoaPods will not override it automatically. " \
69
+ "To integrate CocoaPods, either set this target’s base configuration to `#{ path } ` " \
70
+ "or include `#{ path } ` in your existing build configuration."
71
+ end
72
+ else
64
73
config . base_configuration_reference = file_ref
65
74
end
66
75
end
67
76
77
+
68
78
private
69
79
70
80
# @!group Private helpers
0 commit comments