Skip to content

Commit 73dbb9b

Browse files
committed
feat: update xcode permission by command - test
1 parent e475294 commit 73dbb9b

File tree

3 files changed

+55
-17
lines changed

3 files changed

+55
-17
lines changed

Platform/IOS.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,7 @@ def PostPackaged_UseMordenXcodeProject(self):
242242

243243
# [Fix] Get App Bundle ID from Config for Modern Project as well
244244
path_ini = path_project_root / "Config" / "DefaultEngine.ini"
245-
app_bundle_id = UnrealConfigIniManager.GetConfig(path_ini, "[/Script/IOSRuntimeSettings.IOSRuntimeSettings]", "BundleIdentifier")
246-
if not app_bundle_id:
247-
PrintWarn(f"Could not read BundleIdentifier from {path_ini}, check Config.")
248-
app_bundle_id = ""
249-
else:
250-
PrintLog(f"Read BundleIdentifier from Config: {app_bundle_id}")
245+
app_bundle_id = UnrealConfigIniManager.GetBundleIdentifier(path_ini, uproject_name)
251246

252247
UnrealProjectManager.AddIOSBroadcastExtension(path_project_root, path_ue_config_resources, team_id, provisioning_profile_specifier, app_bundle_id)
253248

@@ -310,13 +305,7 @@ def PostPackaged_UseLegencyXcodeProject(self):
310305

311306
# [Fix] Get App Bundle ID from Config
312307
path_ini = path_project_root / "Config" / "DefaultEngine.ini"
313-
app_bundle_id = UnrealConfigIniManager.GetConfig(path_ini, "[/Script/IOSRuntimeSettings.IOSRuntimeSettings]", "BundleIdentifier")
314-
if not app_bundle_id:
315-
# Fallback/Default attempt (e.g. from memory or args if available, otherwise warning)
316-
PrintWarn(f"Could not read BundleIdentifier from {path_ini}, check Config.")
317-
app_bundle_id = "" # Will trigger fallback in UnrealProjectManager or can be derived
318-
else:
319-
PrintLog(f"Read BundleIdentifier from Config: {app_bundle_id}")
308+
app_bundle_id = UnrealConfigIniManager.GetBundleIdentifier(path_ini, uproject_name)
320309

321310
UnrealProjectManager.AddIOSBroadcastExtension(path_project_root, path_ue_config_resources, team_id, provisioning_profile_specifier, app_bundle_id)
322311

Utility/UnrealConfigIniManager.py

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,50 @@ def GetConfig(path_ini, section, key):
167167
lines = file.readlines()
168168

169169
in_section = False
170+
target_section = section.strip()
171+
target_key = key.strip()
172+
170173
for line in lines:
171174
line = line.strip()
172175
if line.startswith('[') and line.endswith(']'):
173-
if line == section:
176+
# Case insensitive check for section
177+
if line.lower() == target_section.lower():
174178
in_section = True
175179
else:
176180
in_section = False
177-
elif in_section and line.startswith(key + '='):
178-
return line.split('=', 1)[1]
181+
elif in_section and '=' in line:
182+
# Handle possible spaces around =
183+
parts = line.split('=', 1)
184+
current_key = parts[0].strip()
185+
if current_key.lower() == target_key.lower():
186+
return parts[1].strip()
179187

180188
return None
181189

190+
@staticmethod
191+
def GetBundleIdentifier(path_ini, project_name):
192+
# 1. Try IOS Runtime Settings
193+
bundle_id = UnrealConfigIniManager.GetConfig(path_ini, "[/Script/IOSRuntimeSettings.IOSRuntimeSettings]", "BundleIdentifier")
194+
195+
# 2. Try Mac Target Settings
196+
if not bundle_id:
197+
bundle_id = UnrealConfigIniManager.GetConfig(path_ini, "[/Script/MacTargetPlatform.XcodeProjectSettings]", "BundleIdentifier")
198+
199+
# 3. Check for Macros or Failure
200+
if not bundle_id or "$(" in bundle_id:
201+
# Resolve Prefix
202+
prefix = UnrealConfigIniManager.GetConfig(path_ini, "[/Script/IOSRuntimeSettings.IOSRuntimeSettings]", "CodeSigningPrefix")
203+
if not prefix:
204+
prefix = UnrealConfigIniManager.GetConfig(path_ini, "[/Script/MacTargetPlatform.XcodeProjectSettings]", "CodeSigningPrefix")
205+
206+
if not prefix:
207+
prefix = "io.agora"
208+
209+
# Construct ID
210+
bundle_id = f"{prefix}.{project_name}"
211+
PrintLog(f"UnrealConfigIniManager - Resolved Bundle ID from prefix: {bundle_id}")
212+
else:
213+
PrintLog(f"UnrealConfigIniManager - Read Bundle ID: {bundle_id}")
214+
215+
return bundle_id
216+

Utility/UnrealProjectManager.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,22 @@ def AddIOSBroadcastExtension(path_project_root, src_root_path_resource, team_id
303303
if not app_bundle_id:
304304
PrintWarn(f"[AddIOSBroadcastExtension] App Bundle ID not provided, using fallback: {bundle_id_prefix}")
305305

306-
# In a real scenario, retrieve this properly.
306+
# [Fix] Clean Bundle ID (remove quotes if present)
307+
bundle_id_prefix = bundle_id_prefix.replace('"', '').replace("'", "")
307308
extension_bundle_id = f"{bundle_id_prefix}.{extension_name}"
309+
310+
# [Fix] Force update Info.plist with explicit Bundle Identifier
311+
path_info_plist = dst_extension_path / "Info.plist"
312+
if path_info_plist.exists():
313+
PrintLog(f"[AddIOSBroadcastExtension] Updating Info.plist BundleID to: {extension_bundle_id}")
314+
OneXcodeCommand = XcodeCommand()
315+
try:
316+
cmd_set_id = f"Set :CFBundleIdentifier {extension_bundle_id}"
317+
OneXcodeCommand.PlistBuddy(cmd_set_id, path_info_plist)
318+
except Exception as e:
319+
PrintWarn(f"Failed to update CFBundleIdentifier in plist: {e}")
320+
else:
321+
PrintWarn(f"[AddIOSBroadcastExtension] Info.plist not found at {path_info_plist}")
308322

309323
cmd = f"ruby {script_path} '{path_xcodeproj}' '{path_project}' '{main_target_name}' '{extension_name}' '{extension_bundle_id}' '{team_id}' '{provisioning_profile_specifier}'"
310324

0 commit comments

Comments
 (0)