@@ -10,7 +10,9 @@ import 'package:logging/logging.dart';
1010import 'package:native_toolchain_c/src/cbuilder/compiler_resolver.dart' ;
1111
1212const objCFlags = ['-x' , 'objective-c' , '-fobjc-arc' ];
13- const cFlags = < String > [];
13+
14+ String sdkPath = firstLineOfStdout ('xcrun' , ['--show-sdk-path' ]);
15+ final cFlags = < String > ['-isysroot' , sdkPath];
1416
1517const assetName = 'objective_c.dylib' ;
1618
@@ -106,8 +108,13 @@ class Builder {
106108 return output;
107109 }
108110
109- Future <void > linkLib (List <String > objects, String output) =>
110- _compile (['-shared' , '-undefined' , 'dynamic_lookup' , ...objects], output);
111+ Future <void > linkLib (List <String > objects, String output) => _compile ([
112+ '-shared' ,
113+ '-undefined' ,
114+ 'dynamic_lookup' ,
115+ ...cFlags,
116+ ...objects,
117+ ], output);
111118
112119 Future <void > _compile (List <String > flags, String output) async {
113120 final args = [...flags, '-o' , output];
@@ -122,3 +129,12 @@ class Builder {
122129 logger.info ('Generated $output ' );
123130 }
124131}
132+
133+ String firstLineOfStdout (String cmd, List <String > args) {
134+ final result = Process .runSync (cmd, args);
135+ assert (result.exitCode == 0 );
136+ return (result.stdout as String )
137+ .split ('\n ' )
138+ .where ((line) => line.isNotEmpty)
139+ .first;
140+ }
0 commit comments