Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apple: Privacy Settings Support #690

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions platform/resources/CoronaPListSupport.lua
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,15 @@ function CoronaPListSupport.captureCommandOutput( cmd, debugLevel )
return result
end

function CoronaPListSupport.generateXcprivacy( settings, platform )
local platformSettings = settings[platform]
local ret = ""
if platformSettings and platformSettings.xcprivacy then
ret = ret .. CoronaPListSupport.valueToPlistEntry(platformSettings.xcprivacy)
end

return ret
end

function CoronaPListSupport.generateEntitlements( settings, platform, provisionProfile )
local platformSettings = settings[platform]
Expand Down
44 changes: 43 additions & 1 deletion platform/resources/OSXPackageApp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,53 @@ local function generateOSXEntitlements(filename, settings, provisionFile)
return "", includeProvisioning
end

-- xcprivacy
local templateXcprivacy = [[
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
{{CUSTOM_XCPRIVACY}}
</dict>
</plist>
]]
local function generateXcprivacy( options )
local filename = options.tmpDir .. "/PrivacyInfo.xcprivacy"
local outFile = assert( io.open( filename, "wb" ) )

local data = templateXcprivacy

local generatedPrivacy = CoronaPListSupport.generateXcprivacy( options.settings, 'osx')
if( generatedPrivacy and generatedPrivacy ~= "" ) then
data, numMatches = string.gsub( data, "{{CUSTOM_XCPRIVACY}}", generatedPrivacy )
assert( numMatches == 1 )
end

outFile:write(data)
assert( outFile:close() )

print( "Created XCPRIACY: " .. filename );

if debugBuildProcess and debugBuildProcess ~= 0 then
runScript("cat "..filename)
end
end

--
-- generateFiles
--
-- Create the Info.plist file
-- Create the Info.plist and .xcprivacy file
--
-- returns an error message or nil on success
--
local function generateFiles( options )
local result = nil

result = generateXcprivacy( options )
if result then
return result
end

result = CoronaPListSupport.modifyPlist( options )
if result then
return result
Expand Down Expand Up @@ -753,6 +790,11 @@ function OSXPostPackage( params )

runScript( "/bin/mkdir -p "..options.appBundleFile.."/Contents/Resources/Corona/" )

--add xcprivacy file to the bundle
if options.settings.osx and options.settings.osx.xcprivacy then
runScript("cp -v " .. quoteString(options.tmpDir .. "/PrivacyInfo.xcprivacy") .. " " .. quoteString(makepath(appBundleFileUnquoted, "PrivacyInfo.xcprivacy")))
end

-- We get the signingIdentity as a cert fingerprint but we also need the plaintext name
if options.signingIdentity then
options.signingIdentityName = captureCommandOutput("security find-identity -p codesigning -v | grep '".. options.signingIdentity .."' | sed -e 's/.*\\(\".*\"\\).*/\\1/'")
Expand Down
47 changes: 45 additions & 2 deletions platform/resources/iPhonePackageApp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -575,16 +575,54 @@ local function generateXcent( options )
end


-- xcprivacy
local templateXcprivacy = [[
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
{{CUSTOM_XCPRIVACY}}
</dict>
</plist>
]]
local function generateXcprivacy( options )
local filename = options.tmpDir .. "/PrivacyInfo.xcprivacy"
local outFile = assert( io.open( filename, "wb" ) )

local data = templateXcprivacy

local generatedPrivacy = CoronaPListSupport.generateXcprivacy( options.settings, 'iphone')
if( generatedPrivacy and generatedPrivacy ~= "" ) then
data, numMatches = string.gsub( data, "{{CUSTOM_XCPRIVACY}}", generatedPrivacy )
assert( numMatches == 1 )
end

outFile:write(data)
assert( outFile:close() )

print( "Created XCPRIACY: " .. filename );

if debugBuildProcess and debugBuildProcess ~= 0 then
runScript("cat "..filename)
end
end


--
-- generateFiles
--
-- Create the .xcent and Info.plist files
-- Create the .xcent, .xcprivacy, and Info.plist files
--
-- returns an error message or nil on success
--
local function generateFiles( options )
local result = nil

result = generateXcprivacy( options )
if result then
return result
end

result = generateXcent( options )
if result then
return result
Expand Down Expand Up @@ -963,10 +1001,15 @@ local function packageApp( options )
end

--remove standard resources(Corona Resources Bundle) if users selects

if options.includeStandardResources == false then
runScript("rm -rf "..quoteString(makepath(appBundleFileUnquoted, "CoronaResources.bundle")))
end

--add xcprivacy file to the bundle
if options.settings.iphone and options.settings.iphone.xcprivacy then
runScript("cp -v " .. quoteString(options.tmpDir .. "/PrivacyInfo.xcprivacy") .. " " .. quoteString(makepath(appBundleFileUnquoted, "PrivacyInfo.xcprivacy")))
end


-- bundle is now ready to be signed (don't sign if we don't have a signingIdentity, e.g. Xcode Simulator)
if options.signingIdentity then
Expand Down
42 changes: 42 additions & 0 deletions platform/resources/tvosPackageApp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,11 @@ end
local function generateFiles( options )
local result = nil

result = generateXcprivacy( options )
if result then
return result
end

result = generateXcent( options )
if result then
return result
Expand All @@ -994,6 +999,38 @@ local function generateFiles( options )
return result
end

-- xcprivacy
local templateXcprivacy = [[
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
{{CUSTOM_XCPRIVACY}}
</dict>
</plist>
]]
local function generateXcprivacy( options )
local filename = options.tmpDir .. "/PrivacyInfo.xcprivacy"
local outFile = assert( io.open( filename, "wb" ) )

local data = templateXcprivacy

local generatedPrivacy = CoronaPListSupport.generateXcprivacy( options.settings, 'tvos')
if( generatedPrivacy and generatedPrivacy ~= "" ) then
data, numMatches = string.gsub( data, "{{CUSTOM_XCPRIVACY}}", generatedPrivacy )
assert( numMatches == 1 )
end

outFile:write(data)
assert( outFile:close() )

print( "Created XCPRIACY: " .. filename );

if debugBuildProcess and debugBuildProcess ~= 0 then
runScript("cat "..filename)
end
end

-- True for Ad Hoc or Store builds
local function isBuildForDistribution( options )
if not options.signingIdentityName then
Expand Down Expand Up @@ -1293,6 +1330,11 @@ local function packageApp( options )
end
end

--add xcprivacy file to the bundle
if options.settings.tvos and options.settings.tvos.xcprivacy then
runScript("cp -v " .. quoteString(options.tmpDir .. "/PrivacyInfo.xcprivacy") .. " " .. quoteString(makepath(appBundleFileUnquoted, "PrivacyInfo.xcprivacy")))
end

-- bundle is now ready to be signed (don't sign if we don't have a signingIdentity, e.g. Xcode Simulator)
if options.signingIdentity then
-- codesign embedded frameworks before signing the .app
Expand Down