Skip to content

Commit

Permalink
Add a BuildConfiguration target, which is used as dependency. The bui…
Browse files Browse the repository at this point in the history
…ld target runs the GenerateBuildConfig.sh to autogenerate a Swift file that exposes compile time values for the APPGROUP amongst others
  • Loading branch information
feralbob committed Sep 12, 2021
1 parent c0b6a60 commit 67431cf
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ fastlane/test_output
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
OpenSesameConfig.generated.swift
12 changes: 12 additions & 0 deletions Configuration/CodeSigningAndProvisioning.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,15 @@ PRODUCT_BUNDLE_IDENTIFIER = $(PRODUCT_BUNDLE_IDENTIFIER_BASE:default=com.ethanli
APP_GROUP_OVERRIDE =
APP_GROUP = $(APP_GROUP_OVERRIDE:default=group.OpenSesame.ethanlipnik)

// Expose a number of configured XCCONFIG settings via autogenerating a Swift file
// The BuildConfiguration target runs a script phase that runs GenerateBuildConfig.sh
// the script greps for environment variables prefixed with OPENSESAME_BUILDCONFIG_
// and then using sed generates OpenSesameConfig.generated.swift
//
// This allows for the Keychain code to make use of the APP_GROUP
// Whilst it is possible to get the Bundle Identifier at runtime; it doesn't appear
// to be possible to get the entitlements
// See this https://medium.com/@hamdullahshah/generating-code-from-xcode-configurations-6fd203ec69ef
// https://web.archive.org/web/20210911144926/https://medium.com/@hamdullahshah/generating-code-from-xcode-configurations-6fd203ec69ef
OPENSESAME_BUILDCONFIG_APP_GROUP = $(APP_GROUP)
OPENSESAME_BUILDCONFIG_PRODUCT_BUNDLE_IDENTIFIER_BASE = $(PRODUCT_BUNDLE_IDENTIFIER_BASE)
18 changes: 18 additions & 0 deletions Configuration/GenerateBuildConfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# GenerateBuildConfig.sh
# OpenSesame
#
# Created by Robert Shand on 2021-09-11.
#
echo "//Generated file please do not edit"
printf "//\n//\n//generated by GenerateBuildConfig.sh\n"
printf "import Foundation\n\n"
echo "struct OpenSesameConfig { "
echo " fileprivate init() {}"
env |\
grep "OPENSESAME_BUILDCONFIG_" | \
sed "s/OPENSESAME_BUILDCONFIG_/ static let /" | \
sed -E 's/=(.*)/ = "\1"/' | \
sed -E 's/"http.*/URL(string:&)!/'
echo "}"
128 changes: 128 additions & 0 deletions OpenSesame.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
objectVersion = 55;
objects = {

/* Begin PBXAggregateTarget section */
C45CE8FF26ECFF1B00ECD60D /* BuildConfiguration */ = {
isa = PBXAggregateTarget;
buildConfigurationList = C45CE90026ECFF1B00ECD60D /* Build configuration list for PBXAggregateTarget "BuildConfiguration" */;
buildPhases = (
C45CE90326ECFF2200ECD60D /* ShellScript */,
);
dependencies = (
);
name = BuildConfiguration;
productName = BuildConfiguration;
};
/* End PBXAggregateTarget section */

/* Begin PBXBuildFile section */
AA016A3226D577B8007397A7 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA016A3126D577B8007397A7 /* SettingsView.swift */; };
AA016A3326D581D4007397A7 /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA8B504626CD6457003C92AE /* CloudKit.framework */; };
Expand Down Expand Up @@ -177,6 +191,10 @@
AAF56EB226DD6F75003581AC /* NewCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF56EB126DD6F75003581AC /* NewCardView.swift */; };
AAF56EB326DD6F75003581AC /* NewCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF56EB126DD6F75003581AC /* NewCardView.swift */; };
AAFAF5EA26DD5E0900CD1B48 /* ParallaxMotionModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAFAF5E926DD5E0900CD1B48 /* ParallaxMotionModifier.swift */; };
C45CE90D26ECFFC800ECD60D /* OpenSesameConfig.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = C45CE90C26ECFFC800ECD60D /* OpenSesameConfig.generated.swift */; };
C45CE90E26ECFFC800ECD60D /* OpenSesameConfig.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = C45CE90C26ECFFC800ECD60D /* OpenSesameConfig.generated.swift */; };
C45CE90F26ECFFC800ECD60D /* OpenSesameConfig.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = C45CE90C26ECFFC800ECD60D /* OpenSesameConfig.generated.swift */; };
C45CE91026ECFFC800ECD60D /* OpenSesameConfig.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = C45CE90C26ECFFC800ECD60D /* OpenSesameConfig.generated.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -208,6 +226,34 @@
remoteGlobalIDString = AA8B501226CD641D003C92AE;
remoteInfo = "OpenSesame (macOS)";
};
C45CE90426ECFF3800ECD60D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = AA8B4FFE26CD641C003C92AE /* Project object */;
proxyType = 1;
remoteGlobalIDString = C45CE8FF26ECFF1B00ECD60D;
remoteInfo = BuildConfiguration;
};
C45CE90626ECFF4800ECD60D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = AA8B4FFE26CD641C003C92AE /* Project object */;
proxyType = 1;
remoteGlobalIDString = C45CE8FF26ECFF1B00ECD60D;
remoteInfo = BuildConfiguration;
};
C45CE90826ECFF5100ECD60D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = AA8B4FFE26CD641C003C92AE /* Project object */;
proxyType = 1;
remoteGlobalIDString = C45CE8FF26ECFF1B00ECD60D;
remoteInfo = BuildConfiguration;
};
C45CE90A26ECFF5600ECD60D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = AA8B4FFE26CD641C003C92AE /* Project object */;
proxyType = 1;
remoteGlobalIDString = C45CE8FF26ECFF1B00ECD60D;
remoteInfo = BuildConfiguration;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -353,6 +399,8 @@
C41CBD2026E12E6900BD2F91 /* CodeSigningAndProvisioning.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = CodeSigningAndProvisioning.xcconfig; sourceTree = "<group>"; };
C41CBD2126E12EC300BD2F91 /* Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
C41CBD2226E12ED600BD2F91 /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
C45CE8FC26ECFA4400ECD60D /* GenerateBuildConfig.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = GenerateBuildConfig.sh; sourceTree = "<group>"; };
C45CE90C26ECFFC800ECD60D /* OpenSesameConfig.generated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenSesameConfig.generated.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -768,9 +816,11 @@
C41CBD1F26E12E4300BD2F91 /* Configuration */ = {
isa = PBXGroup;
children = (
C45CE90C26ECFFC800ECD60D /* OpenSesameConfig.generated.swift */,
C41CBD2026E12E6900BD2F91 /* CodeSigningAndProvisioning.xcconfig */,
C41CBD2126E12EC300BD2F91 /* Debug.xcconfig */,
C41CBD2226E12ED600BD2F91 /* Release.xcconfig */,
C45CE8FC26ECFA4400ECD60D /* GenerateBuildConfig.sh */,
);
path = Configuration;
sourceTree = "<group>";
Expand All @@ -789,6 +839,7 @@
buildRules = (
);
dependencies = (
C45CE90926ECFF5100ECD60D /* PBXTargetDependency */,
);
name = "AutoFill iOS";
packageProductDependencies = (
Expand All @@ -810,6 +861,7 @@
buildRules = (
);
dependencies = (
C45CE90B26ECFF5600ECD60D /* PBXTargetDependency */,
);
name = "AutoFill macOS";
packageProductDependencies = (
Expand All @@ -833,6 +885,7 @@
buildRules = (
);
dependencies = (
C45CE90526ECFF3800ECD60D /* PBXTargetDependency */,
AA05CCEB26CDDA5200E27F6D /* PBXTargetDependency */,
);
name = "OpenSesame (iOS)";
Expand Down Expand Up @@ -861,6 +914,7 @@
buildRules = (
);
dependencies = (
C45CE90726ECFF4800ECD60D /* PBXTargetDependency */,
AA519A6826CEE5B700C1E354 /* PBXTargetDependency */,
);
name = "OpenSesame (macOS)";
Expand Down Expand Up @@ -941,6 +995,9 @@
CreatedOnToolsVersion = 13.0;
TestTargetID = AA8B501226CD641D003C92AE;
};
C45CE8FF26ECFF1B00ECD60D = {
CreatedOnToolsVersion = 13.0;
};
};
};
buildConfigurationList = AA8B500126CD641C003C92AE /* Build configuration list for PBXProject "OpenSesame" */;
Expand Down Expand Up @@ -970,6 +1027,7 @@
AA8B502326CD641D003C92AE /* Tests macOS */,
AA05CCDF26CDDA5200E27F6D /* AutoFill iOS */,
AA519A5C26CEE5B700C1E354 /* AutoFill macOS */,
C45CE8FF26ECFF1B00ECD60D /* BuildConfiguration */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -1036,6 +1094,27 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
C45CE90326ECFF2200ECD60D /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PROJECT_DIR}/Configuration/GenerateBuildConfig.sh\" > \"${PROJECT_DIR}/Configuration/OpenSesameConfig.generated.swift\"\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
AA05CCDC26CDDA5200E27F6D /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand All @@ -1045,6 +1124,7 @@
AAD3DBED26D342B900531E92 /* String+Misc.swift in Sources */,
AA49EA5026D3EBF300B12838 /* Credentials.swift in Sources */,
AA3754EE26DD28E4007FF26F /* OpenSesame.xcdatamodeld in Sources */,
C45CE90F26ECFFC800ECD60D /* OpenSesameConfig.generated.swift in Sources */,
AA08245226DDC304006BE956 /* Item.swift in Sources */,
AADB8A4B26E6A07000B17B66 /* Persistence+Container.swift in Sources */,
AAD3DBEC26D342B900531E92 /* URL+Misc.swift in Sources */,
Expand All @@ -1067,6 +1147,7 @@
AA49EA5126D3EBF300B12838 /* Credentials.swift in Sources */,
AAD3DBEE26D342B900531E92 /* URL+Misc.swift in Sources */,
AA3754EF26DD28E4007FF26F /* OpenSesame.xcdatamodeld in Sources */,
C45CE91026ECFFC800ECD60D /* OpenSesameConfig.generated.swift in Sources */,
AA08245326DDC304006BE956 /* Item.swift in Sources */,
AADB8A4C26E6A07000B17B66 /* Persistence+Container.swift in Sources */,
AA49EA4826D3EBCE00B12838 /* Data+Misc.swift in Sources */,
Expand Down Expand Up @@ -1116,6 +1197,7 @@
AA08245026DDC304006BE956 /* Item.swift in Sources */,
AA519A9126CF4B3800C1E354 /* OTPAuthenticatorService.swift in Sources */,
AAD3DBE926D342B800531E92 /* String+Misc.swift in Sources */,
C45CE90D26ECFFC800ECD60D /* OpenSesameConfig.generated.swift in Sources */,
AA1F6A2926CD6993004E1A81 /* VaultView.swift in Sources */,
AA3754F126DD38D2007FF26F /* VaultView+CardItemView.swift in Sources */,
AA49EA3F26D3EBA300B12838 /* Data+Misc.swift in Sources */,
Expand Down Expand Up @@ -1166,6 +1248,7 @@
AAD3DBEB26D342B800531E92 /* String+Misc.swift in Sources */,
AA519A8526CF2A5000C1E354 /* LockView.swift in Sources */,
AA49EA0C26D3EB1600B12838 /* ContentView+List.swift in Sources */,
C45CE90E26ECFFC800ECD60D /* OpenSesameConfig.generated.swift in Sources */,
AA49EA3126D3EB8600B12838 /* AccountDetailView+OTPView.swift in Sources */,
AA49EA1226D3EB2600B12838 /* LockView+CreatePassword.swift in Sources */,
AA016A3626D586DC007397A7 /* SettingsView+SyncView.swift in Sources */,
Expand Down Expand Up @@ -1230,6 +1313,26 @@
target = AA8B501226CD641D003C92AE /* OpenSesame (macOS) */;
targetProxy = AA8B502526CD641D003C92AE /* PBXContainerItemProxy */;
};
C45CE90526ECFF3800ECD60D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = C45CE8FF26ECFF1B00ECD60D /* BuildConfiguration */;
targetProxy = C45CE90426ECFF3800ECD60D /* PBXContainerItemProxy */;
};
C45CE90726ECFF4800ECD60D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = C45CE8FF26ECFF1B00ECD60D /* BuildConfiguration */;
targetProxy = C45CE90626ECFF4800ECD60D /* PBXContainerItemProxy */;
};
C45CE90926ECFF5100ECD60D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = C45CE8FF26ECFF1B00ECD60D /* BuildConfiguration */;
targetProxy = C45CE90826ECFF5100ECD60D /* PBXContainerItemProxy */;
};
C45CE90B26ECFF5600ECD60D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = C45CE8FF26ECFF1B00ECD60D /* BuildConfiguration */;
targetProxy = C45CE90A26ECFF5600ECD60D /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
Expand Down Expand Up @@ -1720,6 +1823,22 @@
};
name = Release;
};
C45CE90126ECFF1B00ECD60D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
C45CE90226ECFF1B00ECD60D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
Expand Down Expand Up @@ -1786,6 +1905,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C45CE90026ECFF1B00ECD60D /* Build configuration list for PBXAggregateTarget "BuildConfiguration" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C45CE90126ECFF1B00ECD60D /* Debug */,
C45CE90226ECFF1B00ECD60D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
Expand Down

0 comments on commit 67431cf

Please sign in to comment.