-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_xcode_project.rb
More file actions
277 lines (248 loc) · 7.53 KB
/
create_xcode_project.rb
File metadata and controls
277 lines (248 loc) · 7.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#!/usr/bin/env ruby
require 'securerandom'
require 'fileutils'
# Generate Xcode-style UUIDs
def generate_uuid
SecureRandom.uuid.delete('-').upcase[0..23]
end
project_name = "Bastion"
project_dir = File.expand_path(".")
pbxproj_path = "#{project_dir}/#{project_name}.xcodeproj/project.pbxproj"
# Create xcodeproj directory
FileUtils.mkdir_p("#{project_name}.xcodeproj")
# Find all Swift files
swift_files = Dir.glob("#{project_dir}/Bastion/**/*.swift")
puts "Found #{swift_files.length} Swift files"
# Generate UUIDs for all files
file_refs = {}
build_files = {}
swift_files.each do |file|
relative_path = file.sub("#{project_dir}/", "")
file_refs[file] = generate_uuid
build_files[file] = generate_uuid
end
# Additional UUIDs for project structure
main_group = generate_uuid
bastion_group = generate_uuid
products_group = generate_uuid
frameworks_group = generate_uuid
target_uuid = generate_uuid
sources_phase = generate_uuid
frameworks_phase = generate_uuid
resources_phase = generate_uuid
app_product = generate_uuid
project_uuid = generate_uuid
config_list = generate_uuid
debug_config = generate_uuid
release_config = generate_uuid
puts "Generating project.pbxproj..."
# Create project.pbxproj content
pbxproj_content = <<PBXPROJ
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objects = {
/* Begin PBXBuildFile section */
PBXPROJ
# Add build file references
swift_files.each do |file|
filename = File.basename(file)
pbxproj_content += "\t\t#{build_files[file]} /* #{filename} in Sources */ = {isa = PBXBuildFile; fileRef = #{file_refs[file]} /* #{filename} */; };\n"
end
pbxproj_content += <<PBXPROJ
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
PBXPROJ
# Add file references
swift_files.each do |file|
filename = File.basename(file)
relative_path = file.sub("#{project_dir}/", "")
pbxproj_content += "\t\t#{file_refs[file]} /* #{filename} */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = #{relative_path}; sourceTree = \"<group>\"; };\n"
end
pbxproj_content += "\t\t#{app_product} /* #{project_name}.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = #{project_name}.app; sourceTree = BUILT_PRODUCTS_DIR; };\n"
pbxproj_content += <<PBXPROJ
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
#{frameworks_phase} /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
#{main_group} = {
isa = PBXGroup;
children = (
#{bastion_group} /* Bastion */,
#{products_group} /* Products */,
);
sourceTree = "<group>";
};
#{bastion_group} /* Bastion */ = {
isa = PBXGroup;
children = (
PBXPROJ
# Add all file references to group
swift_files.each do |file|
filename = File.basename(file)
pbxproj_content += "\t\t\t\t#{file_refs[file]} /* #{filename} */,\n"
end
pbxproj_content += <<PBXPROJ
);
path = Bastion;
sourceTree = "<group>";
};
#{products_group} /* Products */ = {
isa = PBXGroup;
children = (
#{app_product} /* #{project_name}.app */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
#{target_uuid} /* #{project_name} */ = {
isa = PBXNativeTarget;
buildConfigurationList = #{config_list} /* Build configuration list for PBXNativeTarget "#{project_name}" */;
buildPhases = (
#{sources_phase} /* Sources */,
#{frameworks_phase} /* Frameworks */,
#{resources_phase} /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = #{project_name};
productName = #{project_name};
productReference = #{app_product} /* #{project_name}.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
#{project_uuid} /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1500;
LastUpgradeCheck = 1500;
};
buildConfigurationList = #{config_list} /* Build configuration list for PBXProject "#{project_name}" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = #{main_group};
productRefGroup = #{products_group} /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
#{target_uuid} /* #{project_name} */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
#{resources_phase} /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
#{sources_phase} /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
PBXPROJ
# Add all build file references
swift_files.each do |file|
filename = File.basename(file)
pbxproj_content += "\t\t\t\t#{build_files[file]} /* #{filename} in Sources */,\n"
end
pbxproj_content += <<PBXPROJ
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
#{debug_config} /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2025 Jordan Koch";
INFOPLIST_KEY_NSMainStoryboardFile = Main;
INFOPLIST_KEY_NSPrincipalClass = NSApplication;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.kochj.bastion;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
#{release_config} /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2025 Jordan Koch";
INFOPLIST_KEY_NSMainStoryboardFile = Main;
INFOPLIST_KEY_NSPrincipalClass = NSApplication;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.kochj.bastion;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
#{config_list} /* Build configuration list */ = {
isa = XCConfigurationList;
buildConfigurations = (
#{debug_config} /* Debug */,
#{release_config} /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = #{project_uuid} /* Project object */;
}
PBXPROJ
File.write(pbxproj_path, pbxproj_content)
puts "✓ Created #{pbxproj_path}"
puts "✓ Xcode project ready to open!"