How can I add multiple header files recursively in .modulemap? - clang

for example, this .modulemap works:
framework module MySDK {
umbrella header "MySDK-umbrella.h"
header "inc/header1.h"
header "inc/header2.h"
header "inc/header3.h"
...
export *
module * { export * }
}
but this one does not:
framework module MySDK {
umbrella header "MySDK-umbrella.h"
header "inc/*.h"
export *
module * { export * }
}
So how can I add multiple header files recursively in .modulemap?

I recommend investigating using umbrella "Headers" instead of umbrella header "MySDK-umbrella.h" for a case like this.
https://clang.llvm.org/docs/Modules.html#umbrella-directory-declaration

Related

Create NativeScript Plugin using IOS Static Library issue

I have created .a static library (tested in Xcode for native ios project and Its working fine)
Now I am following this https://github.com/NativeScript/nativescript-plugin-seed to create nativescript plugin using .a static framework.
Plugin structure
module.modulemap file is created by me and it's look like this
module libstaticlibrary {
umbrella header "staticlibrary.h"
export *
}
staticlibrary.h
#import <Foundation/Foundation.h>
#interface staticlibrary : NSObject
+ (NSString *)sayHello;
#end
libstaticlibrary.d.ts also created by me
declare class staticlibrary extends NSObject {
static sayHello():string;
}
Then in helloplugin.common.ts I am trying to access staticlibrary.sayHello() method.
export class Utils {
public static SUCCESS_MSG(): string {
// let msg = `Your plugin is working on ${app.android ? 'Android' : 'iOS'}.`;
let msg = staticlibrary.sayHello();
setTimeout(() => {
dialogs.alert(`${msg} For real. It's really working :)`).then(() => console.log(`Dialog closed.`));
}, 2000);
return msg;
}
I am getting following error.
node_modules/nativescript-helloplugin/helloplugin.common.ts(21,15): error TS2304: Cannot find name 'staticlibrary'.
What is I am doing wrong here?
It's just the TypeScript compiler error, you have to generate typings for your static library (refer docs to know how) or just add this line at top of your file.
declare var staticlibrary: any
I see that you do have a declaration file in your code snippet, if you want to use it you have to include it to your references.d.ts file.

Declaration of 'u_char' must be imported from module 'Darwin.POSIX.sys.types' before it is required

I imported "if_dl.h" in my Swift framework to use sockaddr_dl like this :
module net [system] [extern_c] {
module if_dl {
umbrella header
"/Applications/Xcode_7.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/net/if_dl.h"
module * {export *}
}
}
and now I am getting this error:
Declaration of 'u_char' must be imported from module
'Darwin.POSIX.sys.types' before it is required
I tried to add "import Darwin" in the class code but it's not resolving the problem.
I resolved the problem,
Module "types" have to be inside the module "net" and it have to be added before adding "if_dl"
module net [system] [extern_c] {
module types {
header "/usr/include/sys/types.h"
export *
}
module if_dl {
header
"/usr/include/net/if_dl.h"
export *
}
}

Xcode Framework: Umbrella header for module 'Test' does not include header 'NewTest.h'

framework module Test {
umbrella header "Test.h"
export *
module * { export * }
}
This is what my module file looks like. How can I resolve the following warning.
Umbrella header for module 'Test' does not include header 'NewTest.h'
I am not familiar with module files.
You should have a module map
modify the code to-
framework module Test {
umbrella header "Test.h"
export *
module * { export * }
explicit module BFAppLinkResolving {
header "BFAppLinkResolving.h"
link "BFAppLinkResolving"
export *
}
explicit module BFWebViewAppLinkResolver {
header "BFWebViewAppLinkResolver.h"
link "BFAWebViewAppLinkResolver"
export *
}
}

Xcode 6: can an iOS static library have a module map?

And then it could be linked and used from Objective-C with the
#import MyStaticLib;
syntax.
If so, how, exactly, do you do this.
You can create a static library with .modulemap file to use #import syntax
[Create Objective-C static library]
If you can edit the library Xcode project you can create a *.modulemap file and set it to the MODULEMAP_FILE Build Setting.
Sample map file from CocoaLumberjack:
framework module CocoaLumberjack {
umbrella header "CocoaLumberjack.h"
export *
module * { export * }
}
module CocoaLumberjack.DDContextFilterLogFormatter {
header "DDContextFilterLogFormatter.h"
export *
}
module CocoaLumberjack.DDDispatchQueueLogFormatter {
header "DDDispatchQueueLogFormatter.h"
export *
}
module CocoaLumberjack.DDMultiFormatter {
header "DDMultiFormatter.h"
export *
}
module CocoaLumberjack.DDASLLogCapture {
header "DDASLLogCapture.h"
export *
}
module CocoaLumberjack.DDAbstractDatabaseLogger {
header "DDAbstractDatabaseLogger.h"
export *
}
You can by creating a framework from this static library, you can follow all the instructions here
Once finished, you can import your static library like that:
#import MyStaticLib;

Dart library layout

I'm struggling with Dart library layout.
I tried the following
lib/
A.dart
B.dart
my_lib.dart
where:
A.dart
class A {
B myB;
}
B.dart
class A {
B myB;
}
my_lib.dart
#library('my_lib');
#source('A.dart');
#source('B.dart');
But in A.dart, in Dart Editor there is a problem: B - no such type.
If I import B.dart in that file, via
#import('B.dart)',
but now it claims that part of library can only contain part directive.
According to http://news.dartlang.org/2012/07/draft-spec-changes-to-library-and.html
partDirective:
metadata part stringLiteral “;”
;
But that doesn't work for me either.
What am I missing?
Download the latest SDK and try:
a.dart
class A {
B myB;
}
b.dart
class B {
}
lib.dart
library mylib;
part 'a.dart';
part 'b.dart';
That should work.
Due to new release changes the layout has to look like the followed example:
a.dart
part of mylib;
class A {
B myB;
}
b.dart
part of mylib;
class B {
}
lib.dart
library mylib;
part 'a.dart';
part 'b.dart';

Resources