Files
suixinkan_ios_new/Podfile
汉秋 a528d9b0d7 接入微信分享 SDK 并配置 Universal Link。
集成 WechatOpenSDK、www.zhifly.cn/suixinkan/ 通用链接与邀请页分享能力,附带 AASA 部署文件与单元测试。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-02 15:02:37 +08:00

110 lines
4.3 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

platform :ios, '16.0'
target 'suixinkan' do
use_frameworks!
# 高德地图 SDK仅真机构建时链接模拟器通过 post_install 剥离(见下方说明)
pod 'AMap3DMap-NO-IDFA', '~> 11.1'
pod 'AMapSearch-NO-IDFA', '~> 9.7'
pod 'AMapLocation-NO-IDFA', '~> 2.11'
# 微信 Open SDK分享能力不调用支付 API
pod 'WechatOpenSDK-XCFramework', '~> 2.0.4'
target 'suixinkanTests' do
inherit! :search_paths
end
end
# 模拟器可用的链接参数(不含高德 prebuilt framework但保留微信 SDK
SIMULATOR_OTHER_LDFLAGS = <<~FLAGS.squish
-ObjC -l"c++" -l"sqlite3.0" -l"z"
-framework "CoreGraphics" -framework "CoreLocation" -framework "CoreTelephony"
-framework "CoreText" -framework "ExternalAccessory" -framework "GLKit"
-framework "OpenGLES" -framework "QuartzCore" -framework "Security"
-framework "SystemConfiguration" -framework "UIKit" -framework "WebKit"
-framework "WechatOpenSDK"
FLAGS
SIMULATOR_FRAMEWORK_SEARCH_PATHS = '"${PODS_ROOT}/WechatOpenSDK-XCFramework" "${PODS_XCFRAMEWORKS_BUILD_DIR}/WechatOpenSDK-XCFramework"'
post_install do |installer|
# 1. 修正 aggregate xcconfig去掉 arm64 排除,模拟器单独链接(不链 AMap
%w[Pods-suixinkan Pods-suixinkanTests].each do |target_name|
support_dir = File.join(installer.sandbox.root, 'Target Support Files', target_name)
Dir.glob(File.join(support_dir, '*.xcconfig')).each do |path|
content = File.read(path)
content.gsub!("EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64\n", '')
# 模拟器链接微信 SDK同时剥离高德 framework
content.gsub!(
/OTHER_LDFLAGS\[sdk=iphonesimulator\*\] = .*\n/,
"OTHER_LDFLAGS[sdk=iphonesimulator*] = #{SIMULATOR_OTHER_LDFLAGS}\n"
)
if content.include?('FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]')
content.gsub!(
/FRAMEWORK_SEARCH_PATHS\[sdk=iphonesimulator\*\] = .*\n/,
"FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*] = $(inherited) #{SIMULATOR_FRAMEWORK_SEARCH_PATHS}\n"
)
else
content << "FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*] = $(inherited) #{SIMULATOR_FRAMEWORK_SEARCH_PATHS}\n"
end
unless content.include?('OTHER_LDFLAGS[sdk=iphonesimulator*]')
content << "\nOTHER_LDFLAGS[sdk=iphonesimulator*] = #{SIMULATOR_OTHER_LDFLAGS}\n"
content << "FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*] = $(inherited) #{SIMULATOR_FRAMEWORK_SEARCH_PATHS}\n"
end
File.write(path, content)
end
end
# 2. AMap pod target 标记为仅真机
installer.pods_project.targets.each do |target|
next unless target.name.start_with?('AMap')
target.build_configurations.each do |config|
config.build_settings['SUPPORTED_PLATFORMS'] = 'iphoneos'
end
end
# 3. 模拟器跳过 AMap.bundle 资源拷贝(当前 Pods 资源仅此一项)
resources_script = File.join(
installer.sandbox.root,
'Target Support Files/Pods-suixinkan/Pods-suixinkan-resources.sh'
)
if File.exist?(resources_script)
content = File.read(resources_script)
unless content.include?('SKIP_AMAP_RESOURCES_FOR_SIMULATOR')
content.sub!(
"RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt",
<<~SHELL
# SKIP_AMAP_RESOURCES_FOR_SIMULATOR
if [ "${EFFECTIVE_PLATFORM_NAME}" = "-iphonesimulator" ]; then
exit 0
fi
RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
SHELL
)
File.write(resources_script, content)
end
end
# 4. 主工程:允许 arm64 模拟器、真机编译期注入 AMAP_ENABLED、关闭脚本沙盒CocoaPods 兼容)
installer.aggregate_targets.each do |aggregate_target|
aggregate_target.user_project.native_targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = ''
config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'NO'
next unless target.name == 'suixinkan'
existing = config.build_settings['SWIFT_ACTIVE_COMPILATION_CONDITIONS[sdk=iphoneos*]'] || '$(inherited)'
config.build_settings['SWIFT_ACTIVE_COMPILATION_CONDITIONS[sdk=iphoneos*]'] = "#{existing} AMAP_ENABLED" unless existing.to_s.include?('AMAP_ENABLED')
end
end
aggregate_target.user_project.save
end
end