cocoapods 1.9.0.beta.3 → 1.10.0.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +222 -0
  3. data/README.md +2 -1
  4. data/lib/cocoapods.rb +3 -1
  5. data/lib/cocoapods/command.rb +12 -2
  6. data/lib/cocoapods/command/lib/lint.rb +12 -3
  7. data/lib/cocoapods/command/repo/push.rb +1 -1
  8. data/lib/cocoapods/command/repo/update.rb +11 -0
  9. data/lib/cocoapods/command/spec/lint.rb +12 -3
  10. data/lib/cocoapods/config.rb +17 -0
  11. data/lib/cocoapods/downloader/cache.rb +2 -2
  12. data/lib/cocoapods/gem_version.rb +1 -1
  13. data/lib/cocoapods/generator/app_target_helper.rb +10 -2
  14. data/lib/cocoapods/generator/copy_dsyms_script.rb +56 -0
  15. data/lib/cocoapods/generator/copy_resources_script.rb +2 -14
  16. data/lib/cocoapods/generator/copy_xcframework_script.rb +245 -0
  17. data/lib/cocoapods/generator/embed_frameworks_script.rb +137 -206
  18. data/lib/cocoapods/generator/script_phase_constants.rb +99 -0
  19. data/lib/cocoapods/installer.rb +70 -3
  20. data/lib/cocoapods/installer/analyzer.rb +17 -8
  21. data/lib/cocoapods/installer/analyzer/target_inspection_result.rb +1 -1
  22. data/lib/cocoapods/installer/base_install_hooks_context.rb +135 -0
  23. data/lib/cocoapods/installer/installation_options.rb +5 -0
  24. data/lib/cocoapods/installer/pod_source_installer.rb +2 -1
  25. data/lib/cocoapods/installer/post_install_hooks_context.rb +1 -127
  26. data/lib/cocoapods/installer/post_integrate_hooks_context.rb +9 -0
  27. data/lib/cocoapods/installer/sandbox_dir_cleaner.rb +2 -1
  28. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +132 -111
  29. data/lib/cocoapods/installer/xcode/pods_project_generator.rb +45 -6
  30. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +13 -27
  31. data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +2 -1
  32. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_dependency_installer.rb +4 -4
  33. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +175 -58
  34. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +61 -30
  35. data/lib/cocoapods/installer/xcode/pods_project_generator/project_generator.rb +3 -2
  36. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb +5 -7
  37. data/lib/cocoapods/installer/xcode/pods_project_generator_result.rb +19 -0
  38. data/lib/cocoapods/installer/xcode/target_validator.rb +1 -1
  39. data/lib/cocoapods/sources_manager.rb +2 -1
  40. data/lib/cocoapods/target.rb +44 -2
  41. data/lib/cocoapods/target/aggregate_target.rb +35 -0
  42. data/lib/cocoapods/target/build_settings.rb +86 -19
  43. data/lib/cocoapods/target/pod_target.rb +85 -11
  44. data/lib/cocoapods/user_interface/error_report.rb +1 -1
  45. data/lib/cocoapods/user_interface/inspector_reporter.rb +3 -10
  46. data/lib/cocoapods/validator.rb +32 -8
  47. data/lib/cocoapods/xcode/framework_paths.rb +1 -1
  48. data/lib/cocoapods/xcode/xcframework.rb +17 -4
  49. data/lib/cocoapods/xcode/xcframework/xcframework_slice.rb +81 -3
  50. metadata +30 -38
  51. data/lib/cocoapods/generator/prepare_artifacts_script.rb +0 -244
@@ -97,7 +97,7 @@ module Pod
97
97
  # `request`.
98
98
  #
99
99
  def path_for_pod(request, slug_opts = {})
100
- root + request.slug(slug_opts)
100
+ root + request.slug(**slug_opts)
101
101
  end
102
102
 
103
103
  # @param [Request] request
@@ -111,7 +111,7 @@ module Pod
111
111
  # `request`.
112
112
  #
113
113
  def path_for_spec(request, slug_opts = {})
114
- path = root + 'Specs' + request.slug(slug_opts)
114
+ path = root + 'Specs' + request.slug(**slug_opts)
115
115
  path.sub_ext('.podspec.json')
116
116
  end
117
117
 
