使用modulemap文件构建框架项目时,如何修复“未找到标头'Home.h'”

时间:2019-01-16 15:11:26

标签: objective-c swift frameworks module-map

我想创建一个包含swift(主要)和objc(可能是已编译框架)文件的swift框架。因此,我创建了一个'...'。modulemap文件并添加了自定义模块。最后,我没有找到标题错误。

我在xcode构建设置中添加了Modulemap文件:Module Map File参数。

详细错误:

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/user/Desktop/test/TestModule/TestModule/PublicFile.swift -emit-module-path /Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/Objects-normal/x86_64/PublicFile~partial.swiftmodule -emit-module-doc-path /Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/Objects-normal/x86_64/PublicFile~partial.swiftdoc -serialize-diagnostics-path /Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/Objects-normal/x86_64/PublicFile.dia -emit-dependencies-path /Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/Objects-normal/x86_64/PublicFile.d -emit-reference-dependencies-path /Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/Objects-normal/x86_64/PublicFile.swiftdeps -target x86_64-apple-ios12.1-simulator -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk -I /Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Products/Debug-iphonesimulator -F /Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Products/Debug-iphonesimulator -enable-testing -g -import-underlying-module -module-cache-path /Users/user/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -I/Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/TestModule-generated-files.hmap -Xcc -I/Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/TestModule-own-target-headers.hmap -Xcc -I/Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/TestModule-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/TestModule-project-headers.hmap -Xcc -I/Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/DerivedSources/x86_64 -Xcc -I/Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -ivfsoverlay -Xcc /Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/user/Desktop/test/TestModule -parse-as-library -module-name TestModule -o /Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/Objects-normal/x86_64/PublicFile.o -index-store-path /Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Index/DataStore -index-system-modules

CompileSwift normal x86_64 /Users/user/Desktop/test/TestModule/TestModule/PublicFile.swift (in target: TestModule)
    cd /Users/user/Desktop/test/TestModule
/Users/user/Library/Developer/Xcode/DerivedData/TestModule-aqjiakhajkrsfgdhavhwzktapigp/Build/Intermediates.noindex/TestModule.build/Debug-iphonesimulator/TestModule.build/unextended-module.modulemap:5:16: error: header 'Home.h' not found
        header "Home.h"
               ^
<unknown>:0: error: could not build Objective-C module 'TestModule'

查看代码:

TestModule.modulemap

framework module TestModule {
    umbrella header "TestModule.h"

    module Home {
        header "Home.h"
        export *
    }

    export *
    module * { export * }
}

Home.h

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface Home : NSObject

- (void)sweet;

@end

NS_ASSUME_NONNULL_END

Home.m

#import "Home.h"

@implementation Home

- (void)sweet {
    NSLog(@"Home sweet home");
}

@end

PublicFile.swift

import Foundation
import Home

//Yes only import

TestModule.h

#import <UIKit/UIKit.h>

//! Project version number for TestModule.
FOUNDATION_EXPORT double TestModuleVersionNumber;

//! Project version string for TestModule.
FOUNDATION_EXPORT const unsigned char TestModuleVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <TestModule/PublicHeader.h>

所有文件都具有相同的级别路径:TestModule文件夹

0 个答案:

没有答案