Skip to content

Commit a34ec71

Browse files
author
Aleksandar Vacic
committed
A better approach
- no additional target - run script before Compile Sources re #102
1 parent 8e7d73f commit a34ec71

File tree

2 files changed

+77
-100
lines changed

2 files changed

+77
-100
lines changed

Diff for: Build-Phases/common-crypto.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
COMMON_CRYPTO_DIR="${SDKROOT}/usr/include/CommonCrypto"
2+
if [ -f "${COMMON_CRYPTO_DIR}/module.modulemap" ]
3+
then
4+
echo "CommonCrypto already exists, skipping"
5+
else
6+
# This if-statement means we'll only run the main script if the
7+
# CommonCrypto.framework directory doesn't exist because otherwise
8+
# the rest of the script causes a full recompile for anything
9+
# where CommonCrypto is a dependency
10+
# Do a "Clean Build Folder" to remove this directory and trigger
11+
# the rest of the script to run
12+
FRAMEWORK_DIR="${BUILT_PRODUCTS_DIR}/CommonCrypto.framework"
13+
14+
if [ -d "${FRAMEWORK_DIR}" ]; then
15+
echo "${FRAMEWORK_DIR} already exists, so skipping the rest of the script."
16+
exit 0
17+
fi
18+
19+
mkdir -p "${FRAMEWORK_DIR}/Modules"
20+
echo "module CommonCrypto [system] {
21+
header \"${SDKROOT}/usr/include/CommonCrypto/CommonCrypto.h\"
22+
export *
23+
}" >> "${FRAMEWORK_DIR}/Modules/module.modulemap"
24+
25+
ln -sf "${SDKROOT}/usr/include/CommonCrypto" "${FRAMEWORK_DIR}/Headers"
26+
fi

Diff for: JWT.xcodeproj/project.pbxproj

+51-100
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,6 @@
66
objectVersion = 46;
77
objects = {
88

9-
/* Begin PBXAggregateTarget section */
10-
D0A831662110E20A00DEA3E1 /* CommonCryptoModuleMap */ = {
11-
isa = PBXAggregateTarget;
12-
buildConfigurationList = D0A831672110E20A00DEA3E1 /* Build configuration list for PBXAggregateTarget "CommonCryptoModuleMap" */;
13-
buildPhases = (
14-
D0A8316A2110E23200DEA3E1 /* ShellScript */,
15-
);
16-
dependencies = (
17-
);
18-
name = CommonCryptoModuleMap;
19-
productName = CommonCryptoModuleMap;
20-
};
21-
/* End PBXAggregateTarget section */
22-
239
/* Begin PBXBuildFile section */
2410
271E10801F90253300B5033C /* JWA.swift in Sources */ = {isa = PBXBuildFile; fileRef = 271E107F1F90253300B5033C /* JWA.swift */; };
2511
271E10811F90253300B5033C /* JWA.swift in Sources */ = {isa = PBXBuildFile; fileRef = 271E107F1F90253300B5033C /* JWA.swift */; };
@@ -91,34 +77,6 @@
9177
remoteGlobalIDString = 279D639B1AD07FFF0024E2BC;
9278
remoteInfo = JWT;
9379
};
94-
D0A8316B2110E2A700DEA3E1 /* PBXContainerItemProxy */ = {
95-
isa = PBXContainerItemProxy;
96-
containerPortal = 279D63931AD07FFF0024E2BC /* Project object */;
97-
proxyType = 1;
98-
remoteGlobalIDString = D0A831662110E20A00DEA3E1;
99-
remoteInfo = CommonCryptoModuleMap;
100-
};
101-
D0A8316D2110E2AF00DEA3E1 /* PBXContainerItemProxy */ = {
102-
isa = PBXContainerItemProxy;
103-
containerPortal = 279D63931AD07FFF0024E2BC /* Project object */;
104-
proxyType = 1;
105-
remoteGlobalIDString = D0A831662110E20A00DEA3E1;
106-
remoteInfo = CommonCryptoModuleMap;
107-
};
108-
D0A8316F2110E2B500DEA3E1 /* PBXContainerItemProxy */ = {
109-
isa = PBXContainerItemProxy;
110-
containerPortal = 279D63931AD07FFF0024E2BC /* Project object */;
111-
proxyType = 1;
112-
remoteGlobalIDString = D0A831662110E20A00DEA3E1;
113-
remoteInfo = CommonCryptoModuleMap;
114-
};
115-
D0A831712110E2BC00DEA3E1 /* PBXContainerItemProxy */ = {
116-
isa = PBXContainerItemProxy;
117-
containerPortal = 279D63931AD07FFF0024E2BC /* Project object */;
118-
proxyType = 1;
119-
remoteGlobalIDString = D0A831662110E20A00DEA3E1;
120-
remoteInfo = CommonCryptoModuleMap;
121-
};
12280
/* End PBXContainerItemProxy section */
12381

