Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions plugin/src/withPlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import { getAppClipIcon } from "./lib/getAppClipIcon";
/**
* List of keys that are not allowed in the Info.plist due to not being supported in App Clip. Add to this array as new build issues arise.
*/
const DisallowedPlistKeys = [
"UIBackgroundModes",
];
const DisallowedPlistKeys = ["UIBackgroundModes"];

export const withPlist: ConfigPlugin<{
targetName: string;
Expand Down Expand Up @@ -67,9 +65,17 @@ export const withPlist: ConfigPlugin<{
MinimumOSVersion: deploymentTarget,
};

if (config.modResults.UIApplicationSceneManifest) {
infoPlist.UIApplicationSceneManifest =
config.modResults.UIApplicationSceneManifest;
}

if (config.ios?.infoPlist) {
for (const key of Object.keys(config.ios?.infoPlist)) {
if (config.ios?.infoPlist && !DisallowedPlistKeys.some((disallowedKey) => disallowedKey === key)) {
if (
config.ios?.infoPlist &&
!DisallowedPlistKeys.some((disallowedKey) => disallowedKey === key)
) {
infoPlist[key] = config.ios.infoPlist[key];
}
}
Expand Down
8 changes: 6 additions & 2 deletions plugin/src/withXcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export const withXcode: ConfigPlugin<{
bundleIdentifier: string;
deploymentTarget: string;
enableCompression?: boolean;
}> = (config, { name, targetName, bundleIdentifier, deploymentTarget, enableCompression }) => {
}> = (
config,
{ name, targetName, bundleIdentifier, deploymentTarget, enableCompression },
) => {
return withXcodeProject(config, (config) => {
const xcodeProject = config.modResults;
const appClipIcon = getAppClipIcon(config);
Expand Down Expand Up @@ -57,7 +60,7 @@ export const withXcode: ConfigPlugin<{

addTargetDependency(xcodeProject, target);

addPbxGroup(xcodeProject, {
const sourceFiles = addPbxGroup(xcodeProject, {
projectName: projectName as string,
targetName,
platformProjectRoot,
Expand All @@ -83,6 +86,7 @@ export const withXcode: ConfigPlugin<{
productFile,
enableCompression,
resourcesPhaseName: appClipIcon ? "Resources" : undefined,
sourceFiles,
});

if (appClipIcon) {
Expand Down
6 changes: 3 additions & 3 deletions plugin/src/xcode/addBuildPhases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export function addBuildPhases(
productFile,
enableCompression,
resourcesPhaseName,
sourceFiles,
}: {
targetUuid: string;
groupName: string;
Expand All @@ -20,13 +21,12 @@ export function addBuildPhases(
};
enableCompression?: boolean;
resourcesPhaseName?: string;
sourceFiles: string[];
},
) {
const buildPath = `"$(CONTENTS_FOLDER_PATH)/AppClips"`;
const folderType = "watch2_app"; // "watch2_app" uses the same subfolder spec (16), app_clip does not exist in cordova-node-xcode yet

const buildPhaseFiles = ["AppDelegate.swift"];

// Add shell script build phase "Start Packager"
xcodeProject.addBuildPhase(
[],
Expand All @@ -43,7 +43,7 @@ export function addBuildPhases(

// Sources build phase
xcodeProject.addBuildPhase(
buildPhaseFiles,
sourceFiles,
"PBXSourcesBuildPhase",
groupName,
targetUuid,
Expand Down
18 changes: 13 additions & 5 deletions plugin/src/xcode/addPbxGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ export function addPbxGroup(
fs.mkdirSync(targetPath, { recursive: true });
}

const filesToCopy = [
"SplashScreen.storyboard",
"AppDelegate.swift",
];
const sourceFiles = ["AppDelegate.swift"];
if (
fs.existsSync(
path.join(platformProjectRoot, projectName, "SceneDelegate.swift"),
)
) {
sourceFiles.push("SceneDelegate.swift");
}

const filesToCopy = ["SplashScreen.storyboard", ...sourceFiles];

for (const file of filesToCopy) {
const source = path.join(platformProjectRoot, projectName, file);
Expand All @@ -51,7 +57,7 @@ export function addPbxGroup(
// Add PBX group
const { uuid: pbxGroupUuid } = xcodeProject.addPbxGroup(
[
"AppDelegate.swift",
...sourceFiles,
"Info.plist",
"Images.xcassets",
"SplashScreen.storyboard",
Expand All @@ -72,6 +78,8 @@ export function addPbxGroup(
}
}
}

return sourceFiles;
}

function copyFileSync(source: string, target: string) {
Expand Down
Loading