-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBundleDrop.podspec
More file actions
129 lines (119 loc) · 4.4 KB
/
Copy pathBundleDrop.podspec
File metadata and controls
129 lines (119 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
require "digest"
require "fileutils"
require "json"
require "open3"
require "shellwords"
bundle_drop_native_runtime_identity_resource = lambda do
return nil unless defined?(Pod::Config)
project_root = File.expand_path("..", Pod::Config.instance.installation_root.to_s)
config_path = File.join(project_root, "bundle.drop.config.js")
writer_path = File.join(
__dir__,
"lib",
"CLI",
"scripts",
"native",
"write-runtime-identity.js"
)
unless File.file?(writer_path)
raise Pod::Informative,
"Bundle Drop native runtime identity writer is missing: #{writer_path}"
end
resource_path = File.join(
"ios",
"build",
"generated",
"runtime-identity",
Digest::SHA256.hexdigest(project_root)[0, 16],
"bundle-drop-build-identity.json"
)
output_path = File.join(__dir__, resource_path)
if File.file?(config_path)
stdout, stderr, status = Open3.capture3(
ENV.fetch("NODE_BINARY", "node"),
writer_path,
"--project-root", project_root,
"--platform", "ios",
"--output", output_path
)
unless status.success?
detail = stderr.strip.empty? ? stdout.strip : stderr.strip
raise Pod::Informative,
"Bundle Drop could not generate the iOS runtime identity: #{detail}"
end
identity = JSON.parse(File.read(output_path))
return nil if identity["source"] == "expo"
unless identity["runtimeVersion"].is_a?(String) && !identity["runtimeVersion"].empty?
raise Pod::Informative, "Bundle Drop generated an invalid iOS runtime identity."
end
else
# CocoaPods evaluates the podspec before `bundle-drop login` in the documented
# fresh-install flow. Keep the resource and build phase in the Pods project so
# the first native build can replace this inert placeholder after setup.
FileUtils.mkdir_p(File.dirname(output_path))
File.write(
output_path,
JSON.generate({
"schemaVersion" => 1,
"platform" => "ios",
"source" => "unconfigured"
}) + "\n"
)
end
resource_path
end
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
native_version = package["nativeVersion"] || package["version"]
native_runtime_identity_resource = bundle_drop_native_runtime_identity_resource.call
native_runtime_identity_project_root = if native_runtime_identity_resource
File.expand_path("..", Pod::Config.instance.installation_root.to_s)
end
native_runtime_identity_writer = if native_runtime_identity_resource
File.join(__dir__, "lib", "CLI", "scripts", "native", "write-runtime-identity.js")
end
native_runtime_identity_output = if native_runtime_identity_resource
File.join(__dir__, native_runtime_identity_resource)
end
Pod::Spec.new do |s|
s.name = "BundleDrop"
s.version = native_version
s.summary = package["description"]
s.homepage = package["homepage"]
s.license = package["license"]
s.authors = package["author"]
s.platforms = { :ios => "13.0" }
s.source = { :git => ".git", :tag => "#{s.version}" }
s.source_files = "ios/**/*.{h,m,mm,swift}", "third_party/xdelta/**/*.{c,h}"
s.resources = native_runtime_identity_resource if native_runtime_identity_resource
if native_runtime_identity_resource
# Intentionally omit output files so Xcode reruns this when a bare app builds,
# even when CocoaPods has not been reinstalled since its config changed.
s.script_phase = {
:name => "Regenerate Bundle Drop runtime identity",
:execution_position => :before_compile,
:show_env_vars_in_log => "0",
:script => <<-SCRIPT
set -e
"${NODE_BINARY:-node}" \
#{Shellwords.escape(native_runtime_identity_writer)} \
--project-root #{Shellwords.escape(native_runtime_identity_project_root)} \
--platform ios \
--output #{Shellwords.escape(native_runtime_identity_output)}
SCRIPT
}
end
s.public_header_files = "ios/BundleDropLocator.h", "ios/BundleDropZipExtractor.h"
s.private_header_files = "third_party/xdelta/**/*.h"
s.pod_target_xcconfig = {
"GCC_C_LANGUAGE_STANDARD" => "c11",
"GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) HAVE_CONFIG_H=1",
"HEADER_SEARCH_PATHS" => "$(inherited) \"${PODS_TARGET_SRCROOT}/third_party/xdelta\" \"${PODS_TARGET_SRCROOT}/third_party/xdelta/xdelta3\""
}
s.libraries = "z"
s.swift_version = "5.0"
if respond_to?(:install_modules_dependencies, true)
install_modules_dependencies(s)
else
s.dependency "React-Core"
end
end