feature 5.0.0

This commit is contained in:
v7lin
2023-02-24 17:52:31 +08:00
parent 50d9526ee6
commit 0432a5b783
2 changed files with 17 additions and 17 deletions

View File

@ -11,7 +11,7 @@ calling_dir = File.dirname(__FILE__)
project_dir = calling_dir.slice(0..(calling_dir.index('/.symlinks'))) project_dir = calling_dir.slice(0..(calling_dir.index('/.symlinks')))
flutter_project_dir = calling_dir.slice(0..(calling_dir.index('/ios/.symlinks'))) flutter_project_dir = calling_dir.slice(0..(calling_dir.index('/ios/.symlinks')))
cfg = YAML.load_file(File.join(flutter_project_dir, 'pubspec.yaml')) cfg = YAML.load_file(File.join(flutter_project_dir, 'pubspec.yaml'))
if cfg['tencent_kit'] && (cfg['tencent_kit']['app_id'] || cfg['tencent_kit']['universal_link']) if cfg['tencent_kit'] && cfg['tencent_kit']['app_id']
app_id = cfg['tencent_kit']['app_id'] app_id = cfg['tencent_kit']['app_id']
universal_link = cfg['tencent_kit']['universal_link'] universal_link = cfg['tencent_kit']['universal_link']
options = "" options = ""

View File

@ -47,7 +47,7 @@ end
# Actually open and modify the project # Actually open and modify the project
project = Xcodeproj::Project.open(project_path) project = Xcodeproj::Project.open(project_path)
project.targets.each do |target| project.targets.each do |target|
if (target.name == "Runner") if target.name == "Runner"
app_id = options_dict[:app_id] app_id = options_dict[:app_id]
universal_link = options_dict[:universal_link] universal_link = options_dict[:universal_link]
@ -60,7 +60,7 @@ project.targets.each do |target|
end end
sectionObject.build_configurations.each do |config| sectionObject.build_configurations.each do |config|
infoplist = config.build_settings["INFOPLIST_FILE"] infoplist = config.build_settings["INFOPLIST_FILE"]
if (!infoplist) if !infoplist
puts("INFOPLIST_FILE is not exist") puts("INFOPLIST_FILE is not exist")
exit(0) exit(0)
end end
@ -70,16 +70,16 @@ project.targets.each do |target|
exit(0) exit(0)
end end
result = Plist.parse_xml(infoplistFile, marshal: false) result = Plist.parse_xml(infoplistFile, marshal: false)
if (!result) if !result
result = {} result = {}
end end
urlTypes = result["CFBundleURLTypes"] urlTypes = result["CFBundleURLTypes"]
if (!urlTypes) if !urlTypes
urlTypes = [] urlTypes = []
result["CFBundleURLTypes"] = urlTypes result["CFBundleURLTypes"] = urlTypes
end end
isUrlTypeExist = urlTypes.any? { |urlType| urlType["CFBundleURLSchemes"] && (urlType["CFBundleURLSchemes"].include? "tencent#{app_id}") } isUrlTypeExist = urlTypes.any? { |urlType| urlType["CFBundleURLSchemes"] && (urlType["CFBundleURLSchemes"].include? "tencent#{app_id}") }
if (!isUrlTypeExist) if !isUrlTypeExist
urlTypes << { urlTypes << {
"CFBundleTypeRole": "Editor", "CFBundleTypeRole": "Editor",
"CFBundleURLName": "tencent", "CFBundleURLName": "tencent",
@ -88,7 +88,7 @@ project.targets.each do |target|
File.write(infoplistFile, Plist::Emit.dump(result)) File.write(infoplistFile, Plist::Emit.dump(result))
end end
queriesSchemes = result["LSApplicationQueriesSchemes"] queriesSchemes = result["LSApplicationQueriesSchemes"]
if (!queriesSchemes) if !queriesSchemes
queriesSchemes = [] queriesSchemes = []
result["LSApplicationQueriesSchemes"] = queriesSchemes result["LSApplicationQueriesSchemes"] = queriesSchemes
end end
@ -109,33 +109,33 @@ project.targets.each do |target|
"mqqthirdappgroup", "mqqthirdappgroup",
"mqqopensdkminiapp", "mqqopensdkminiapp",
] ]
if (tencentSchemes.any? { |scheme| !(queriesSchemes.include? scheme)} ) if tencentSchemes.any? { |scheme| !(queriesSchemes.include? scheme)}
tencentSchemes.each do |scheme| tencentSchemes.each do |scheme|
if (!(queriesSchemes.include? scheme)) if !(queriesSchemes.include? scheme)
queriesSchemes << scheme queriesSchemes << scheme
end end
end end
File.write(infoplistFile, Plist::Emit.dump(result)) File.write(infoplistFile, Plist::Emit.dump(result))
end end
security = result["NSAppTransportSecurity"] security = result["NSAppTransportSecurity"]
if (!security) if !security
security = {} security = {}
result["NSAppTransportSecurity"] = security result["NSAppTransportSecurity"] = security
end end
if (security["NSAllowsArbitraryLoads"] != true) if security["NSAllowsArbitraryLoads"] != true
security["NSAllowsArbitraryLoads"] = true security["NSAllowsArbitraryLoads"] = true
File.write(infoplistFile, Plist::Emit.dump(result)) File.write(infoplistFile, Plist::Emit.dump(result))
end end
if (security["NSAllowsArbitraryLoadsInWebContent"] != true) if security["NSAllowsArbitraryLoadsInWebContent"] != true
security["NSAllowsArbitraryLoadsInWebContent"] = true security["NSAllowsArbitraryLoadsInWebContent"] = true
File.write(infoplistFile, Plist::Emit.dump(result)) File.write(infoplistFile, Plist::Emit.dump(result))
end end
end end
if (universal_link) if universal_link
applinks = "applinks:#{URI.parse(universal_link).host}" applinks = "applinks:#{URI.parse(universal_link).host}"
sectionObject.build_configurations.each do |config| sectionObject.build_configurations.each do |config|
codeSignEntitlements = config.build_settings["CODE_SIGN_ENTITLEMENTS"] codeSignEntitlements = config.build_settings["CODE_SIGN_ENTITLEMENTS"]
if (!codeSignEntitlements) if !codeSignEntitlements
codeSignEntitlements = "Runner/Runner.entitlements" codeSignEntitlements = "Runner/Runner.entitlements"
config.build_settings["CODE_SIGN_ENTITLEMENTS"] = codeSignEntitlements config.build_settings["CODE_SIGN_ENTITLEMENTS"] = codeSignEntitlements
project.save() project.save()
@ -152,16 +152,16 @@ project.targets.each do |target|
project.save() project.save()
end end
result = Plist.parse_xml(codeSignEntitlementsFile, marshal: false) result = Plist.parse_xml(codeSignEntitlementsFile, marshal: false)
if (!result) if !result
result = {} result = {}
end end
domains = result["com.apple.developer.associated-domains"] domains = result["com.apple.developer.associated-domains"]
if (!domains) if !domains
domains = [] domains = []
result["com.apple.developer.associated-domains"] = domains result["com.apple.developer.associated-domains"] = domains
end end
isApplinksExist = domains.include? applinks isApplinksExist = domains.include? applinks
if (!isApplinksExist) if !isApplinksExist
domains << applinks domains << applinks
File.write(codeSignEntitlementsFile, Plist::Emit.dump(result)) File.write(codeSignEntitlementsFile, Plist::Emit.dump(result))
end end