Skip to content

Commit

Permalink
remove extra things added
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrico972 committed Dec 13, 2024
1 parent 738b3ec commit 126c463
Showing 1 changed file with 0 additions and 64 deletions.
64 changes: 0 additions & 64 deletions plugin/src/withAirshipIOS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ const NOTIFICATION_SERVICE_EXTENSION_TARGET_NAME = "AirshipNotificationServiceEx
const NOTIFICATION_SERVICE_FILE_NAME = "AirshipNotificationService.swift";
const NOTIFICATION_SERVICE_INFO_PLIST_FILE_NAME = "AirshipNotificationServiceExtension-Info.plist";

const AIRSHP_PLUGIN_EXTENDER_DIR_NAME = "AirshipPluginExtender";

const withCapabilities: ConfigPlugin<AirshipIOSPluginProps> = (config, props) => {
return withInfoPlist(config, (plist) => {
if (!Array.isArray(plist.modResults.UIBackgroundModes)) {
Expand Down Expand Up @@ -247,68 +245,6 @@ function getEasManagedCredentialsConfigExtra(config: ExpoConfig): {[k: string]:
}
}

const withAirshipExtender: ConfigPlugin<AirshipIOSPluginProps> = (config, props) => {
return withDangerousMod(config, [
'ios',
async config => {
await writeAirshipExtenderFileAsync(props, config.modRequest.projectRoot);
return config;
},
]);
};

async function writeAirshipExtenderFileAsync(props: AirshipIOSPluginProps, projectRoot: string) {
if (!props.airshipExtender) {
return;
}

const fileName = basename(props.airshipExtender)
const extenderDestinationPath = join(projectRoot, "ios", AIRSHP_PLUGIN_EXTENDER_DIR_NAME);

if (!existsSync(extenderDestinationPath)) {
mkdirSync(extenderDestinationPath, { recursive: true });
}

// Copy the Airship Extender file into the iOS expo project.
readFile(props.airshipExtender, 'utf8', (err, data) => {
if (err || !data) {
console.error("Airship couldn't read file " + (props.airshipExtender));
console.error(err);
return;
}
writeFileSync(join(extenderDestinationPath, fileName), data);
});
};

const withAirshipExtenderInMainTarget: ConfigPlugin<AirshipIOSPluginProps> = (config, props) => {
return withXcodeProject(config, newConfig => {
const xcodeProject = newConfig.modResults;

if (!!xcodeProject.pbxTargetByName(NOTIFICATION_SERVICE_EXTENSION_TARGET_NAME)) {
console.log(NOTIFICATION_SERVICE_EXTENSION_TARGET_NAME + " already exists in project. Skipping...");
return newConfig;
}

// Create new PBXGroup for the extension
const extGroup = xcodeProject.addPbxGroup(
[NOTIFICATION_SERVICE_FILE_NAME, NOTIFICATION_SERVICE_INFO_PLIST_FILE_NAME],
NOTIFICATION_SERVICE_EXTENSION_TARGET_NAME,
NOTIFICATION_SERVICE_EXTENSION_TARGET_NAME
);

// Add the new PBXGroup to the top level group. This makes the
// files / folder appear in the file explorer in Xcode.
const groups = xcodeProject.hash.project.objects["PBXGroup"];
Object.keys(groups).forEach(function(key) {
if (typeof groups[key] === "object" && groups[key].name === undefined && groups[key].path === undefined) {
xcodeProject.addToPbxGroup(extGroup.uuid, key);
}
});

return newConfig;
});
};

export const withAirshipIOS: ConfigPlugin<AirshipIOSPluginProps> = (config, props) => {
config = withCapabilities(config, props);
config = withAPNSEnvironment(config, props);
Expand Down

0 comments on commit 126c463

Please sign in to comment.