@@ -1,5 +1,5 @@
1
1
  module Pod
2
2
  # The version of the CocoaPods command line tool.
3
3
  #
4
- VERSION = '1.9.0.beta.3'.freeze unless defined? Pod::VERSION
4
+ VERSION = '1.10.0.beta.1'.freeze unless defined? Pod::VERSION
5
5
  end
@@ -127,9 +127,17 @@ module Pod
127
127
  # @return [void]
128
128
  #
129
129
  def self.add_xctest_search_paths(target)
130
+ requires_libs = target.platform_name == :ios &&
131
+ Version.new(target.deployment_target) < Version.new('12.2')
132
+
130
133
  target.build_configurations.each do |configuration|
131
- search_paths = configuration.build_settings['FRAMEWORK_SEARCH_PATHS'] ||= '$(inherited)'
132
- search_paths << ' "$(PLATFORM_DIR)/Developer/Library/Frameworks"'
134
+ framework_search_paths = configuration.build_settings['FRAMEWORK_SEARCH_PATHS'] ||= '$(inherited)'
135
+ framework_search_paths << ' "$(PLATFORM_DIR)/Developer/Library/Frameworks"'
136
+
137
+ if requires_libs
138
+ library_search_paths = configuration.build_settings['LIBRARY_SEARCH_PATHS'] ||= '$(inherited)'
139
+ library_search_paths << ' "$(PLATFORM_DIR)/Developer/usr/lib"'
140
+ end
133
141
  end
134
142
  end
135
143
 
@@ -0,0 +1,56 @@
1
+ module Pod
2
+ module Generator
3
+ class CopydSYMsScript
4
+ # @return [Array<Pathname>] dsym_paths the dSYM paths to include in the script contents.
5
+ #
6
+ attr_reader :dsym_paths
7
+
8
+ # @return [Array<Pathname>] bcsymbolmap_paths the bcsymbolmap paths to include in the script contents.
9
+ #
10
+ attr_reader :bcsymbolmap_paths
11
+
12
+ # Initialize a new instance
13
+ #
14
+ # @param [Array<Pathname>] dsym_paths @see dsym_paths
15
+ # @param [Array<Pathname>] bcsymbolmap_paths @see bcsymbolmap_paths
16
+ #
17
+ def initialize(dsym_paths, bcsymbolmap_paths)
18
+ @dsym_paths = Array(dsym_paths)
19
+ @bcsymbolmap_paths = Array(bcsymbolmap_paths)
20
+ end
21
+
22
+ # Saves the copy dSYMs script to the given pathname.
23
+ #
24
+ # @param [Pathname] pathname
25
+ # The path where the copy dSYMs script should be saved.
26
+ #
27
+ # @return [void]
28
+ #
29
+ def save_as(pathname)
30
+ pathname.open('w') do |file|
31
+ file.puts(generate)
32
+ end
33
+ File.chmod(0755, pathname.to_s)
34
+ end
35
+
36
+ # @return [String] The generated of the copy dSYMs script.
37
+ #
38
+ def generate
39
+ script = <<-SH.strip_heredoc
40
+ #{Pod::Generator::ScriptPhaseConstants::DEFAULT_SCRIPT_PHASE_HEADER}
41
+ #{Pod::Generator::ScriptPhaseConstants::STRIP_INVALID_ARCHITECTURES_METHOD}
42
+ #{Pod::Generator::ScriptPhaseConstants::RSYNC_PROTECT_TMP_FILES}
43
+ #{Pod::Generator::ScriptPhaseConstants::INSTALL_DSYM_METHOD}
44
+ #{Pod::Generator::ScriptPhaseConstants::INSTALL_BCSYMBOLMAP_METHOD}
45
+ SH
46
+ dsym_paths.each do |dsym_path|
47
+ script << %(install_dsym "#{dsym_path}"\n)
48
+ end
49
+ bcsymbolmap_paths.each do |bcsymbolmap_path|
50
+ script << %(install_bcsymbolmap "#{bcsymbolmap_path}"\n)
51
+ end
52
+ script
53
+ end
54
+ end
55
+ end
56
+ end
@@ -100,16 +100,7 @@ module Pod
100
100
  end
101
101
 
102
102
  INSTALL_RESOURCES_FUNCTION = <<EOS
