Skip to content

Commit f2f4623

Browse files
fix empty plist update
1 parent 809ca03 commit f2f4623

3 files changed

Lines changed: 22 additions & 14 deletions

File tree

dist/index.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58047,10 +58047,10 @@ async function GetProjectDetails(credential, xcodeVersion) {
5804758047
finally {
5804858048
await infoPlistHandle.close();
5804958049
}
58050-
const infoPlistJson = plist.parse(infoPlistContent);
58051-
const cFBundleShortVersionString = infoPlistJson['CFBundleShortVersionString'];
58050+
const infoPlist = plist.parse(infoPlistContent);
58051+
const cFBundleShortVersionString = infoPlist['CFBundleShortVersionString'];
5805258052
core.info(`CFBundleShortVersionString: ${cFBundleShortVersionString}`);
58053-
const cFBundleVersion = infoPlistJson['CFBundleVersion'];
58053+
const cFBundleVersion = infoPlist['CFBundleVersion'];
5805458054
core.info(`CFBundleVersion: ${cFBundleVersion}`);
5805558055
const projectRef = new XcodeProject_1.XcodeProject(projectPath, projectName, platform, bundleId, projectDirectory, cFBundleShortVersionString, cFBundleVersion, scheme, credential, xcodeVersion);
5805658056
await getExportOptions(projectRef);
@@ -58071,10 +58071,15 @@ async function GetProjectDetails(credential, xcodeVersion) {
5807158071
if (projectRef.bundleVersion <= bundleVersion) {
5807258072
projectRef.bundleVersion = bundleVersion + 1;
5807358073
core.debug(`Auto Incremented bundle version ==> ${projectRef.bundleVersion}`);
58074-
infoPlistJson['CFBundleVersion'] = projectRef.bundleVersion;
58075-
const plistHandle = await fs.promises.open(infoPlistPath, fs.constants.O_RDWR);
58074+
infoPlist['CFBundleVersion'] = projectRef.bundleVersion;
58075+
try {
58076+
await fs.promises.writeFile(infoPlistPath, plist.build(infoPlist));
58077+
}
58078+
catch (error) {
58079+
(0, utilities_1.log)(`Failed to update Info.plist!\n${error}`, 'error');
58080+
}
58081+
const plistHandle = await fs.promises.open(infoPlistPath, fs.constants.O_RDONLY);
5807658082
try {
58077-
await fs.promises.writeFile(plistHandle, plist.build(infoPlistJson));
5807858083
core.info(`Updated Info.plist with CFBundleVersion: ${projectRef.bundleVersion}`);
5807958084
const updatedInfoPlistContent = await fs.promises.readFile(plistHandle, 'utf8');
5808058085
core.info(`----- Updated Info.plist content: -----\n${updatedInfoPlistContent}\n--------------------------------`);

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/xcode.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
7070
} finally {
7171
await infoPlistHandle.close();
7272
}
73-
const infoPlistJson = plist.parse(infoPlistContent);
74-
const cFBundleShortVersionString = infoPlistJson['CFBundleShortVersionString'];
73+
const infoPlist = plist.parse(infoPlistContent) as any;
74+
const cFBundleShortVersionString = infoPlist['CFBundleShortVersionString'];
7575
core.info(`CFBundleShortVersionString: ${cFBundleShortVersionString}`);
76-
const cFBundleVersion = infoPlistJson['CFBundleVersion'] as number;
76+
const cFBundleVersion = infoPlist['CFBundleVersion'] as number;
7777
core.info(`CFBundleVersion: ${cFBundleVersion}`);
7878
const projectRef = new XcodeProject(
7979
projectPath,
@@ -103,11 +103,14 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
103103
if (projectRef.bundleVersion <= bundleVersion) {
104104
projectRef.bundleVersion = bundleVersion + 1;
105105
core.debug(`Auto Incremented bundle version ==> ${projectRef.bundleVersion}`);
106-
infoPlistJson['CFBundleVersion'] = projectRef.bundleVersion;
107-
// read and write handle
108-
const plistHandle = await fs.promises.open(infoPlistPath, fs.constants.O_RDWR);
106+
infoPlist['CFBundleVersion'] = projectRef.bundleVersion;
107+
try {
108+
await fs.promises.writeFile(infoPlistPath, plist.build(infoPlist));
109+
} catch (error) {
110+
log(`Failed to update Info.plist!\n${error}`, 'error');
111+
}
112+
const plistHandle = await fs.promises.open(infoPlistPath, fs.constants.O_RDONLY);
109113
try {
110-
await fs.promises.writeFile(plistHandle, plist.build(infoPlistJson));
111114
core.info(`Updated Info.plist with CFBundleVersion: ${projectRef.bundleVersion}`);
112115
const updatedInfoPlistContent = await fs.promises.readFile(plistHandle, 'utf8');
113116
core.info(`----- Updated Info.plist content: -----\n${updatedInfoPlistContent}\n--------------------------------`);

0 commit comments

Comments
 (0)