Skip to content

Commit 891853f

Browse files
Revert to using a Target build phase script to make copy of .example if USER config doesn't yet exist
1 parent 04e3b49 commit 891853f

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ There is no need to modify any other files.
6262

6363
> **NOTE:** If `SQLiteLib-USER.xcconfig` doesn't exist, copy the `SQLiteLib-USER.xcconfig.example` file and rename it, or build once (which will automatically do this for you). ([Reference](#notes))
6464
65-
##### Special Note:
66-
67-
SQLiteLib's build process searches multiple locations for the `SQLiteLib-USER.xcconfig` file.
68-
69-
You can place the file in the **parent directory** (i.e. the directory that contains SQLiteLib.xcodeproj), and SQLiteLib will **always** use that version of the file.
70-
7165

7266
#### Compiling a Specific Version of SQLite:
7367

@@ -175,7 +169,9 @@ Xcode (verified in Version 7.3.1 (7D1014)) will always show "sqlite3.c" as red/m
175169

176170
This is a UI issue in Xcode - the path is properly set in the project.pbxproj file to be "Relative to Build Products", and the build should succeed.
177171

178-
##### There's no SQLiteLib-USER.xcconfig:
172+
##### Xcode displays a warning:
173+
`SQLiteLib.xcconfig line 6: Unable to find included file "SQLiteLib-USER.xcconfig"`
179174

180-
SQLiteLib will automatically generate this from the base template `SQLiteLib-USER.xcconfig.example` on first build, or you may copy and rename it yourself.
175+
SQLiteLib's project will automatically generate this from the base template `SQLiteLib-USER.xcconfig.example` on first build, or you may copy and rename it yourself.
181176

177+
(Future builds will not display the warning. The warning does not affect functionality.)