12482
/* Begin PBXFileReference section */
@@ -153,6 +111,7 @@
153111
CD9B62351C7753EC005D4844 /* JWT.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = JWT.framework; sourceTree = BUILT_PRODUCTS_DIR; };
154112
CD9B62471C7753FB005D4844 /* JWT.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = JWT.framework; sourceTree = BUILT_PRODUCTS_DIR; };
155113
CE8198B6E30BA6B8F8125FA7 /* Pods_JWTTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_JWTTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
114+
D0882E042111B6460012248F /* Build-Phases */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "Build-Phases"; sourceTree = "<group>"; };
156115
/* End PBXFileReference section */
157116

158117
/* Begin PBXFrameworksBuildPhase section */
@@ -218,6 +177,7 @@
218177
279D63921AD07FFF0024E2BC = {
219178
isa = PBXGroup;
220179
children = (
180+
D0882E042111B6460012248F /* Build-Phases */,
221181
520A711B1C469F440005C709 /* Package.swift */,
222182
520A71121C469F010005C709 /* Sources */,
223183
279D639E1AD07FFF0024E2BC /* Sources */,
@@ -342,6 +302,7 @@
342302
isa = PBXNativeTarget;
343303
buildConfigurationList = 279D63B21AD07FFF0024E2BC /* Build configuration list for PBXNativeTarget "JWT-OSX" */;
344304
buildPhases = (
305+
D0882DFF2111B2CE0012248F /* Run Script: CommonCrypto */,
345306
279D63971AD07FFF0024E2BC /* Sources */,
346307
279D63981AD07FFF0024E2BC /* Frameworks */,
347308
279D63991AD07FFF0024E2BC /* Headers */,
@@ -350,7 +311,6 @@
350311
buildRules = (
351312
);
352313
dependencies = (
353-
D0A8316C2110E2A700DEA3E1 /* PBXTargetDependency */,
354314
);
355315
name = "JWT-OSX";
356316
productName = JWT;
@@ -379,6 +339,7 @@
379339
isa = PBXNativeTarget;
380340
buildConfigurationList = CD9B62201C7753D8005D4844 /* Build configuration list for PBXNativeTarget "JWT-iOS" */;
381341
buildPhases = (
342+
D0882E012111B5C70012248F /* Run Script: CommonCrypto */,
382343
CD9B62161C7753D8005D4844 /* Sources */,
383344
CD9B621B1C7753D8005D4844 /* Frameworks */,
384345
CD9B621D1C7753D8005D4844 /* Headers */,
@@ -387,7 +348,6 @@
387348
buildRules = (
388349
);
389350
dependencies = (
390-
D0A8316E2110E2AF00DEA3E1 /* PBXTargetDependency */,
391351
);
392352
name = "JWT-iOS";
393353
productName = JWT;
@@ -398,6 +358,7 @@
398358
isa = PBXNativeTarget;
399359
buildConfigurationList = CD9B62321C7753EC005D4844 /* Build configuration list for PBXNativeTarget "JWT-tvOS" */;
400360
buildPhases = (
361+
D0882E022111B5DC0012248F /* Run Script: CommonCrypto */,
401362
CD9B62281C7753EC005D4844 /* Sources */,
402363
CD9B622D1C7753EC005D4844 /* Frameworks */,
403364
CD9B622F1C7753EC005D4844 /* Headers */,
@@ -406,7 +367,6 @@
406367
buildRules = (
407368
);
408369
dependencies = (
409-
D0A831702110E2B500DEA3E1 /* PBXTargetDependency */,
410370
);
411371
name = "JWT-tvOS";
412372
productName = JWT;
@@ -417,6 +377,7 @@
417377
isa = PBXNativeTarget;
418378
buildConfigurationList = CD9B62441C7753FB005D4844 /* Build configuration list for PBXNativeTarget "JWT-watchOS" */;
419379
buildPhases = (
380+
D0882E032111B5EE0012248F /* Run Script: CommonCrypto */,
420381
CD9B623A1C7753FB005D4844 /* Sources */,
421382
CD9B623F1C7753FB005D4844 /* Frameworks */,
422383
CD9B62411C7753FB005D4844 /* Headers */,
@@ -425,7 +386,6 @@
425386
buildRules = (
426387
);
427388
dependencies = (
428-
D0A831722110E2BC00DEA3E1 /* PBXTargetDependency */,
429389
);
430390
name = "JWT-watchOS";
431391
productName = JWT;
@@ -449,10 +409,6 @@
449409
279D63A61AD07FFF0024E2BC = {
450410
CreatedOnToolsVersion = 6.2;
451411
};
452-
D0A831662110E20A00DEA3E1 = {
453-
CreatedOnToolsVersion = 10.0;
454-
ProvisioningStyle = Automatic;
455-
};
456412
};
457413
};
458414
buildConfigurationList = 279D63961AD07FFF0024E2BC /* Build configuration list for PBXProject "JWT" */;
@@ -472,7 +428,6 @@
472428
CD9B62251C7753EC005D4844 /* JWT-tvOS */,
473429
CD9B62371C7753FB005D4844 /* JWT-watchOS */,
474430
279D63A61AD07FFF0024E2BC /* JWTTests */,
475-
D0A831662110E20A00DEA3E1 /* CommonCryptoModuleMap */,
476431
);
477432
};
478433
/* End PBXProject section */
@@ -516,18 +471,61 @@
516471
/* End PBXResourcesBuildPhase section */
517472

518473
/* Begin PBXShellScriptBuildPhase section */
519-
D0A8316A2110E23200DEA3E1 /* ShellScript */ = {
474+
D0882DFF2111B2CE0012248F /* Run Script: CommonCrypto */ = {
475+
isa = PBXShellScriptBuildPhase;
476+
buildActionMask = 2147483647;
477+
files = (
478+
);
479+
inputPaths = (
480+
);
481+
name = "Run Script: CommonCrypto";
482+
outputPaths = (
483+
);
484+
runOnlyForDeploymentPostprocessing = 0;
485+
shellPath = /bin/sh;
486+
shellScript = "$SRCROOT/Build-Phases/common-crypto.sh";
487+
};
488+
D0882E012111B5C70012248F /* Run Script: CommonCrypto */ = {
489+
isa = PBXShellScriptBuildPhase;
490+
buildActionMask = 2147483647;
491+
files = (
492+
);
493+
inputPaths = (
494+
);
495+
name = "Run Script: CommonCrypto";
496+
outputPaths = (
497+
);
498+
runOnlyForDeploymentPostprocessing = 0;
499+
shellPath = /bin/sh;
500+
shellScript = "$SRCROOT/Build-Phases/common-crypto.sh";
501+
};
502+
D0882E022111B5DC0012248F /* Run Script: CommonCrypto */ = {
520503
isa = PBXShellScriptBuildPhase;
521504
buildActionMask = 2147483647;
522505
files = (
523506
);
524507
inputPaths = (
525508
);
509+
name = "Run Script: CommonCrypto";
526510
outputPaths = (
527511
);
528512
runOnlyForDeploymentPostprocessing = 0;
529513
shellPath = /bin/sh;
530-
shellScript = "COMMON_CRYPTO_DIR=\"${SDKROOT}/usr/include/CommonCrypto\"\nif [ -f \"${COMMON_CRYPTO_DIR}/module.modulemap\" ]\nthen\necho \"CommonCrypto already exists, skipping\"\nelse\n# This if-statement means we'll only run the main script if the CommonCryptoModuleMap directory doesn't exist\n# Because otherwise the rest of the script causes a full recompile for anything where CommonCrypto is a dependency\n# Do a \"Clean Build Folder\" to remove this directory and trigger the rest of the script to run\nif [ -d \"${BUILT_PRODUCTS_DIR}/CommonCryptoModuleMap\" ]; then\necho \"${BUILT_PRODUCTS_DIR}/CommonCryptoModuleMap directory already exists, so skipping the rest of the script.\"\nexit 0\nfi\n\nmkdir -p \"${BUILT_PRODUCTS_DIR}/CommonCryptoModuleMap\"\ncat <<EOF > \"${BUILT_PRODUCTS_DIR}/CommonCryptoModuleMap/module.modulemap\"\nmodule CommonCrypto [system] {\n header \"${SDKROOT}/usr/include/CommonCrypto/CommonCrypto.h\"\n export *\n}\nEOF\necho \"Built ${BUILT_PRODUCTS_DIR}/CommonCryptoModuleMap directory\"\nfi";
514+
shellScript = "$SRCROOT/Build-Phases/common-crypto.sh";
515+
};
516+
D0882E032111B5EE0012248F /* Run Script: CommonCrypto */ = {
517+
isa = PBXShellScriptBuildPhase;
518+
buildActionMask = 2147483647;
519+
files = (
520+
);
521+
inputPaths = (
522+
);
523+
name = "Run Script: CommonCrypto";
524+
outputPaths = (
525+
);
526+
runOnlyForDeploymentPostprocessing = 0;
527+
shellPath = /bin/sh;
528+
shellScript = "$SRCROOT/Build-Phases/common-crypto.sh";
531529
};
532530
/* End PBXShellScriptBuildPhase section */
533531

@@ -630,26 +628,6 @@
630628
target = 279D639B1AD07FFF0024E2BC /* JWT-OSX */;
631629
targetProxy = 279D63A91AD07FFF0024E2BC /* PBXContainerItemProxy */;
632630
};
633-
D0A8316C2110E2A700DEA3E1 /* PBXTargetDependency */ = {
634-
isa = PBXTargetDependency;
635-
target = D0A831662110E20A00DEA3E1 /* CommonCryptoModuleMap */;
636-
targetProxy = D0A8316B2110E2A700DEA3E1 /* PBXContainerItemProxy */;
637-
};
638-
D0A8316E2110E2AF00DEA3E1 /* PBXTargetDependency */ = {
639-
isa = PBXTargetDependency;
640-
target = D0A831662110E20A00DEA3E1 /* CommonCryptoModuleMap */;
641-
targetProxy = D0A8316D2110E2AF00DEA3E1 /* PBXContainerItemProxy */;
642-
};
643-
D0A831702110E2B500DEA3E1 /* PBXTargetDependency */ = {
644-
isa = PBXTargetDependency;
645-
target = D0A831662110E20A00DEA3E1 /* CommonCryptoModuleMap */;
646-
targetProxy = D0A8316F2110E2B500DEA3E1 /* PBXContainerItemProxy */;
647-
};
648-
D0A831722110E2BC00DEA3E1 /* PBXTargetDependency */ = {
649-
isa = PBXTargetDependency;
650-
target = D0A831662110E20A00DEA3E1 /* CommonCryptoModuleMap */;
651-
targetProxy = D0A831712110E2BC00DEA3E1 /* PBXContainerItemProxy */;
652-
};
653631
/* End PBXTargetDependency section */
654632

655633
/* Begin XCBuildConfiguration section */
@@ -947,24 +925,6 @@
947925
};
948926
name = Release;
949927
};
950-
D0A831682110E20A00DEA3E1 /* Debug */ = {
951-
isa = XCBuildConfiguration;
952-
buildSettings = {
953-
CODE_SIGN_STYLE = Automatic;
954-
PRODUCT_NAME = "$(TARGET_NAME)";
955-
SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos appletvsimulator appletvos watchsimulator watchos";
956-
};
957-
name = Debug;
958-
};
959-
D0A831692110E20A00DEA3E1 /* Release */ = {
960-
isa = XCBuildConfiguration;
961-
buildSettings = {
962-
CODE_SIGN_STYLE = Automatic;
963-
PRODUCT_NAME = "$(TARGET_NAME)";
964-
SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos appletvsimulator appletvos watchsimulator watchos";
965-
};
966-
name = Release;
967-
};
968928
/* End XCBuildConfiguration section */
969929

970930
/* Begin XCConfigurationList section */
@@ -1022,15 +982,6 @@
1022982
defaultConfigurationIsVisible = 0;
1023983
defaultConfigurationName = Release;
1024984
};
1025-
D0A831672110E20A00DEA3E1 /* Build configuration list for PBXAggregateTarget "CommonCryptoModuleMap" */ = {
1026-
isa = XCConfigurationList;
1027-
buildConfigurations = (
1028-
D0A831682110E20A00DEA3E1 /* Debug */,
1029-
D0A831692110E20A00DEA3E1 /* Release */,
1030-
);
1031-
defaultConfigurationIsVisible = 0;
1032-
defaultConfigurationName = Release;
1033-
};
1034985
/* End XCConfigurationList section */
1035986
};
1036987
rootObject = 279D63931AD07FFF0024E2BC /* Project object */;

0 commit comments

Comments
 (0)