UNPKG

expo-plugin-ios-ads-frameworks

Version:

An Expo plugin to add iOS ad-related frameworks (AdSupport, AdServices, StoreKit, AppTrackingTransparency).

34 lines (28 loc) 970 B
const { withXcodeProject } = require("@expo/config-plugins"); const REQUIRED_FRAMEWORKS = [ "AdSupport.framework", "AdServices.framework", "StoreKit.framework", "AppTrackingTransparency.framework", ]; const addFrameworkToProject = (xcodeProject, framework) => { const frameworksGroup = xcodeProject.pbxGroupByName("Frameworks"); const hasFramework = frameworksGroup.children.some( (child) => child.comment === framework ); if (!hasFramework) { xcodeProject.addFramework(framework, { weak: true }); } }; const withIOSFrameworks = (config, pluginConfig) => { const FRAMEWORKS = pluginConfig?.REQUIRED_FRAMEWORKS || REQUIRED_FRAMEWORKS; return withXcodeProject(config, (config) => { const xcodeProject = config.modResults; // Add StoreKit.framework to the project FRAMEWORKS.forEach((framework) => { addFrameworkToProject(xcodeProject, framework); }); return config; }); }; module.exports = withIOSFrameworks;