Add ScenicPermission module and AMap CocoaPods with simulator support.
Integrate scenic selection and permission flows into home routing, add AMap SDK for device builds while keeping arm64 simulators compilable via Podfile post_install hooks. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
89
Podfile
Normal file
89
Podfile
Normal file
@ -0,0 +1,89 @@
|
||||
platform :ios, '17.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'
|
||||
|
||||
target 'suixinkanTests' do
|
||||
inherit! :search_paths
|
||||
end
|
||||
end
|
||||
|
||||
# 模拟器可用的链接参数(不含高德 prebuilt framework)
|
||||
SIMULATOR_OTHER_LDFLAGS = <<~FLAGS.squish
|
||||
-ObjC -l"c++" -l"z"
|
||||
-framework "CoreGraphics" -framework "CoreLocation" -framework "CoreTelephony"
|
||||
-framework "CoreText" -framework "ExternalAccessory" -framework "GLKit"
|
||||
-framework "OpenGLES" -framework "QuartzCore" -framework "Security"
|
||||
-framework "SystemConfiguration"
|
||||
FLAGS
|
||||
|
||||
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", '')
|
||||
|
||||
unless content.include?('OTHER_LDFLAGS[sdk=iphonesimulator*]')
|
||||
content << "\nOTHER_LDFLAGS[sdk=iphonesimulator*] = #{SIMULATOR_OTHER_LDFLAGS}\n"
|
||||
content << "FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*] = $(inherited)\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
|
||||
Reference in New Issue
Block a user