SQLiteLib.xcodeproj/project.pbxproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
isa = PBXAggregateTarget;
1212
buildConfigurationList = F3BA81441CFB4D5B003DC1BA /* Build configuration list for PBXAggregateTarget "amalgamation" */;
1313
buildPhases = (
14+
EEDD06761CFE1FD300478EC5 /* Copy .example configuration, if no USER configuration present */,
1415
F3BA81451CFB4D7B003DC1BA /* ShellScript */,
1516
);
1617
dependencies = (
@@ -154,6 +155,22 @@
154155
/* End PBXProject section */
155156

156157
/* Begin PBXShellScriptBuildPhase section */
158+
EEDD06761CFE1FD300478EC5 /* Copy .example configuration, if no USER configuration present */ = {
159+
isa = PBXShellScriptBuildPhase;
160+
buildActionMask = 2147483647;
161+
files = (
162+
);
163+
inputPaths = (
164+
"$(SRCROOT)/SQLiteLib-USER.xcconfig.example",
165+
);
166+
name = "Copy .example configuration, if no USER configuration present";
167+
outputPaths = (
168+
);
169+
runOnlyForDeploymentPostprocessing = 0;
170+
shellPath = /bin/sh;
171+
shellScript = "copiedfiles=false\nfor ((i=0; i < SCRIPT_INPUT_FILE_COUNT ; i++))\ndo\n INFILE=SCRIPT_INPUT_FILE_$i\n EXAMPLEFILE=${!INFILE};\n OUTPUTFILE=${EXAMPLEFILE%.example}\n echo \"${INFILE}=${EXAMPLEFILE}\"\n if [ -f \"$EXAMPLEFILE\" ]\n then\n if [ ! -f \"$OUTPUTFILE\" ];\n then\n echo \"Expected USER configuration file doesn't exist\"\n echo \"Copying .example file\"\n cp $EXAMPLEFILE $OUTPUTFILE\n touch $OUTPUTFILE\n copiedfiles=true\n else\n echo \"USER Configuration file already exists: ${OUTPUTFILE}\"\n echo \"Skipping .example copy.\"\n fi\n else\n echo \"Missing input .example file: ${EXAMPLEFILE}\"\n exit 1\n fi\ndone\n\nif [ \"$copiedfiles\" = true ] ; then\n touch \"${SRCROOT}/SQLiteLib.xcconfig\"\n sleep 1\nfi\n";
172+
showEnvVarsInLog = 0;
173+
};
157174
F3BA81451CFB4D7B003DC1BA /* ShellScript */ = {
158175
isa = PBXShellScriptBuildPhase;
159176
buildActionMask = 2147483647;

SQLiteLib.xcodeproj/xcshareddata/xcschemes/sqlitelib.xcscheme

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
33
LastUpgradeVersion = "0730"
4-
version = "1.7">
4+
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
77
buildImplicitDependencies = "YES">
8-
<PreActions>
9-
<ExecutionAction
10-
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
11-
<ActionContent
12-
title = "Process USER configuration"
13-
scriptText = "#&#10;# Process USER Configuration Files&#10;#&#10;# The choice of which FILE to use is as follows:&#10;# 1. If FILE exists in the parent directory of ${SRCROOT}, it is copied to ${SRCROOT}/FILE and used, else&#10;# 2. If FILE exists in ${SRCROOT} it is used, else&#10;# 3. The example file (FILE.example) is copied to ${SRCROOT}/FILE and is used&#10;&#10;SCRIPT_INPUT_FILE_COUNT=1&#10;SCRIPT_INPUT_FILE_0=&quot;${SRCROOT}/SQLiteLib-USER.xcconfig.example&quot;&#10;&#10;copiedfiles=false&#10;for ((i=0; i &lt; SCRIPT_INPUT_FILE_COUNT ; i++))&#10;do&#10; INFILE=SCRIPT_INPUT_FILE_$&#10; EXAMPLEFILE=${!INFILE};&#10; OUTPUTFILE=${EXAMPLEFILE%.example}&#10;&#10; OUTPUTFILENAME=$(basename $OUTPUTFILE)&#10;&#10; # Search parent directory of ${SRCROOT} for &quot;$OUTPUTFILENAME&quot; file.&#10; # Overwrite existing output file if parent override exists.&#10;&#10; PARENTOVERRIDE=&quot;${SRCROOT}/../${OUTPUTFILENAME}&quot;&#10;&#10; if [ -f &quot;$PARENTOVERRIDE&quot; ]&#10; then&#10; # Use parent override&#10; echo &quot;Parent USER configuration override exists - copying&quot;&#10; cp $PARENTOVERRIDE $OUTPUTFILE&#10; touch $OUTPUTFILE&#10; copiedfiles=true&#10; else&#10; # Use .example file, if output file doesn&apos;t exist&#10; if [ ! -f &quot;$OUTPUTFILE&quot; ];&#10; then&#10; echo &quot;${INFILE}=${EXAMPLEFILE}&quot;&#10; if [ -f &quot;$EXAMPLEFILE&quot; ]&#10; then&#10; echo &quot;Expected USER configuration file doesn&apos;t exist&quot;&#10; echo &quot;Copying .example file&quot;&#10; cp $EXAMPLEFILE $OUTPUTFILE&#10; touch $OUTPUTFILE&#10; copiedfiles=true&#10; else&#10; echo &quot;Missing input .example file: ${EXAMPLEFILE}&quot;&#10; exit 1&#10; fi&#10; else&#10; echo &quot;USER Configuration file already exists: ${OUTPUTFILE}&quot;&#10; echo &quot;Using existing file.&quot;&#10; fi&#10; fi&#10;done&#10;&#10;if [ &quot;$copiedfiles&quot; = true ] ; then&#10; touch &quot;${SRCROOT}/SQLiteLib.xcconfig&quot;&#10; sleep .5&#10;fi&#10;"
14-
shellToInvoke = "/bin/sh">
15-
<EnvironmentBuildable>
16-
<BuildableReference
17-
BuildableIdentifier = "primary"
18-
BlueprintIdentifier = "D2AAC045055464E500DB518D"
19-
BuildableName = "libsqlitecustom.a"
20-
BlueprintName = "sqlitecustom"
21-
ReferencedContainer = "container:SQLiteLib.xcodeproj">
22-
</BuildableReference>
23-
</EnvironmentBuildable>
24-
</ActionContent>
25-
</ExecutionAction>
26-
</PreActions>
278
<BuildActionEntries>
289
<BuildActionEntry
2910
buildForTesting = "YES"

0 commit comments

Comments
 (0)