88
99Pod ::Spec . new do |s |
1010 s . name = 'ReerCodable'
11- s . version = '1.5.0 '
11+ s . version = '0.0.3 '
1212 s . summary = 'Codable extensions using Swift Macro'
1313
1414 s . description = <<-DESC
@@ -30,27 +30,57 @@ Pod::Spec.new do |s|
3030
3131 s . source_files = 'Sources/ReerCodable/**/*'
3232
33- s . preserve_paths = [ "Package.swift" , "Sources/ReerCodableMacros" , "Tests" ]
33+ s . preserve_paths = [ "Package.swift" , "Sources/ReerCodableMacros" , "Tests" , "MacroPlugin" ]
3434
3535 s . pod_target_xcconfig = {
36- 'OTHER_SWIFT_FLAGS' => '-Xfrontend -load-plugin-executable -Xfrontend $( PODS_BUILD_DIR) /ReerCodable/release /ReerCodableMacros-tool #ReerCodableMacros'
36+ 'OTHER_SWIFT_FLAGS' => '-Xfrontend -load-plugin-executable -Xfrontend ${ PODS_BUILD_DIR} /ReerCodable/MacroPlugin /ReerCodableMacros#ReerCodableMacros'
3737 }
3838
3939 s . user_target_xcconfig = {
40- 'OTHER_SWIFT_FLAGS' => '-Xfrontend -load-plugin-executable -Xfrontend $( PODS_BUILD_DIR) /ReerCodable/release /ReerCodableMacros-tool #ReerCodableMacros'
40+ 'OTHER_SWIFT_FLAGS' => '-Xfrontend -load-plugin-executable -Xfrontend ${ PODS_BUILD_DIR} /ReerCodable/MacroPlugin /ReerCodableMacros#ReerCodableMacros'
4141 }
4242
43+ # Download prebuilt universal macro plugin from GitHub Release
4344 script = <<-SCRIPT
44- env -i PATH="$PATH" "$SHELL" -l -c "swift build -c release --package-path \\ "$PODS_TARGET_SRCROOT\\ " --build-path \\ "${PODS_BUILD_DIR}/ReerCodable\\ ""
45+ set -e
46+
47+ PLUGIN_DIR="${PODS_BUILD_DIR}/ReerCodable/MacroPlugin"
48+ PLUGIN_NAME="ReerCodableMacros"
49+ VERSION="#{ s . version } "
50+ DOWNLOAD_URL="https://github.com/reers/ReerCodable/releases/download/${VERSION}/${PLUGIN_NAME}.zip"
51+
52+ # Check if plugin already exists
53+ if [ -x "${PLUGIN_DIR}/${PLUGIN_NAME}" ]; then
54+ echo "Macro plugin already exists, skipping download."
55+ exit 0
56+ fi
57+
58+ mkdir -p "${PLUGIN_DIR}"
59+
60+ echo "Downloading prebuilt macro plugin from ${DOWNLOAD_URL}..."
61+
62+ if curl -L -f --connect-timeout 3 --max-time 60 -o "${PLUGIN_DIR}/${PLUGIN_NAME}.zip" "${DOWNLOAD_URL}"; then
63+ unzip -o "${PLUGIN_DIR}/${PLUGIN_NAME}.zip" -d "${PLUGIN_DIR}"
64+ rm -f "${PLUGIN_DIR}/${PLUGIN_NAME}.zip"
65+ chmod +x "${PLUGIN_DIR}/${PLUGIN_NAME}"
66+ echo "Successfully downloaded prebuilt macro plugin"
67+ file "${PLUGIN_DIR}/${PLUGIN_NAME}"
68+ else
69+ echo "Warning: Failed to download prebuilt macro plugin, will build from source..."
70+
71+ # Fallback: build from source
72+ env -i PATH="$PATH" "$SHELL" -l -c "swift build -c release --package-path \\ "${PODS_TARGET_SRCROOT}\\ " --build-path \\ "${PODS_BUILD_DIR}/ReerCodable\\ " --product ReerCodableMacros"
73+ cp "${PODS_BUILD_DIR}/ReerCodable/release/ReerCodableMacros-tool" "${PLUGIN_DIR}/${PLUGIN_NAME}"
74+ chmod +x "${PLUGIN_DIR}/${PLUGIN_NAME}"
75+ echo "Built macro plugin from source"
76+ file "${PLUGIN_DIR}/${PLUGIN_NAME}"
77+ fi
4578 SCRIPT
46-
79+
4780 s . script_phase = {
48- :name => 'Build ReerCodable macro plugin ' ,
81+ :name => 'Download ReerCodableMacros Plugin ' ,
4982 :script => script ,
50- :execution_position => :before_compile ,
51- :output_files => [
52- '$(PODS_BUILD_DIR)/ReerCodable/release/ReerCodableMacros-tool'
53- ]
83+ :execution_position => :before_compile
5484 }
5585
5686end
0 commit comments