Skip to content

Commit 9cd6910

Browse files
committed
Remove pre-build macro plugin for Cocoapods
1 parent dbb1a6e commit 9cd6910

File tree

5 files changed

+2
-53
lines changed

5 files changed

+2
-53
lines changed

MacroPlugin/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 7 deletions
This file was deleted.

MacroPlugin/Package.swift

Lines changed: 0 additions & 4 deletions
This file was deleted.

MacroPlugin/ReerCodableMacros

-14.7 MB
Binary file not shown.

README.md

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -100,31 +100,11 @@ Pod::Spec.new do |s|
100100
s.dependency 'ReerCodable', '1.4.6'
101101
# Copy the following config to your pod
102102
s.pod_target_xcconfig = {
103-
'OTHER_SWIFT_FLAGS' => '-Xfrontend -load-plugin-executable -Xfrontend ${PODS_ROOT}/ReerCodable/MacroPlugin/ReerCodableMacros#ReerCodableMacros'
103+
'OTHER_SWIFT_FLAGS' => '-Xfrontend -load-plugin-executable -Xfrontend $(PODS_BUILD_DIR)/ReerCodable/release/ReerCodableMacros-tool#ReerCodableMacros'
104104
}
105105
end
106106
</code></pre>
107107

108-
<p>Alternatively, if not using <code>s.pod_target_xcconfig</code> and <code>s.user_target_xcconfig</code>, you can add the following script in podfile for unified processing:</p>
109-
<pre><code class="ruby language-ruby">
110-
post_install do |installer|
111-
installer.pods_project.targets.each do |target|
112-
reercodable_dependency = target.dependencies.find { |d| ['ReerCodable'].include?(d.name) }
113-
if reercodable_dependency
114-
puts "Adding ReerCodable Swift flags to target: #{target.name}"
115-
target.build_configurations.each do |config|
116-
swift_flags = config.build_settings['OTHER_SWIFT_FLAGS'] ||= ['$(inherited)']
117-
plugin_flag = '-Xfrontend -load-plugin-executable -Xfrontend ${PODS_ROOT}/ReerCodable/MacroPlugin/ReerCodableMacros#ReerCodableMacros'
118-
unless swift_flags.join(' ').include?(plugin_flag)
119-
swift_flags.concat(plugin_flag.split)
120-
end
121-
config.build_settings['OTHER_SWIFT_FLAGS'] = swift_flags
122-
end
123-
end
124-
end
125-
end
126-
</code></pre>
127-
128108
<p><strong>⚠️ Important:</strong> If you encounter <code>rsync</code> permission errors with Xcode 14+, disable User Script Sandboxing:</p>
129109
<p>In your project's <strong>Build Settings</strong>, search for <code>User Script Sandboxing</code> and set <code>ENABLE_USER_SCRIPT_SANDBOXING</code> to <code>No</code>. This resolves CocoaPods script execution issues caused by Xcode's stricter sandbox restrictions.</p>
130110

README_CN.md

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -94,31 +94,11 @@ Pod::Spec.new do |s|
9494
s.dependency 'ReerCodable', '1.4.6'
9595
# 复制以下 config 到你的 pod
9696
s.pod_target_xcconfig = {
97-
'OTHER_SWIFT_FLAGS' => '-Xfrontend -load-plugin-executable -Xfrontend ${PODS_ROOT}/ReerCodable/MacroPlugin/ReerCodableMacros#ReerCodableMacros'
97+
'OTHER_SWIFT_FLAGS' => '-Xfrontend -load-plugin-executable -Xfrontend $(PODS_BUILD_DIR)/ReerCodable/release/ReerCodableMacros-tool#ReerCodableMacros'
9898
}
9999
end
100100
</code></pre>
101101

102-
<p>或者, 如果不使用<code>s.pod_target_xcconfig</code>和<code>s.user_target_xcconfig</code>, 也可以在 podfile 中添加如下脚本统一处理:</p>
103-
<pre><code class="ruby language-ruby">
104-
post_install do |installer|
105-
installer.pods_project.targets.each do |target|
106-
reercodable_dependency = target.dependencies.find { |d| ['ReerCodable'].include?(d.name) }
107-
if reercodable_dependency
108-
puts "Adding ReerCodable Swift flags to target: #{target.name}"
109-
target.build_configurations.each do |config|
110-
swift_flags = config.build_settings['OTHER_SWIFT_FLAGS'] ||= ['$(inherited)']
111-
plugin_flag = '-Xfrontend -load-plugin-executable -Xfrontend ${PODS_ROOT}/ReerCodable/MacroPlugin/ReerCodableMacros#ReerCodableMacros'
112-
unless swift_flags.join(' ').include?(plugin_flag)
113-
swift_flags.concat(plugin_flag.split)
114-
end
115-
config.build_settings['OTHER_SWIFT_FLAGS'] = swift_flags
116-
end
117-
end
118-
end
119-
end
120-
</code></pre>
121-
122102
<p><strong>⚠️ 重要提示:</strong>若在 Xcode 14+ 遇到 <code>rsync</code> 权限错误,需关闭用户脚本沙盒:</p>
123103
<p>在工程的 <strong>Build Settings</strong> 中搜索 <code>User Script Sandboxing</code>,将 <code>ENABLE_USER_SCRIPT_SANDBOXING</code> 设为 <code>No</code>。这可解决 Xcode 严格沙盒限制导致的 CocoaPods 脚本执行失败问题。</p>
124104

0 commit comments

Comments
 (0)