103
- #!/bin/sh
104
- set -e
105
- set -u
106
- set -o pipefail
107
-
108
- function on_error {
109
- echo "$(realpath -mq "${0}"):$1: error: Unexpected failure"
110
- }
111
- trap 'on_error $LINENO' ERR
112
-
103
+ #{Pod::Generator::ScriptPhaseConstants::DEFAULT_SCRIPT_PHASE_HEADER}
113
104
  if [ -z ${UNLOCALIZED_RESOURCES_FOLDER_PATH+x} ]; then
114
105
  # If UNLOCALIZED_RESOURCES_FOLDER_PATH is not set, then there's nowhere for us to copy
115
106
  # resources to, so exit 0 (signalling the script phase was successful).
@@ -123,10 +114,7 @@ RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
123
114
 
124
115
  XCASSET_FILES=()
125
116
 
126
- # This protects against multiple targets copying the same framework dependency at the same time. The solution
127
- # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
128
- RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
129
-
117
+ #{Pod::Generator::ScriptPhaseConstants::RSYNC_PROTECT_TMP_FILES}
130
118
  case "${TARGETED_DEVICE_FAMILY:-}" in
131
119
  1,2)
132
120
  TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
@@ -0,0 +1,245 @@
1
+ require 'cocoapods/xcode'
2
+
3
+ module Pod
4
+ module Generator
5
+ class CopyXCFrameworksScript
6
+ # @return [Array<Pod::Xcode::XCFramework>] List of xcframeworks to copy
7
+ #
8
+ attr_reader :xcframeworks
9
+
10
+ # @return [Pathname] the root directory of the sandbox
11
+ #
12
+ attr_reader :sandbox_root
13
+
14
+ # @return [Platform] the platform of the target for which this script will run
15
+ #
16
+ attr_reader :platform
17
+
18
+ # Creates a script for copying XCFramework slcies into an intermediate build directory
19
+ #
20
+ # @param [Array<Pod::Xcode::XCFramework>] xcframeworks
21
+ # the list of xcframeworks to copy
22
+ #
23
+ # @param [Pathname] sandbox_root
24
+ # the root of the Sandbox into which this script will be installed
25
+ #
26
+ # @param [Platform] platform
27
+ # the platform of the target for which this script will be run
28
+ #
29
+ def initialize(xcframeworks, sandbox_root, platform)
30
+ @xcframeworks = xcframeworks
31
+ @sandbox_root = sandbox_root
32
+ @platform = platform
33
+ end
34
+
35
+ # Saves the resource script to the given pathname.
36
+ #
37
+ # @param [Pathname] pathname
38
+ # The path where the embed frameworks script should be saved.
39
+ #
40
+ # @return [void]
41
+ #
42
+ def save_as(pathname)
43
+ pathname.open('w') do |file|
44
+ file.puts(script)
45
+ end
46
+ File.chmod(0o755, pathname.to_s)
47
+ end
48
+
49
+ # @return [String] The contents of the embed frameworks script.
50
+ #
51
+ def generate
52
+ script
53
+ end
54
+
55
+ private
56
+
57
+ # @!group Private Helpers
58
+
59
+ # @return [String] The contents of the prepare artifacts script.
60
+ #
61
+ def script
62
+ script = <<-SH.strip_heredoc
63
+ #{Pod::Generator::ScriptPhaseConstants::DEFAULT_SCRIPT_PHASE_HEADER}
64
+
65
+ #{Pod::Generator::ScriptPhaseConstants::RSYNC_PROTECT_TMP_FILES}
66
+
67
+ copy_dir()
68
+ {
69
+ local source="$1"
70
+ local destination="$2"
71
+
72
+ # Use filter instead of exclude so missing patterns don't throw errors.
73
+ echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" \\"${source}\\" \\"${destination}\\""
74
+ rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" "${source}" "${destination}"
75
+ }
76
+
77
+ SELECT_SLICE_RETVAL=""
78
+
79
+ select_slice() {
80
+ local paths=("$@")
81
+ # Locate the correct slice of the .xcframework for the current architectures
82
+ local target_path=""
83
+
84
+ # Split archs on space so we can find a slice that has all the needed archs
85
+ local target_archs=$(echo $ARCHS | tr " " "\\n")
86
+
87
+ local target_variant=""
88
+ if [[ "$PLATFORM_NAME" == *"simulator" ]]; then
89
+ target_variant="simulator"
90
+ fi
91
+ if [[ ! -z ${EFFECTIVE_PLATFORM_NAME+x} && "$EFFECTIVE_PLATFORM_NAME" == *"maccatalyst" ]]; then
92
+ target_variant="maccatalyst"
93
+ fi
94
+ for i in ${!paths[@]}; do
95
+ local matched_all_archs="1"
96
+ for target_arch in $target_archs
97
+ do
98
+ if ! [[ "${paths[$i]}" == *"$target_variant"* ]]; then
99
+ matched_all_archs="0"
100
+ break
101
+ fi
102
+
103
+ # This regex matches all possible variants of the arch in the folder name:
104
+ # Let's say the folder name is: ios-armv7_armv7s_arm64_arm64e/CoconutLib.framework
105
+ # We match the following: -armv7_, _armv7s_, _arm64_ and _arm64e/.
106
+ # If we have a specific variant: ios-i386_x86_64-simulator/CoconutLib.framework
107
+ # We match the following: -i386_ and _x86_64-
108
+ local target_arch_regex="[_\\-]${target_arch}[\\/_\\-]"
109
+ if ! [[ "${paths[$i]}" =~ $target_arch_regex ]]; then
110
+ matched_all_archs="0"
111
+ break
112
+ fi
113
+ done
114
+
115
+ if [[ "$matched_all_archs" == "1" ]]; then
116
+ # Found a matching slice
117
+ echo "Selected xcframework slice ${paths[$i]}"
118
+ SELECT_SLICE_RETVAL=${paths[$i]}
119
+ break
120
+ fi
121
+ done
122
+ }
123
+
124
+ install_library() {
125
+ local source="$1"
126
+ local name="$2"
127
+ local destination="#{Target::BuildSettings::XCFRAMEWORKS_BUILD_DIR_VARIABLE}/${name}"
128
+
129
+ # Libraries can contain headers, module maps, and a binary, so we'll copy everything in the folder over
130
+
131
+ local source="$binary"
132
+ echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" \\"${source}/*\\" \\"${destination}\\""
133
+ rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" "${source}/*" "${destination}"
134
+ }
135
+
136
+ # Copies a framework to derived data for use in later build phases
137
+ install_framework()
138
+ {
139
+ local source="$1"
140
+ local name="$2"
141
+ local destination="#{Pod::Target::BuildSettings::XCFRAMEWORKS_BUILD_DIR_VARIABLE}/${name}"
142
+
143
+ if [ ! -d "$destination" ]; then
144
+ mkdir -p "$destination"
145
+ fi
146
+
147
+ copy_dir "$source" "$destination"
148
+ echo "Copied $source to $destination"
149
+ }
150
+
151
+ install_xcframework_library() {
152
+ local basepath="$1"
153
+ local name="$2"
154
+ local paths=("$@")
155
+
156
+ # Locate the correct slice of the .xcframework for the current architectures
157
+ select_slice "${paths[@]}"
158
+ local target_path="$SELECT_SLICE_RETVAL"
159
+ if [[ -z "$target_path" ]]; then
160
+ echo "warning: [CP] Unable to find matching .xcframework slice in '${paths[@]}' for the current build architectures ($ARCHS)."
161
+ return
162
+ fi
163
+
164
+ install_framework "$basepath/$target_path" "$name"
165
+ }
166
+
167
+ install_xcframework() {
168
+ local basepath="$1"
169
+ local name="$2"
170
+ local package_type="$3"
171
+ local paths=("$@")
172
+
173
+ # Locate the correct slice of the .xcframework for the current architectures
174
+ select_slice "${paths[@]}"
175
+ local target_path="$SELECT_SLICE_RETVAL"
176
+ if [[ -z "$target_path" ]]; then
177
+ echo "warning: [CP] Unable to find matching .xcframework slice in '${paths[@]}' for the current build architectures ($ARCHS)."
178
+ return
179
+ fi
180
+ local source="$basepath/$target_path"
181
+
182
+ local destination="#{Pod::Target::BuildSettings::XCFRAMEWORKS_BUILD_DIR_VARIABLE}/${name}"
183
+
184
+ if [ ! -d "$destination" ]; then
185
+ mkdir -p "$destination"
186
+ fi
187
+
188
+ if [[ "$package_type" == "library" ]]; then
189
+ # Libraries can contain headers, module maps, and a binary, so we'll copy everything in the folder over
190
+ copy_dir "$source/" "$destination"
191
+ elif [[ "$package_type" == "framework" ]]; then
192
+ copy_dir "$source" "$destination"
193
+ fi
194
+ echo "Copied $source to $destination"
195
+ }
196
+
197
+ SH
198
+ xcframeworks.each do |xcframework|
199
+ slices = xcframework.slices.select { |f| f.platform.symbolic_name == platform.symbolic_name }
200
+ next if slices.empty?
201
+ args = install_xcframework_args(xcframework, slices)
202
+ script << "install_xcframework #{args}\n"
203
+ end
204
+
205
+ script << "\n" unless xcframeworks.empty?
206
+ script
207
+ end
208
+
209
+ def shell_escape(value)
210
+ "\"#{value}\""
211
+ end
212
+
213
+ def install_xcframework_args(xcframework, slices)
214
+ root = xcframework.path
215
+ args = [shell_escape("${PODS_ROOT}/#{root.relative_path_from(sandbox_root)}")]
216
+ args << shell_escape(xcframework.name)
217
+ is_framework = xcframework.build_type.framework?
218
+ args << shell_escape(is_framework ? 'framework' : 'library')
219
+ slices.each do |slice|
220
+ args << if is_framework
221
+ shell_escape(slice.path.relative_path_from(root))
222
+ else
223
+ # We don't want the path to the library binary, we want the dir that contains it
224
+ shell_escape(slice.path.dirname.relative_path_from(root))
225
+ end
226
+ end
227
+ args.join(' ')
228
+ end
229
+
230
+ class << self
231
+ # @param [Pathname] xcframework_path
232
+ # the base path of the .xcframework bundle
233
+ #
234
+ # @return [Array<Pathname>] all found .dSYM paths
235
+ #
236
+ def dsym_folder(xcframework_path)
237
+ basename = File.basename(xcframework_path, '.xcframework')
238
+ dsym_basename = basename + '.dSYMs'
239
+ path = xcframework_path.dirname + dsym_basename
240
+ Pathname.new(path) if File.directory?(path)
241
+ end
242
+ end
243
+ end
244
+ end
245
+ end
@@ -8,11 +8,20 @@ module Pod
8
8
  #
9
9
  attr_reader :frameworks_by_config
10
10
 
11
+ # @return [Hash{String => Array<XCFrameworkPaths>}] Multiple lists of frameworks per
12
+ # configuration.
13
+ #
14
+ attr_reader :xcframeworks_by_config
15
+
11
16
  # @param [Hash{String => Array<FrameworkPaths>] frameworks_by_config
12
17
  # @see #frameworks_by_config
13
18
  #
14
- def initialize(frameworks_by_config)
19
+ # @param [Hash{String => Array<XCFramework>] xcframeworks_by_config
20
+ # @see #xcframeworks_by_config
21
+ #
22
+ def initialize(frameworks_by_config, xcframeworks_by_config)
15
23
  @frameworks_by_config = frameworks_by_config
24
+ @xcframeworks_by_config = xcframeworks_by_config
16
25
  end
17
26
 
18
27
  # Saves the resource script to the given pathname.
@@ -43,213 +52,123 @@ module Pod
43
52
  #
44
53
  def script
45
54
  script = <<-SH.strip_heredoc
46
- #!/bin/sh
47
- set -e
48
- set -u
49
- set -o pipefail
50
-
51
- function on_error {
52
- echo "$(realpath -mq "${0}"):$1: error: Unexpected failure"
53
- }
54
- trap 'on_error $LINENO' ERR
55
-
56
- if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then
57
- # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy
58
- # frameworks to, so exit 0 (signalling the script phase was successful).
59
- exit 0
60
- fi
61
-
62
- echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
63
- mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
64
-
65
- COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}"
66
- SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
67
-
68
- # Used as a return value for each invocation of `strip_invalid_archs` function.
69
- STRIP_BINARY_RETVAL=0
70
-
71
- # This protects against multiple targets copying the same framework dependency at the same time. The solution
72
- # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
73
- RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
74
-
75
- # Copies and strips a vendored framework
76
- install_framework()
77
- {
78
- if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
79
- local source="${BUILT_PRODUCTS_DIR}/$1"
80
- elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
81
- local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
82
- elif [ -r "$1" ]; then
83
- local source="$1"
84
- fi
85
-
86
- local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
87
-
88
- if [ -L "${source}" ]; then
89
- echo "Symlinked..."
90
- source="$(readlink "${source}")"
91
- fi
92
-
93
- # Use filter instead of exclude so missing patterns don't throw errors.
94
- echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" --filter \\"- Headers\\" --filter \\"- PrivateHeaders\\" --filter \\"- Modules\\" \\"${source}\\" \\"${destination}\\""
95
- rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
96
-
97
- local basename
98
- basename="$(basename -s .framework "$1")"
99
- binary="${destination}/${basename}.framework/${basename}"
100
-
101
- if ! [ -r "$binary" ]; then
102
- binary="${destination}/${basename}"
103
- elif [ -L "${binary}" ]; then
104
- echo "Destination binary is symlinked..."
105
- dirname="$(dirname "${binary}")"
106
- binary="${dirname}/$(readlink "${binary}")"
107
- fi
108
-
109
- # Strip invalid architectures so "fat" simulator / device frameworks work on device
110
- if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
111
- strip_invalid_archs "$binary"
112
- fi
113
-
114
- # Resign the code if required by the build settings to avoid unstable apps
115
- code_sign_if_enabled "${destination}/$(basename "$1")"
116
-
117
- # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
118
- if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
119
- local swift_runtime_libs
120
- swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\\\/\\(.+dylib\\).*/\\\\1/g | uniq -u)
121
- for lib in $swift_runtime_libs; do
122
- echo "rsync -auv \\"${SWIFT_STDLIB_PATH}/${lib}\\" \\"${destination}\\""
123
- rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
124
- code_sign_if_enabled "${destination}/${lib}"
125
- done
126
- fi
127
- }
128
-
129
- # Copies and strips a vendored dSYM
130
- install_dsym() {
131
- local source="$1"
132
- if [ -r "$source" ]; then
133
- # Copy the dSYM into a the targets temp dir.
134
- echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" --filter \\"- Headers\\" --filter \\"- PrivateHeaders\\" --filter \\"- Modules\\" \\"${source}\\" \\"${DERIVED_FILES_DIR}\\""
135
- rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}"
136
-
137
- local basename
138
- basename="$(basename -s .framework.dSYM "$source")"
139
- binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}"
140
-
141
- # Strip invalid architectures so "fat" simulator / device frameworks work on device
142
- if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then
143
- strip_invalid_archs "$binary"
144
- fi
145
-
146
- if [[ $STRIP_BINARY_RETVAL == 1 ]]; then
147
- # Move the stripped file into its final destination.
148
- echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" --filter \\"- Headers\\" --filter \\"- PrivateHeaders\\" --filter \\"- Modules\\" \\"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\\" \\"${DWARF_DSYM_FOLDER_PATH}\\""
149
- rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}"
150
- else
151
- # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing.
152
- touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM"
153
- fi
154
- fi
155
- }
156
-
157
- # Copies the bcsymbolmap files of a vendored framework
158
- install_bcsymbolmap() {
159
- local bcsymbolmap_path="$1"
160
- local destination="${BUILT_PRODUCTS_DIR}"
161
- echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${bcsymbolmap_path}\" \"${destination}\""
162
- rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}"
163
- }
164
-
165
- # Signs a framework with the provided identity
166
- code_sign_if_enabled() {
167
- if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
168
- # Use the current code_sign_identity
169
- echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
170
- local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'"
171
-
172
- if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
173
- code_sign_cmd="$code_sign_cmd &"
174
- fi
175
- echo "$code_sign_cmd"
176
- eval "$code_sign_cmd"
177
- fi
178
- }
179
-
180
- # Strip invalid architectures
181
- strip_invalid_archs() {
182
- binary="$1"
183
- # Get architectures for current target binary
184
- binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)"
185
- # Intersect them with the architectures we are building for
186
- intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\\n' | sort | uniq -d)"
187
- # If there are no archs supported by this binary then warn the user
188
- if [[ -z "$intersected_archs" ]]; then
189
- echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)."
190
- STRIP_BINARY_RETVAL=0
191
- return
192
- fi
193
- stripped=""
194
- for arch in $binary_archs; do
195
- if ! [[ "${ARCHS}" == *"$arch"* ]]; then
196
- # Strip non-valid architectures in-place
197
- lipo -remove "$arch" -output "$binary" "$binary"
198
- stripped="$stripped $arch"
199
- fi
200
- done
201
- if [[ "$stripped" ]]; then
202
- echo "Stripped $binary of architectures:$stripped"
203
- fi
204
- STRIP_BINARY_RETVAL=1
205
- }
206
-
207
- install_artifact() {
208
- artifact="$1"
209
- base="$(basename "$artifact")"
210
- case $base in
211
- *.framework)
212
- install_framework "$artifact"
213
- ;;
214
- *.dSYM)
215
- install_dsym "$artifact"
216
- ;;
217
- *.bcsymbolmap)
218
- install_bcsymbolmap "$artifact"
219
- ;;
220
- *)
221
- echo "error: Unrecognized artifact "$artifact""
222
- ;;
223
- esac
224
- }
225
-
226
- copy_artifacts() {
227
- file_list="$1"
228
- while read artifact; do
229
- install_artifact "$artifact"
230
- done <$file_list
231
- }
232
-
233
- ARTIFACT_LIST_FILE="${BUILT_PRODUCTS_DIR}/cocoapods-artifacts-${CONFIGURATION}.txt"
234
- if [ -r "${ARTIFACT_LIST_FILE}" ]; then
235
- copy_artifacts "${ARTIFACT_LIST_FILE}"
236
- fi
237
-
55
+ #{Pod::Generator::ScriptPhaseConstants::DEFAULT_SCRIPT_PHASE_HEADER}
56
+ if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then
57
+ # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy
58
+ # frameworks to, so exit 0 (signalling the script phase was successful).
59
+ exit 0
60
+ fi
61
+
62
+ echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
63
+ mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
64
+
65
+ COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}"
66
+ SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
67
+ BCSYMBOLMAP_DIR="BCSymbolMaps"
68
+
69
+
70
+ #{Pod::Generator::ScriptPhaseConstants::RSYNC_PROTECT_TMP_FILES}
71
+ # Copies and strips a vendored framework
72
+ install_framework()
73
+ {
74
+ if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
75
+ local source="${BUILT_PRODUCTS_DIR}/$1"
76
+ elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
77
+ local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
78
+ elif [ -r "$1" ]; then
79
+ local source="$1"
80
+ fi
81
+
82
+ local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
83
+
84
+ if [ -L "${source}" ]; then
85
+ echo "Symlinked..."
86
+ source="$(readlink "${source}")"
87
+ fi
88
+
89
+ if [ -d "${source}/${BCSYMBOLMAP_DIR}" ]; then
90
+ # Locate and install any .bcsymbolmaps if present, and remove them from the .framework before the framework is copied
91
+ find "${source}/${BCSYMBOLMAP_DIR}" -name "*.bcsymbolmap"|while read f; do
92
+ echo "Installing $f"
93
+ install_bcsymbolmap "$f" "$destination"
94
+ rm "$f"
95
+ done
96
+ rmdir "${source}/${BCSYMBOLMAP_DIR}"
97
+ fi
98
+
99
+ # Use filter instead of exclude so missing patterns don't throw errors.
100
+ echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" --filter \\"- Headers\\" --filter \\"- PrivateHeaders\\" --filter \\"- Modules\\" \\"${source}\\" \\"${destination}\\""
101
+ rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
102
+
103
+ local basename
104
+ basename="$(basename -s .framework "$1")"
105
+ binary="${destination}/${basename}.framework/${basename}"
106
+
107
+ if ! [ -r "$binary" ]; then
108
+ binary="${destination}/${basename}"
109
+ elif [ -L "${binary}" ]; then
110
+ echo "Destination binary is symlinked..."
111
+ dirname="$(dirname "${binary}")"
112
+ binary="${dirname}/$(readlink "${binary}")"
113
+ fi
114
+
115
+ # Strip invalid architectures so "fat" simulator / device frameworks work on device
116
+ if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
117
+ strip_invalid_archs "$binary"
118
+ fi
119
+
120
+ # Resign the code if required by the build settings to avoid unstable apps
121
+ code_sign_if_enabled "${destination}/$(basename "$1")"
122
+
123
+ # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
124
+ if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
125
+ local swift_runtime_libs
126
+ swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\\\/\\(.+dylib\\).*/\\\\1/g | uniq -u)
127
+ for lib in $swift_runtime_libs; do
128
+ echo "rsync -auv \\"${SWIFT_STDLIB_PATH}/${lib}\\" \\"${destination}\\""
129
+ rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
130
+ code_sign_if_enabled "${destination}/${lib}"
131
+ done
132
+ fi
133
+ }
134
+ #{Pod::Generator::ScriptPhaseConstants::INSTALL_DSYM_METHOD}
135
+ #{Pod::Generator::ScriptPhaseConstants::STRIP_INVALID_ARCHITECTURES_METHOD}
136
+ #{Pod::Generator::ScriptPhaseConstants::INSTALL_BCSYMBOLMAP_METHOD}
137
+ # Signs a framework with the provided identity
138
+ code_sign_if_enabled() {
139
+ if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
140
+ # Use the current code_sign_identity
141
+ echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
142
+ local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'"
143
+
144
+ if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
145
+ code_sign_cmd="$code_sign_cmd &"
146
+ fi
147
+ echo "$code_sign_cmd"
148
+ eval "$code_sign_cmd"
149
+ fi
150
+ }
238
151
  SH
