@@ -270,25 +270,6 @@ func xcodeProject(
270
270
// Add framework search path to build settings.
271
271
targetSettings. common. FRAMEWORK_SEARCH_PATHS = [ " $(PLATFORM_DIR)/Developer/Library/Frameworks " ]
272
272
273
- // Generate a module map for ClangModule (if not provided by user) and
274
- // add to the build settings.
275
- if case let clangModule as ClangModule = module, clangModule. type == . library {
276
- targetSettings. common. DEFINES_MODULE = " YES "
277
- let moduleMapPath : AbsolutePath
278
- // If user provided the modulemap no need to generate.
279
- if fileSystem. isFile ( clangModule. moduleMapPath) {
280
- moduleMapPath = clangModule. moduleMapPath
281
- } else {
282
- // Generate and drop the modulemap inside Xcodeproj folder.
283
- let path = xcodeprojPath. appending ( components: " GeneratedModuleMap " , clangModule. c99name)
284
- var moduleMapGenerator = ModuleMapGenerator ( for: clangModule, fileSystem: fileSystem)
285
- try moduleMapGenerator. generateModuleMap ( inDir: path)
286
- moduleMapPath = path. appending ( component: moduleMapFilename)
287
- }
288
-
289
- targetSettings. common. MODULEMAP_FILE = moduleMapPath. relative ( to: xcodeprojPath. parentDirectory) . asString
290
- }
291
-
292
273
// At the moment, set the Swift version to 3 (we will need to make this dynamic), but for now this is necessary.
293
274
targetSettings. common. SWIFT_VERSION = " 3.0 "
294
275
@@ -353,12 +334,29 @@ func xcodeProject(
353
334
// Add the `include` group for a libary C language target.
354
335
if case let clangModule as ClangModule = module, clangModule. type == . library, fileSystem. isDirectory ( clangModule. includeDir) {
355
336
let includeDir = clangModule. includeDir
356
- _ = makeGroup ( for: includeDir)
337
+ let includeGroup = makeGroup ( for: includeDir)
357
338
// FIXME: Support C++ headers.
358
339
for header in try walk ( includeDir, fileSystem: fileSystem) where header. extension == " h " {
359
340
let group = makeGroup ( for: header. parentDirectory)
360
341
group. addFileReference ( path: header. basename)
361
342
}
343
+
344
+ // Generate a module map for ClangModule (if not provided by user) and
345
+ // add to the build settings.
346
+ targetSettings. common. DEFINES_MODULE = " YES "
347
+ let moduleMapPath : AbsolutePath
348
+ // If user provided the modulemap no need to generate.
349
+ if fileSystem. isFile ( clangModule. moduleMapPath) {
350
+ moduleMapPath = clangModule. moduleMapPath
351
+ } else {
352
+ // Generate and drop the modulemap inside Xcodeproj folder.
353
+ let path = xcodeprojPath. appending ( components: " GeneratedModuleMap " , clangModule. c99name)
354
+ var moduleMapGenerator = ModuleMapGenerator ( for: clangModule, fileSystem: fileSystem)
355
+ try moduleMapGenerator. generateModuleMap ( inDir: path)
356
+ moduleMapPath = path. appending ( component: moduleMapFilename)
357
+ }
358
+ includeGroup. addFileReference ( path: moduleMapPath. asString, name: moduleMapPath. basename)
359
+ targetSettings. common. MODULEMAP_FILE = moduleMapPath. relative ( to: xcodeprojPath. parentDirectory) . asString
362
360
}
363
361
}
364
362
0 commit comments