@bacons/apple-targets 0.1.5 → 0.1.6
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/build/index.js +2 -1
- package/build/withXcodeChanges.js +75 -105
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -42,7 +42,8 @@ const withTargetsDir = (config, _props) => {
|
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
(0, withPodTargetExtension_1.withPodTargetExtension)(config);
|
|
45
|
-
|
|
45
|
+
(0, withXcparse_1.withXcodeProjectBetaBaseMod)(config);
|
|
46
|
+
return config;
|
|
46
47
|
};
|
|
47
48
|
exports.withTargetsDir = withTargetsDir;
|
|
48
49
|
module.exports = exports.withTargetsDir;
|
|
@@ -648,8 +648,7 @@ async function applyXcodeChanges(config, project, props) {
|
|
|
648
648
|
}
|
|
649
649
|
const targets = getExtensionTargets();
|
|
650
650
|
const productName = props.name;
|
|
651
|
-
|
|
652
|
-
const targetToUpdate = (_a = targets.find((target) => target.props.productName === productName)) !== null && _a !== void 0 ? _a : targets[0];
|
|
651
|
+
let targetToUpdate = (_a = targets.find((target) => target.props.productName === productName)) !== null && _a !== void 0 ? _a : targets[0];
|
|
653
652
|
if (targetToUpdate) {
|
|
654
653
|
console.log(`Target "${targetToUpdate.props.productName}" already exists, updating instead of creating a new one`);
|
|
655
654
|
}
|
|
@@ -661,9 +660,14 @@ async function applyXcodeChanges(config, project, props) {
|
|
|
661
660
|
function applyDevelopmentTeamIdToTargets() {
|
|
662
661
|
var _a, _b;
|
|
663
662
|
var _c, _d, _e;
|
|
663
|
+
// Set to the provided value or any value.
|
|
664
|
+
const devTeamId = developmentTeamId ||
|
|
665
|
+
project.rootObject.props.targets
|
|
666
|
+
.map((target) => target.getDefaultBuildSetting("DEVELOPMENT_TEAM"))
|
|
667
|
+
.find(Boolean);
|
|
664
668
|
project.rootObject.props.targets.forEach((target) => {
|
|
665
|
-
if (
|
|
666
|
-
target.setBuildSetting("DEVELOPMENT_TEAM",
|
|
669
|
+
if (devTeamId) {
|
|
670
|
+
target.setBuildSetting("DEVELOPMENT_TEAM", devTeamId);
|
|
667
671
|
}
|
|
668
672
|
else {
|
|
669
673
|
target.removeBuildSetting("DEVELOPMENT_TEAM");
|
|
@@ -675,7 +679,7 @@ async function applyXcodeChanges(config, project, props) {
|
|
|
675
679
|
(_b = (_d = project.rootObject.props.attributes.TargetAttributes)[_e = target.uuid]) !== null && _b !== void 0 ? _b : (_d[_e] = {
|
|
676
680
|
CreatedOnToolsVersion: "14.3",
|
|
677
681
|
ProvisioningStyle: "Automatic",
|
|
678
|
-
DevelopmentTeam:
|
|
682
|
+
DevelopmentTeam: devTeamId,
|
|
679
683
|
});
|
|
680
684
|
}
|
|
681
685
|
}
|
|
@@ -779,95 +783,48 @@ async function applyXcodeChanges(config, project, props) {
|
|
|
779
783
|
// Create new build phases
|
|
780
784
|
targetToUpdate.props.buildConfigurationList =
|
|
781
785
|
createConfigurationListForType(project, props);
|
|
782
|
-
configureTargetWithEntitlements(targetToUpdate);
|
|
783
|
-
configureTargetWithPreview(targetToUpdate);
|
|
784
|
-
configureTargetWithKnownSettings(targetToUpdate);
|
|
785
|
-
configureJsExport(targetToUpdate);
|
|
786
|
-
applyDevelopmentTeamIdToTargets();
|
|
787
|
-
syncMarketingVersions();
|
|
788
|
-
return project;
|
|
789
|
-
}
|
|
790
|
-
const productType = (0, target_1.productTypeForType)(props.type);
|
|
791
|
-
const isExtension = productType === "com.apple.product-type.app-extension";
|
|
792
|
-
const isExtensionKit = productType === "com.apple.product-type.extensionkit-extension";
|
|
793
|
-
const appExtensionBuildFile = xcode_1.PBXBuildFile.create(project, {
|
|
794
|
-
fileRef: xcode_1.PBXFileReference.create(project, {
|
|
795
|
-
explicitFileType: isExtensionKit
|
|
796
|
-
? "wrapper.extensionkit-extension"
|
|
797
|
-
: "wrapper.app-extension",
|
|
798
|
-
includeInIndex: 0,
|
|
799
|
-
path: productName + (isExtension ? ".appex" : ".app"),
|
|
800
|
-
sourceTree: "BUILT_PRODUCTS_DIR",
|
|
801
|
-
}),
|
|
802
|
-
settings: {
|
|
803
|
-
ATTRIBUTES: ["RemoveHeadersOnCopy"],
|
|
804
|
-
},
|
|
805
|
-
});
|
|
806
|
-
project.rootObject.ensureProductGroup().props.children.push(
|
|
807
|
-
// @ts-expect-error
|
|
808
|
-
appExtensionBuildFile.props.fileRef);
|
|
809
|
-
const extensionTarget = project.rootObject.createNativeTarget({
|
|
810
|
-
buildConfigurationList: createConfigurationListForType(project, props),
|
|
811
|
-
name: productName,
|
|
812
|
-
productName,
|
|
813
|
-
// @ts-expect-error
|
|
814
|
-
productReference: appExtensionBuildFile.props.fileRef /* alphaExtension.appex */,
|
|
815
|
-
productType: productType,
|
|
816
|
-
});
|
|
817
|
-
configureTargetWithKnownSettings(extensionTarget);
|
|
818
|
-
configureTargetWithEntitlements(extensionTarget);
|
|
819
|
-
configureTargetWithPreview(extensionTarget);
|
|
820
|
-
extensionTarget.ensureFrameworks(props.frameworks);
|
|
821
|
-
extensionTarget.getSourcesBuildPhase();
|
|
822
|
-
extensionTarget.getResourcesBuildPhase();
|
|
823
|
-
configureJsExport(extensionTarget);
|
|
824
|
-
// Add the target dependency to the main app, should be only one.
|
|
825
|
-
mainAppTarget.props.dependencies.push(xcode_1.PBXTargetDependency.create(project, {
|
|
826
|
-
target: extensionTarget,
|
|
827
|
-
targetProxy: xcode_1.PBXContainerItemProxy.create(project, {
|
|
828
|
-
containerPortal: project.rootObject,
|
|
829
|
-
proxyType: 1,
|
|
830
|
-
remoteGlobalIDString: extensionTarget.uuid,
|
|
831
|
-
remoteInfo: productName,
|
|
832
|
-
}),
|
|
833
|
-
}));
|
|
834
|
-
const WELL_KNOWN_COPY_EXTENSIONS_NAME = (() => {
|
|
835
|
-
switch (props.type) {
|
|
836
|
-
case "clip":
|
|
837
|
-
return "Embed App Clips";
|
|
838
|
-
case "watch":
|
|
839
|
-
return "Embed Watch Content";
|
|
840
|
-
case "app-intent":
|
|
841
|
-
return "Embed ExtensionKit Extensions";
|
|
842
|
-
default:
|
|
843
|
-
return "Embed Foundation Extensions";
|
|
844
|
-
}
|
|
845
|
-
})();
|
|
846
|
-
// Could exist from a Share Extension
|
|
847
|
-
const copyFilesBuildPhase = mainAppTarget.props.buildPhases.find((phase) => {
|
|
848
|
-
if (xcode_1.PBXCopyFilesBuildPhase.is(phase)) {
|
|
849
|
-
// TODO: maybe there's a safer way to do this? The name is not a good identifier.
|
|
850
|
-
return phase.props.name === WELL_KNOWN_COPY_EXTENSIONS_NAME;
|
|
851
|
-
}
|
|
852
|
-
});
|
|
853
|
-
if (copyFilesBuildPhase) {
|
|
854
|
-
// Assume that this is the first run if there is no matching target that we identified from a previous run.
|
|
855
|
-
copyFilesBuildPhase.props.files.push(appExtensionBuildFile);
|
|
856
786
|
}
|
|
857
787
|
else {
|
|
858
|
-
|
|
859
|
-
|
|
788
|
+
const productType = (0, target_1.productTypeForType)(props.type);
|
|
789
|
+
const isExtension = productType === "com.apple.product-type.app-extension";
|
|
790
|
+
const isExtensionKit = productType === "com.apple.product-type.extensionkit-extension";
|
|
791
|
+
const appExtensionBuildFile = xcode_1.PBXBuildFile.create(project, {
|
|
792
|
+
fileRef: xcode_1.PBXFileReference.create(project, {
|
|
793
|
+
explicitFileType: isExtensionKit
|
|
794
|
+
? "wrapper.extensionkit-extension"
|
|
795
|
+
: "wrapper.app-extension",
|
|
796
|
+
includeInIndex: 0,
|
|
797
|
+
path: productName + (isExtension ? ".appex" : ".app"),
|
|
798
|
+
sourceTree: "BUILT_PRODUCTS_DIR",
|
|
799
|
+
}),
|
|
800
|
+
settings: {
|
|
801
|
+
ATTRIBUTES: ["RemoveHeadersOnCopy"],
|
|
802
|
+
},
|
|
803
|
+
});
|
|
804
|
+
project.rootObject.ensureProductGroup().props.children.push(
|
|
805
|
+
// @ts-expect-error
|
|
806
|
+
appExtensionBuildFile.props.fileRef);
|
|
807
|
+
targetToUpdate = project.rootObject.createNativeTarget({
|
|
808
|
+
buildConfigurationList: createConfigurationListForType(project, props),
|
|
809
|
+
name: productName,
|
|
810
|
+
productName,
|
|
811
|
+
// @ts-expect-error
|
|
812
|
+
productReference: appExtensionBuildFile.props.fileRef /* alphaExtension.appex */,
|
|
813
|
+
productType: productType,
|
|
860
814
|
});
|
|
815
|
+
const copyPhase = mainAppTarget.getCopyBuildPhaseForTarget(targetToUpdate);
|
|
816
|
+
if (!copyPhase.getBuildFile(appExtensionBuildFile.props.fileRef)) {
|
|
817
|
+
copyPhase.props.files.push(appExtensionBuildFile);
|
|
818
|
+
}
|
|
861
819
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
});
|
|
820
|
+
configureTargetWithKnownSettings(targetToUpdate);
|
|
821
|
+
configureTargetWithEntitlements(targetToUpdate);
|
|
822
|
+
configureTargetWithPreview(targetToUpdate);
|
|
823
|
+
targetToUpdate.ensureFrameworks(props.frameworks);
|
|
824
|
+
targetToUpdate.getSourcesBuildPhase();
|
|
825
|
+
targetToUpdate.getResourcesBuildPhase();
|
|
826
|
+
configureJsExport(targetToUpdate);
|
|
827
|
+
mainAppTarget.addDependency(targetToUpdate);
|
|
871
828
|
const assetsDir = path_1.default.join(magicCwd, "assets");
|
|
872
829
|
// TODO: Maybe just limit this to Safari extensions?
|
|
873
830
|
const explicitFolders = !fs_1.default.existsSync(assetsDir)
|
|
@@ -877,22 +834,35 @@ async function applyXcodeChanges(config, project, props) {
|
|
|
877
834
|
.filter((file) => file !== ".DS_Store" &&
|
|
878
835
|
fs_1.default.statSync(path_1.default.join(assetsDir, file)).isDirectory())
|
|
879
836
|
.map((file) => path_1.default.join("assets", file));
|
|
880
|
-
const
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
837
|
+
const protectedGroup = ensureProtectedGroup(project, path_1.default.dirname(props.cwd));
|
|
838
|
+
if (!protectedGroup.props.children.find((child) => child.props.path === path_1.default.basename(props.cwd))) {
|
|
839
|
+
const syncRootGroup = xcode_1.PBXFileSystemSynchronizedRootGroup.create(project, {
|
|
840
|
+
path: path_1.default.basename(props.cwd),
|
|
841
|
+
exceptions: [
|
|
842
|
+
xcode_1.PBXFileSystemSynchronizedBuildFileExceptionSet.create(project, {
|
|
843
|
+
target: targetToUpdate,
|
|
844
|
+
membershipExceptions: [
|
|
845
|
+
// TODO: What other files belong here, why is this here?
|
|
846
|
+
"Info.plist",
|
|
847
|
+
// Exclude the config path
|
|
848
|
+
path_1.default.relative(magicCwd, props.configPath),
|
|
849
|
+
].sort(),
|
|
850
|
+
}),
|
|
851
|
+
],
|
|
852
|
+
explicitFileTypes: {},
|
|
853
|
+
explicitFolders: [
|
|
854
|
+
// Replaces the previous `lastKnownFileType: "folder",` system that's used in things like Safari extensions to include folders of assets.
|
|
855
|
+
// ex: `"Resources/_locales", "Resources/images"`
|
|
856
|
+
...explicitFolders,
|
|
857
|
+
],
|
|
858
|
+
sourceTree: "<group>",
|
|
859
|
+
});
|
|
860
|
+
if (!targetToUpdate.props.fileSystemSynchronizedGroups) {
|
|
861
|
+
targetToUpdate.props.fileSystemSynchronizedGroups = [];
|
|
862
|
+
}
|
|
863
|
+
targetToUpdate.props.fileSystemSynchronizedGroups.push(syncRootGroup);
|
|
864
|
+
protectedGroup.props.children.push(syncRootGroup);
|
|
893
865
|
}
|
|
894
|
-
extensionTarget.props.fileSystemSynchronizedGroups.push(syncRootGroup);
|
|
895
|
-
ensureProtectedGroup(project, path_1.default.dirname(props.cwd)).props.children.push(syncRootGroup);
|
|
896
866
|
applyDevelopmentTeamIdToTargets();
|
|
897
867
|
syncMarketingVersions();
|
|
898
868
|
return project;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bacons/apple-targets",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Generate Apple Targets with Expo Prebuild",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"files": [
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@react-native/normalize-colors": "^0.76.1",
|
|
33
33
|
"glob": "^10.2.6",
|
|
34
|
-
"@bacons/xcode": "
|
|
34
|
+
"@bacons/xcode": "1.0.0-alpha.24",
|
|
35
35
|
"fs-extra": "^11.2.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|