239
- frameworks_by_config.each do |config, frameworks_with_dsyms|
240
- next if frameworks_with_dsyms.empty?
241
- script << %(if [[ "$CONFIGURATION" == "#{config}" ]]; then\n)
242
- frameworks_with_dsyms.each do |framework_with_dsym|
243
- script << %( install_framework "#{framework_with_dsym.source_path}"\n)
244
- # Vendored frameworks might have a dSYM file next to them so ensure its copied. Frameworks built from
245
- # sources will have their dSYM generated and copied by Xcode.
246
- script << %( install_dsym "#{framework_with_dsym.dsym_path}"\n) unless framework_with_dsym.dsym_path.nil?
247
- unless framework_with_dsym.bcsymbolmap_paths.nil?
248
- framework_with_dsym.bcsymbolmap_paths.each do |bcsymbolmap_path|
249
- script << %( install_bcsymbolmap "#{bcsymbolmap_path}"\n)
250
- end
251
- end
152
+ contents_by_config = Hash.new do |hash, key|
153
+ hash[key] = ''
154
+ end
155
+ frameworks_by_config.each do |config, frameworks|
156
+ frameworks.each do |framework|
157
+ contents_by_config[config] << %( install_framework "#{framework.source_path}"\n)
158
+ end
159
+ end
160
+ xcframeworks_by_config.each do |config, xcframeworks|
161
+ xcframeworks.each do |xcframework|
162
+ name = xcframework.name
163
+ contents_by_config[config] << %( install_framework "#{Target::BuildSettings::XCFRAMEWORKS_BUILD_DIR_VARIABLE}/#{name}/#{name}.framework"\n)
252
164
  end
165
+ end
166
+ script << "\n" unless contents_by_config.empty?
167
+ contents_by_config.keys.sort.each do |config|
168
+ contents = contents_by_config[config]
169
+ next if contents.empty?
170
+ script << %(if [[ "$CONFIGURATION" == "#{config}" ]]; then\n)
171
+ script << contents
253
172
  script << "fi\n"
254
173
  end
255
174
  script << <<-SH.strip_heredoc
@@ -259,6 +178,18 @@ module Pod
259
178
  SH
260
179
  script
261
180
  end
181
+
182
+ # @param [Xcode::FrameworkPaths] framework_path
183
+ # the framework path containing the dSYM
184
+ #
185
+ # @return [String, Nil] the name of the dSYM binary, if found
186
+ #
187
+ def dsym_binary_name(framework_path)
188
+ return nil if framework_path.dsym_path.nil?
189
+ if (path = Pathname.glob(framework_path.dsym_path.join('Contents/Resources/DWARF', '**/*')).first)
190
+ File.basename(path)
191
+ end
192
+ end
262
193
  end
263
194
  end
264
195
  end