3

G'day,

This is really killing me my framework project builds without error or warning in the debug configuration, but when I try to build for archive it fails because the <Module>-Swift.h is not found. Apparently it's not being generated in this configuration.

Sometimes when this happens (in Debug) I can delete the references to the swift header, build then put back then rebuild to fix it. This does not help when building for Release.

All the swift related build settings are the same for Debug as for Release.

Here is an example of an error from the build log, note that the file LBImageView.swift does not import anything except Foundation. It make no reference to the DRHExperimentData class:

CompileSwift normal x86_64 /Users/l.walsh/Documents/Developer/LabBot/LBImageView.swift
cd /Users/l.walsh/Documents/Developer/LabBot
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/l.walsh/Documents/Developer/LabBot/LBImageView.swift /Users/l.walsh/Documents/Developer/LabBot/LBSize.swift /Users/l.walsh/Documents/Developer/LabBot/LBDataMatrix.swift /Users/l.walsh/Documents/Developer/LabBot/LBCalibratedPair.swift /Users/l.walsh/Documents/Developer/LabBot/LBExtensions.swift /Users/l.walsh/Documents/Developer/LabBot/LBExperimentDelegate.swift /Users/l.walsh/Documents/Developer/LabBot/LBGridView.swift /Users/l.walsh/Documents/Developer/LabBot/LBPoint.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -I /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/BuildProductsPath/Release -F /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/BuildProductsPath/Release -g -import-underlying-module -module-cache-path /Users/l.walsh/Library/Developer/Xcode/DerivedData/ModuleCache -serialize-debugging-options -Xcc -I/Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/LabBot-generated-files.hmap -Xcc -I/Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/LabBot-own-target-headers.hmap -Xcc -I/Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/LabBot-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/LabBot-project-headers.hmap -Xcc -I/Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/BuildProductsPath/Release/include -Xcc -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Xcc -I/Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/DerivedSources/x86_64 -Xcc -I/Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/DerivedSources -Xcc -ivfsoverlay -Xcc /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/l.walsh/Documents/Developer/LabBot -emit-module-doc-path /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/Objects-normal/x86_64/LBImageView~partial.swiftdoc -O -module-name LabBot -emit-module-path /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/Objects-normal/x86_64/LBImageView~partial.swiftmodule -serialize-diagnostics-path /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/Objects-normal/x86_64/LBImageView.dia -emit-dependencies-path /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/Objects-normal/x86_64/LBImageView.d -emit-reference-dependencies-path /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/Objects-normal/x86_64/LBImageView.swiftdeps -o /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/Objects-normal/x86_64/LBImageView.o

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/l.walsh/Documents/Developer/LabBot/LabBot.h"
    ^
/Users/l.walsh/Documents/Developer/LabBot/LabBot.h:16:9: note: in file included from /Users/l.walsh/Documents/Developer/LabBot/LabBot.h:16:
#import "DRHExperimentData.h"
    ^
/Users/l.walsh/Documents/Developer/LabBot/DRHExperimentData.h:12:9: error: 'LabBot/LabBot-Swift.h' file not found
#import <LabBot/LabBot-Swift.h>
    ^
<unknown>:0: error: could not build Objective-C module 'LabBot'

Has anyone experienced this and solved it? Does anyone have any ideas?

Thanks for any help on this, Lee.

Tangler
  • 168
  • 9
  • Verify your "Header Path" in Build Setting, for Debug mode – Duyen-Hoa Jun 01 '15 at 09:18
  • @HoaParis I'm not sure exactly which setting you are referring to. There is no setting call "Header Path". All the various paths including search paths and interface paths look correct and are the same for Debug and Release settings. – Tangler Jun 03 '15 at 05:33
  • I mean "Header Search Paths" in "Build Settings" for your application, in XCode. – Duyen-Hoa Jun 03 '15 at 08:12
  • @HoaParis Thanks, but as I said the various search paths all seem fine and are the same for both Debug and Release modes. Also if it makes a difference, it's not an application it's a framework, as stated in the OP. – Tangler Jun 04 '15 at 00:20
  • I faced the same problem suddenly. Then I had to build the framework in release mode first before building the main target. It solved the problem. – Raunak Apr 27 '19 at 14:23

1 Answers1

1

So it turns out that you can't #import Swift module headers into obj-c .h files, you must put them in the .m files. Thus I removed #import <LabBot/LabBot-Swift.h> from class.h and put it in the .m file. Problem solved.

Note, you will need an @class statement in your .h file if your interface refers to a class that is defined in the Swift module that you want to import.

Unfortunately, for some reason XCode let me get away importing module headers into .h files when building for Debug. It only spat the dummy when building for Release. Furthermore, XCode does not throw an error related to the offending obj-c class, it throws errors relating to classes that are part of the Swift module being included.

Maybe there is a build setting that stops letting Debug allow this (or lets Release allow it), but I could not find it.

Tangler
  • 168
  • 9
  • thank you so much. Your answer help me to find out what was causing this issue. It took me a lot of time to find a solution which works correctly. – IMACODE Mar 18 '19 at 09:10