react-native-ios-widget 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +5 -0
- package/README.md +100 -0
- package/_widgets/EmojiRanger/AdventureActivityConfiguration.swift +71 -0
- package/_widgets/EmojiRanger/AllCharactersView.swift +43 -0
- package/_widgets/EmojiRanger/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/_widgets/EmojiRanger/Assets.xcassets/AppIcon.appiconset/Contents.json +13 -0
- package/_widgets/EmojiRanger/Assets.xcassets/Contents.json +6 -0
- package/_widgets/EmojiRanger/Assets.xcassets/WidgetBackground.colorset/Contents.json +11 -0
- package/_widgets/EmojiRanger/Attributes.swift +21 -0
- package/_widgets/EmojiRanger/EmojiRanger.swift +248 -0
- package/_widgets/EmojiRanger/EmojiRangersWidget.intentdefinition +118 -0
- package/_widgets/EmojiRanger/EmojiRangersWidget.swift +189 -0
- package/_widgets/EmojiRanger/EmojiRangersWidgetBundle.swift +21 -0
- package/_widgets/EmojiRanger/ImageURLProtocol.swift +66 -0
- package/_widgets/EmojiRanger/Info.plist +11 -0
- package/_widgets/EmojiRanger/LeaderboardWidget.swift +93 -0
- package/_widgets/EmojiRanger/Module.swift +94 -0
- package/_widgets/PizzaDelivery/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/_widgets/PizzaDelivery/Assets.xcassets/AppIcon.appiconset/Contents.json +13 -0
- package/_widgets/PizzaDelivery/Assets.xcassets/Contents.json +6 -0
- package/_widgets/PizzaDelivery/Assets.xcassets/WidgetBackground.colorset/Contents.json +11 -0
- package/_widgets/PizzaDelivery/Attributes.swift +15 -0
- package/_widgets/PizzaDelivery/Info.plist +11 -0
- package/_widgets/PizzaDelivery/LiveActivity.swift +108 -0
- package/_widgets/PizzaDelivery/Module.swift +94 -0
- package/_widgets/PizzaDelivery/WidgetBundle.swift +13 -0
- package/_widgets/PizzaDelivery/Widgets.swift +59 -0
- package/app.plugin.js +1 -0
- package/build/ExpoWidget.d.ts +3 -0
- package/build/ExpoWidget.d.ts.map +1 -0
- package/build/ExpoWidget.js +3 -0
- package/build/ExpoWidget.js.map +1 -0
- package/build/ReactNativeWidgetExtensionModule.d.ts +3 -0
- package/build/ReactNativeWidgetExtensionModule.d.ts.map +1 -0
- package/build/ReactNativeWidgetExtensionModule.js +5 -0
- package/build/ReactNativeWidgetExtensionModule.js.map +1 -0
- package/build/Widget.d.ts +2 -0
- package/build/Widget.d.ts.map +1 -0
- package/build/Widget.js +19 -0
- package/build/Widget.js.map +1 -0
- package/expo-module.config.json +6 -0
- package/ios/ReactNativeWidgetExtension.podspec +27 -0
- package/package.json +48 -0
- package/plugin/build/android/index.d.ts +10 -0
- package/plugin/build/android/index.js +18 -0
- package/plugin/build/android/withWidgetAndroidManifest.d.ts +5 -0
- package/plugin/build/android/withWidgetAndroidManifest.js +55 -0
- package/plugin/build/android/withWidgetAppBuildGradle.d.ts +7 -0
- package/plugin/build/android/withWidgetAppBuildGradle.js +20 -0
- package/plugin/build/android/withWidgetProjectBuildGradle.d.ts +8 -0
- package/plugin/build/android/withWidgetProjectBuildGradle.js +21 -0
- package/plugin/build/android/withWidgetSourceCode.d.ts +5 -0
- package/plugin/build/android/withWidgetSourceCode.js +51 -0
- package/plugin/build/index.d.ts +10 -0
- package/plugin/build/index.js +34 -0
- package/plugin/build/ios/index.d.ts +9 -0
- package/plugin/build/ios/index.js +34 -0
- package/plugin/build/ios/withConfig.d.ts +6 -0
- package/plugin/build/ios/withConfig.js +55 -0
- package/plugin/build/ios/withPodfile.d.ts +5 -0
- package/plugin/build/ios/withPodfile.js +83 -0
- package/plugin/build/ios/withWidgetExtensionEntitlements.d.ts +7 -0
- package/plugin/build/ios/withWidgetExtensionEntitlements.js +47 -0
- package/plugin/build/ios/withXcode.d.ts +7 -0
- package/plugin/build/ios/withXcode.js +79 -0
- package/plugin/build/lib/getWidgetExtensionEntitlements.d.ts +5 -0
- package/plugin/build/lib/getWidgetExtensionEntitlements.js +20 -0
- package/plugin/build/lib/getWidgetFiles.d.ts +9 -0
- package/plugin/build/lib/getWidgetFiles.js +117 -0
- package/plugin/build/withConfig.d.ts +6 -0
- package/plugin/build/withConfig.js +55 -0
- package/plugin/build/withPodfile.d.ts +5 -0
- package/plugin/build/withPodfile.js +83 -0
- package/plugin/build/withWidgetExtensionEntitlements.d.ts +7 -0
- package/plugin/build/withWidgetExtensionEntitlements.js +47 -0
- package/plugin/build/withXcode.d.ts +7 -0
- package/plugin/build/withXcode.js +79 -0
- package/plugin/build/xcode/addBuildPhases.d.ts +13 -0
- package/plugin/build/xcode/addBuildPhases.js +48 -0
- package/plugin/build/xcode/addPbxGroup.d.ts +6 -0
- package/plugin/build/xcode/addPbxGroup.js +25 -0
- package/plugin/build/xcode/addProductFile.d.ts +5 -0
- package/plugin/build/xcode/addProductFile.js +22 -0
- package/plugin/build/xcode/addTargetDependency.d.ts +4 -0
- package/plugin/build/xcode/addTargetDependency.js +15 -0
- package/plugin/build/xcode/addToPbxNativeTargetSection.d.ts +24 -0
- package/plugin/build/xcode/addToPbxNativeTargetSection.js +30 -0
- package/plugin/build/xcode/addToPbxProjectSection.d.ts +4 -0
- package/plugin/build/xcode/addToPbxProjectSection.js +15 -0
- package/plugin/build/xcode/addXCConfigurationList.d.ts +8 -0
- package/plugin/build/xcode/addXCConfigurationList.js +62 -0
- package/plugin/src/index.ts +52 -0
- package/plugin/src/lib/getWidgetExtensionEntitlements.ts +33 -0
- package/plugin/src/lib/getWidgetFiles.ts +109 -0
- package/plugin/src/withConfig.ts +71 -0
- package/plugin/src/withPodfile.ts +73 -0
- package/plugin/src/withWidgetExtensionEntitlements.ts +30 -0
- package/plugin/src/withXcode.ts +73 -0
- package/plugin/src/xcode/addBuildPhases.ts +83 -0
- package/plugin/src/xcode/addPbxGroup.ts +46 -0
- package/plugin/src/xcode/addProductFile.ts +25 -0
- package/plugin/src/xcode/addTargetDependency.ts +17 -0
- package/plugin/src/xcode/addToPbxNativeTargetSection.ts +46 -0
- package/plugin/src/xcode/addToPbxProjectSection.ts +23 -0
- package/plugin/src/xcode/addXCConfigurationList.ts +83 -0
- package/plugin/tsconfig.json +16 -0
- package/src/ReactNativeWidgetExtensionModule.ts +5 -0
- package/src/Widget.ts +25 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { mergeContents } from "@expo/config-plugins/build/utils/generateCode";
|
|
2
|
+
import { ConfigPlugin, withDangerousMod } from "expo/config-plugins";
|
|
3
|
+
import * as fs from "fs";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
|
|
6
|
+
export const withPodfile: ConfigPlugin<{
|
|
7
|
+
targetName: string;
|
|
8
|
+
pods?: string[];
|
|
9
|
+
}> = (config, { targetName, pods = [] }) => {
|
|
10
|
+
return withDangerousMod(config, [
|
|
11
|
+
"ios",
|
|
12
|
+
(config) => {
|
|
13
|
+
const podFilePath = path.join(
|
|
14
|
+
config.modRequest.platformProjectRoot,
|
|
15
|
+
"Podfile"
|
|
16
|
+
);
|
|
17
|
+
let podFileContent = fs.readFileSync(podFilePath).toString();
|
|
18
|
+
|
|
19
|
+
/* podFileContent = mergeContents({
|
|
20
|
+
tag: "withWidgetExtensionPodfile1999999999",
|
|
21
|
+
src: podFileContent,
|
|
22
|
+
newSrc: ` target '${targetName}' do\n \n end`,
|
|
23
|
+
anchor: /post_install/,
|
|
24
|
+
offset: 0,
|
|
25
|
+
comment: "#",
|
|
26
|
+
}).contents; */
|
|
27
|
+
|
|
28
|
+
/* podFileContent = podFileContent.replace(
|
|
29
|
+
/use_expo_modules!/,
|
|
30
|
+
`use_expo_modules!(searchPaths: ["./node_modules", "../../node_modules", "../../../WidgetExtension"])`
|
|
31
|
+
); */
|
|
32
|
+
|
|
33
|
+
podFileContent = mergeContents({
|
|
34
|
+
tag: "react-native-widget-extension-1",
|
|
35
|
+
src: podFileContent,
|
|
36
|
+
newSrc: `installer.pods_project.targets.each do |target|
|
|
37
|
+
target.build_configurations.each do |config|
|
|
38
|
+
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
|
|
39
|
+
end
|
|
40
|
+
end`,
|
|
41
|
+
anchor:
|
|
42
|
+
/installer.target_installation_results.pod_target_installation_results/,
|
|
43
|
+
offset: 0,
|
|
44
|
+
comment: "#",
|
|
45
|
+
}).contents;
|
|
46
|
+
|
|
47
|
+
/* podFileContent = mergeContents({
|
|
48
|
+
tag: "react-native-widget-extension-2",
|
|
49
|
+
src: podFileContent,
|
|
50
|
+
newSrc: `pod 'WidgetExtension', :path => '../WidgetExtension/ios'`,
|
|
51
|
+
anchor: /use_react_native/,
|
|
52
|
+
offset: -1,
|
|
53
|
+
comment: "#",
|
|
54
|
+
}).contents; */
|
|
55
|
+
|
|
56
|
+
podFileContent = podFileContent
|
|
57
|
+
.concat(`\n\n# >>> Inserted by react-native-widget-extension\n`)
|
|
58
|
+
.concat(
|
|
59
|
+
`target '${targetName}' do
|
|
60
|
+
use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
|
|
61
|
+
use_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS']
|
|
62
|
+
|
|
63
|
+
${pods.map((pod) => `pod '${pod}'`).join("\n")}
|
|
64
|
+
end`
|
|
65
|
+
)
|
|
66
|
+
.concat(`\n# >>> Inserted by react-native-widget-extension`);
|
|
67
|
+
|
|
68
|
+
fs.writeFileSync(podFilePath, podFileContent);
|
|
69
|
+
|
|
70
|
+
return config;
|
|
71
|
+
},
|
|
72
|
+
]);
|
|
73
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import plist from "@expo/plist";
|
|
2
|
+
import { ConfigPlugin, withInfoPlist } from "expo/config-plugins";
|
|
3
|
+
import * as fs from "fs";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
|
|
6
|
+
import { getWidgetExtensionEntitlements } from "./lib/getWidgetExtensionEntitlements";
|
|
7
|
+
|
|
8
|
+
export const withWidgetExtensionEntitlements: ConfigPlugin<{
|
|
9
|
+
targetName: string;
|
|
10
|
+
targetPath: string;
|
|
11
|
+
groupIdentifier: string;
|
|
12
|
+
appleSignin: boolean;
|
|
13
|
+
}> = (config, { targetName, groupIdentifier }) => {
|
|
14
|
+
return withInfoPlist(config, (config) => {
|
|
15
|
+
const targetPath = path.join(
|
|
16
|
+
config.modRequest.platformProjectRoot,
|
|
17
|
+
targetName
|
|
18
|
+
);
|
|
19
|
+
const filePath = path.join(targetPath, `${targetName}.entitlements`);
|
|
20
|
+
|
|
21
|
+
const appClipEntitlements = getWidgetExtensionEntitlements(config.ios, {
|
|
22
|
+
groupIdentifier,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
26
|
+
fs.writeFileSync(filePath, plist.build(appClipEntitlements));
|
|
27
|
+
|
|
28
|
+
return config;
|
|
29
|
+
});
|
|
30
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ConfigPlugin, withXcodeProject } from "expo/config-plugins";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
|
|
4
|
+
import { addXCConfigurationList } from "./xcode/addXCConfigurationList";
|
|
5
|
+
import { addProductFile } from "./xcode/addProductFile";
|
|
6
|
+
import { addToPbxNativeTargetSection } from "./xcode/addToPbxNativeTargetSection";
|
|
7
|
+
import { addToPbxProjectSection } from "./xcode/addToPbxProjectSection";
|
|
8
|
+
import { addTargetDependency } from "./xcode/addTargetDependency";
|
|
9
|
+
import { addPbxGroup } from "./xcode/addPbxGroup";
|
|
10
|
+
import { addBuildPhases } from "./xcode/addBuildPhases";
|
|
11
|
+
import { getWidgetFiles } from "./lib/getWidgetFiles";
|
|
12
|
+
|
|
13
|
+
export const withXcode: ConfigPlugin<{
|
|
14
|
+
targetName: string;
|
|
15
|
+
bundleIdentifier: string;
|
|
16
|
+
deploymentTarget: string;
|
|
17
|
+
widgetsFolder: string;
|
|
18
|
+
}> = (
|
|
19
|
+
config,
|
|
20
|
+
{ targetName, bundleIdentifier, deploymentTarget, widgetsFolder }
|
|
21
|
+
) => {
|
|
22
|
+
return withXcodeProject(config, (config) => {
|
|
23
|
+
const xcodeProject = config.modResults;
|
|
24
|
+
const widgetsPath = path.join(config.modRequest.projectRoot, widgetsFolder);
|
|
25
|
+
|
|
26
|
+
const targetUuid = xcodeProject.generateUuid();
|
|
27
|
+
const groupName = "Embed Foundation Extensions";
|
|
28
|
+
const { platformProjectRoot } = config.modRequest;
|
|
29
|
+
const marketingVersion = config.version;
|
|
30
|
+
|
|
31
|
+
const targetPath = path.join(platformProjectRoot, targetName);
|
|
32
|
+
|
|
33
|
+
const widgetFiles = getWidgetFiles(widgetsPath, targetPath);
|
|
34
|
+
|
|
35
|
+
const xCConfigurationList = addXCConfigurationList(xcodeProject, {
|
|
36
|
+
targetName,
|
|
37
|
+
currentProjectVersion: config.ios!.buildNumber || "1",
|
|
38
|
+
bundleIdentifier,
|
|
39
|
+
deploymentTarget,
|
|
40
|
+
marketingVersion,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const productFile = addProductFile(xcodeProject, {
|
|
44
|
+
targetName,
|
|
45
|
+
groupName,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const target = addToPbxNativeTargetSection(xcodeProject, {
|
|
49
|
+
targetName,
|
|
50
|
+
targetUuid,
|
|
51
|
+
productFile,
|
|
52
|
+
xCConfigurationList,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
addToPbxProjectSection(xcodeProject, target);
|
|
56
|
+
|
|
57
|
+
addTargetDependency(xcodeProject, target);
|
|
58
|
+
|
|
59
|
+
addBuildPhases(xcodeProject, {
|
|
60
|
+
targetUuid,
|
|
61
|
+
groupName,
|
|
62
|
+
productFile,
|
|
63
|
+
widgetFiles,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
addPbxGroup(xcodeProject, {
|
|
67
|
+
targetName,
|
|
68
|
+
widgetFiles,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return config;
|
|
72
|
+
});
|
|
73
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { XcodeProject } from "expo/config-plugins";
|
|
2
|
+
import * as util from "util";
|
|
3
|
+
|
|
4
|
+
import { WidgetFiles } from "../lib/getWidgetFiles";
|
|
5
|
+
|
|
6
|
+
export function addBuildPhases(
|
|
7
|
+
xcodeProject: XcodeProject,
|
|
8
|
+
{
|
|
9
|
+
targetUuid,
|
|
10
|
+
groupName,
|
|
11
|
+
productFile,
|
|
12
|
+
widgetFiles,
|
|
13
|
+
}: {
|
|
14
|
+
targetUuid: string;
|
|
15
|
+
groupName: string;
|
|
16
|
+
productFile: {
|
|
17
|
+
uuid: string;
|
|
18
|
+
target: string;
|
|
19
|
+
basename: string;
|
|
20
|
+
group: string;
|
|
21
|
+
};
|
|
22
|
+
widgetFiles: WidgetFiles;
|
|
23
|
+
}
|
|
24
|
+
) {
|
|
25
|
+
const buildPath = `""`;
|
|
26
|
+
const folderType = "app_extension";
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
swiftFiles,
|
|
30
|
+
assetDirectories,
|
|
31
|
+
entitlementFiles,
|
|
32
|
+
plistFiles,
|
|
33
|
+
fontFiles,
|
|
34
|
+
} = widgetFiles;
|
|
35
|
+
|
|
36
|
+
// Sources build phase
|
|
37
|
+
xcodeProject.addBuildPhase(
|
|
38
|
+
[...swiftFiles],
|
|
39
|
+
"PBXSourcesBuildPhase",
|
|
40
|
+
groupName,
|
|
41
|
+
targetUuid,
|
|
42
|
+
folderType,
|
|
43
|
+
buildPath
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// Copy files build phase
|
|
47
|
+
xcodeProject.addBuildPhase(
|
|
48
|
+
[],
|
|
49
|
+
"PBXCopyFilesBuildPhase",
|
|
50
|
+
groupName,
|
|
51
|
+
xcodeProject.getFirstTarget().uuid,
|
|
52
|
+
folderType,
|
|
53
|
+
buildPath
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
xcodeProject
|
|
57
|
+
.buildPhaseObject("PBXCopyFilesBuildPhase", groupName, productFile.target)
|
|
58
|
+
.files.push({
|
|
59
|
+
value: productFile.uuid,
|
|
60
|
+
comment: util.format("%s in %s", productFile.basename, productFile.group), // longComment(file);
|
|
61
|
+
});
|
|
62
|
+
xcodeProject.addToPbxBuildFileSection(productFile);
|
|
63
|
+
|
|
64
|
+
// Frameworks build phase
|
|
65
|
+
xcodeProject.addBuildPhase(
|
|
66
|
+
[],
|
|
67
|
+
"PBXFrameworksBuildPhase",
|
|
68
|
+
groupName,
|
|
69
|
+
targetUuid,
|
|
70
|
+
folderType,
|
|
71
|
+
buildPath
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
// Resources build phase
|
|
75
|
+
xcodeProject.addBuildPhase(
|
|
76
|
+
[...assetDirectories, ...fontFiles],
|
|
77
|
+
"PBXResourcesBuildPhase",
|
|
78
|
+
groupName,
|
|
79
|
+
targetUuid,
|
|
80
|
+
folderType,
|
|
81
|
+
buildPath
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { XcodeProject } from "expo/config-plugins";
|
|
2
|
+
|
|
3
|
+
import { WidgetFiles } from "../lib/getWidgetFiles";
|
|
4
|
+
|
|
5
|
+
export function addPbxGroup(
|
|
6
|
+
xcodeProject: XcodeProject,
|
|
7
|
+
{
|
|
8
|
+
targetName,
|
|
9
|
+
widgetFiles,
|
|
10
|
+
}: {
|
|
11
|
+
targetName: string;
|
|
12
|
+
widgetFiles: WidgetFiles;
|
|
13
|
+
}
|
|
14
|
+
) {
|
|
15
|
+
const {
|
|
16
|
+
swiftFiles,
|
|
17
|
+
assetDirectories,
|
|
18
|
+
entitlementFiles,
|
|
19
|
+
plistFiles,
|
|
20
|
+
fontFiles,
|
|
21
|
+
} = widgetFiles;
|
|
22
|
+
|
|
23
|
+
// Add PBX group
|
|
24
|
+
const { uuid: pbxGroupUuid } = xcodeProject.addPbxGroup(
|
|
25
|
+
[
|
|
26
|
+
...swiftFiles,
|
|
27
|
+
...entitlementFiles,
|
|
28
|
+
...plistFiles,
|
|
29
|
+
...fontFiles,
|
|
30
|
+
...assetDirectories,
|
|
31
|
+
`${targetName}.entitlements`,
|
|
32
|
+
],
|
|
33
|
+
targetName,
|
|
34
|
+
targetName
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Add PBXGroup to top level group
|
|
38
|
+
const groups = xcodeProject.hash.project.objects["PBXGroup"];
|
|
39
|
+
if (pbxGroupUuid) {
|
|
40
|
+
Object.keys(groups).forEach(function (key) {
|
|
41
|
+
if (groups[key].name === undefined && groups[key].path === undefined) {
|
|
42
|
+
xcodeProject.addToPbxGroup(pbxGroupUuid, key);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { XcodeProject } from "expo/config-plugins";
|
|
2
|
+
|
|
3
|
+
export function addProductFile(
|
|
4
|
+
xcodeProject: XcodeProject,
|
|
5
|
+
{ targetName, groupName }: { targetName: string; groupName: string }
|
|
6
|
+
) {
|
|
7
|
+
const options = {
|
|
8
|
+
basename: `${targetName}.appex`,
|
|
9
|
+
// fileRef: xcodeProject.generateUuid(),
|
|
10
|
+
// uuid: xcodeProject.generateUuid(),
|
|
11
|
+
group: groupName,
|
|
12
|
+
explicitFileType: "wrapper.app-extension",
|
|
13
|
+
/* fileEncoding: 4, */
|
|
14
|
+
settings: {
|
|
15
|
+
ATTRIBUTES: ["RemoveHeadersOnCopy"],
|
|
16
|
+
},
|
|
17
|
+
includeInIndex: 0,
|
|
18
|
+
path: `${targetName}.appex`,
|
|
19
|
+
sourceTree: "BUILT_PRODUCTS_DIR",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const productFile = xcodeProject.addProductFile(targetName, options);
|
|
23
|
+
|
|
24
|
+
return productFile;
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { XcodeProject } from "expo/config-plugins";
|
|
2
|
+
|
|
3
|
+
export function addTargetDependency(
|
|
4
|
+
xcodeProject: XcodeProject,
|
|
5
|
+
target: { uuid: string }
|
|
6
|
+
) {
|
|
7
|
+
if (!xcodeProject.hash.project.objects["PBXTargetDependency"]) {
|
|
8
|
+
xcodeProject.hash.project.objects["PBXTargetDependency"] = {};
|
|
9
|
+
}
|
|
10
|
+
if (!xcodeProject.hash.project.objects["PBXContainerItemProxy"]) {
|
|
11
|
+
xcodeProject.hash.project.objects["PBXContainerItemProxy"] = {};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
xcodeProject.addTargetDependency(xcodeProject.getFirstTarget().uuid, [
|
|
15
|
+
target.uuid,
|
|
16
|
+
]);
|
|
17
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { XcodeProject } from "expo/config-plugins";
|
|
2
|
+
|
|
3
|
+
export function addToPbxNativeTargetSection(
|
|
4
|
+
xcodeProject: XcodeProject,
|
|
5
|
+
{
|
|
6
|
+
targetName,
|
|
7
|
+
targetUuid,
|
|
8
|
+
productFile,
|
|
9
|
+
xCConfigurationList,
|
|
10
|
+
}: {
|
|
11
|
+
targetName: string;
|
|
12
|
+
targetUuid: string;
|
|
13
|
+
productFile: { fileRef: string };
|
|
14
|
+
xCConfigurationList: { uuid: string };
|
|
15
|
+
}
|
|
16
|
+
) {
|
|
17
|
+
const target = {
|
|
18
|
+
uuid: targetUuid,
|
|
19
|
+
pbxNativeTarget: {
|
|
20
|
+
isa: "PBXNativeTarget",
|
|
21
|
+
name: targetName,
|
|
22
|
+
productName: targetName,
|
|
23
|
+
productReference: productFile.fileRef,
|
|
24
|
+
productType: `"com.apple.product-type.app-extension"`,
|
|
25
|
+
buildConfigurationList: xCConfigurationList.uuid,
|
|
26
|
+
buildPhases: [],
|
|
27
|
+
buildRules: [],
|
|
28
|
+
dependencies: [],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
xcodeProject.addToPbxNativeTargetSection(target);
|
|
33
|
+
|
|
34
|
+
const frameworksGroup = xcodeProject.findPBXGroupKey({ name: "Frameworks" });
|
|
35
|
+
const file1 = xcodeProject.addFile("WidgetKit.framework", frameworksGroup);
|
|
36
|
+
const file2 = xcodeProject.addFile("SwiftUI.framework", frameworksGroup);
|
|
37
|
+
const frameworksBuildPhaseObj = xcodeProject.pbxFrameworksBuildPhaseObj(
|
|
38
|
+
target.uuid
|
|
39
|
+
);
|
|
40
|
+
/* console.log(
|
|
41
|
+
{ file1, file2, frameworksBuildPhaseObj },
|
|
42
|
+
frameworksBuildPhaseObj.files
|
|
43
|
+
); */
|
|
44
|
+
|
|
45
|
+
return target;
|
|
46
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { XcodeProject } from "expo/config-plugins";
|
|
2
|
+
|
|
3
|
+
export function addToPbxProjectSection(
|
|
4
|
+
xcodeProject: XcodeProject,
|
|
5
|
+
target: { uuid: string }
|
|
6
|
+
) {
|
|
7
|
+
xcodeProject.addToPbxProjectSection(target);
|
|
8
|
+
|
|
9
|
+
// Add target attributes to project section
|
|
10
|
+
if (
|
|
11
|
+
!xcodeProject.pbxProjectSection()[xcodeProject.getFirstProject().uuid]
|
|
12
|
+
.attributes.TargetAttributes
|
|
13
|
+
) {
|
|
14
|
+
xcodeProject.pbxProjectSection()[
|
|
15
|
+
xcodeProject.getFirstProject().uuid
|
|
16
|
+
].attributes.TargetAttributes = {};
|
|
17
|
+
}
|
|
18
|
+
xcodeProject.pbxProjectSection()[
|
|
19
|
+
xcodeProject.getFirstProject().uuid
|
|
20
|
+
].attributes.TargetAttributes[target.uuid] = {
|
|
21
|
+
LastSwiftMigration: 1250,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { XcodeProject } from "expo/config-plugins";
|
|
2
|
+
|
|
3
|
+
export function addXCConfigurationList(
|
|
4
|
+
xcodeProject: XcodeProject,
|
|
5
|
+
{
|
|
6
|
+
targetName,
|
|
7
|
+
currentProjectVersion,
|
|
8
|
+
bundleIdentifier,
|
|
9
|
+
deploymentTarget,
|
|
10
|
+
marketingVersion,
|
|
11
|
+
}: {
|
|
12
|
+
targetName: string;
|
|
13
|
+
currentProjectVersion: string;
|
|
14
|
+
bundleIdentifier: string;
|
|
15
|
+
deploymentTarget: string;
|
|
16
|
+
marketingVersion?: string;
|
|
17
|
+
}
|
|
18
|
+
) {
|
|
19
|
+
const commonBuildSettings: any = {
|
|
20
|
+
/* ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
|
21
|
+
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
|
|
22
|
+
CLANG_ANALYZER_NONNULL = YES;
|
|
23
|
+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
|
24
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
|
25
|
+
CLANG_ENABLE_OBJC_WEAK = YES;
|
|
26
|
+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
|
27
|
+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
|
28
|
+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
|
29
|
+
CODE_SIGN_STYLE = Automatic;
|
|
30
|
+
DEBUG_INFORMATION_FORMAT = dwarf;
|
|
31
|
+
DEVELOPMENT_TEAM = G76836P2D4;
|
|
32
|
+
GCC_C_LANGUAGE_STANDARD = gnu11;
|
|
33
|
+
|
|
34
|
+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
|
35
|
+
MARKETING_VERSION = 1.0;
|
|
36
|
+
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
|
37
|
+
MTL_FAST_MATH = YES;
|
|
38
|
+
SKIP_INSTALL = YES;
|
|
39
|
+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
|
40
|
+
SWIFT_EMIT_LOC_STRINGS = YES;
|
|
41
|
+
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; */
|
|
42
|
+
|
|
43
|
+
PRODUCT_NAME: `"$(TARGET_NAME)"`,
|
|
44
|
+
SWIFT_VERSION: "5.0",
|
|
45
|
+
TARGETED_DEVICE_FAMILY: `"1,2"`,
|
|
46
|
+
INFOPLIST_FILE: `${targetName}/Info.plist`,
|
|
47
|
+
CURRENT_PROJECT_VERSION: `"${currentProjectVersion}"`,
|
|
48
|
+
IPHONEOS_DEPLOYMENT_TARGET: `"${deploymentTarget}"`,
|
|
49
|
+
PRODUCT_BUNDLE_IDENTIFIER: `"${bundleIdentifier}"`,
|
|
50
|
+
GENERATE_INFOPLIST_FILE: `"YES"`,
|
|
51
|
+
INFOPLIST_KEY_CFBundleDisplayName: targetName,
|
|
52
|
+
INFOPLIST_KEY_NSHumanReadableCopyright: `""`,
|
|
53
|
+
MARKETING_VERSION: `"${marketingVersion}"`,
|
|
54
|
+
SWIFT_OPTIMIZATION_LEVEL: `"-Onone"`,
|
|
55
|
+
CODE_SIGN_ENTITLEMENTS: "WidgetsExtension/WidgetsExtension.entitlements",
|
|
56
|
+
// DEVELOPMENT_TEAM: `"G76836P2D4"`,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const buildConfigurationsList = [
|
|
60
|
+
{
|
|
61
|
+
name: "Debug",
|
|
62
|
+
isa: "XCBuildConfiguration",
|
|
63
|
+
buildSettings: {
|
|
64
|
+
...commonBuildSettings,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "Release",
|
|
69
|
+
isa: "XCBuildConfiguration",
|
|
70
|
+
buildSettings: {
|
|
71
|
+
...commonBuildSettings,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
const xCConfigurationList = xcodeProject.addXCConfigurationList(
|
|
77
|
+
buildConfigurationsList,
|
|
78
|
+
"Release",
|
|
79
|
+
`Build configuration list for PBXNativeTarget "${targetName}"`
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
return xCConfigurationList;
|
|
83
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "build",
|
|
4
|
+
"lib": ["ES2020"],
|
|
5
|
+
"module": "CommonJS",
|
|
6
|
+
"target": "ES2020",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"moduleResolution": "node"
|
|
13
|
+
},
|
|
14
|
+
"include": ["src"],
|
|
15
|
+
"exclude": ["**/__mocks__/*", "**/__tests__/*", "**/__stories__/*"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { requireNativeModule } from "expo-modules-core";
|
|
2
|
+
|
|
3
|
+
// It loads the native module object from the JSI or falls back to
|
|
4
|
+
// the bridge module (from NativeModulesProxy) if the remote debugger is on.
|
|
5
|
+
export default requireNativeModule("ReactNativeWidgetExtension");
|
package/src/Widget.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
import { requireNativeModule } from "expo-modules-core";
|
|
3
|
+
|
|
4
|
+
const ExpoWidget =
|
|
5
|
+
Platform.OS === "ios"
|
|
6
|
+
? requireNativeModule("ReactNativeWidgetExtension")
|
|
7
|
+
: undefined;
|
|
8
|
+
|
|
9
|
+
const checkWidgetSupport = () => {
|
|
10
|
+
if (Platform.OS === "ios") {
|
|
11
|
+
return parseInt(Platform.Version, 10) >= 14;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return false;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const supportWidgets = checkWidgetSupport();
|
|
18
|
+
|
|
19
|
+
export const reloadAllTimelines = async () => {
|
|
20
|
+
if (!supportWidgets || !ExpoWidget) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
await ExpoWidget.reloadAllTimelines();
|
|
25
|
+
};
|
package/tsconfig.json
ADDED