@@ -18,6 +18,17 @@ import * as mobileprovision from "ios-mobileprovision-finder";
18
18
import { SpawnOptions } from "child_process" ;
19
19
import { BUILD_XCCONFIG_FILE_NAME } from "../constants" ;
20
20
21
+ interface INativeSourceCodeDescription {
22
+ path : string ;
23
+ name : string ;
24
+ }
25
+
26
+ interface INativeSourceCodeGroup {
27
+ name : string ;
28
+ path : string ;
29
+ files : INativeSourceCodeDescription [ ] ;
30
+ }
31
+
21
32
export class IOSProjectService extends projectServiceBaseLib . PlatformProjectServiceBase implements IPlatformProjectService {
22
33
private static XCODE_PROJECT_EXT_NAME = ".xcodeproj" ;
23
34
private static XCODE_SCHEME_EXT_NAME = ".xcscheme" ;
@@ -924,6 +935,11 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
924
935
public async preparePluginNativeCode ( pluginData : IPluginData , projectData : IProjectData , opts ?: any ) : Promise < void > {
925
936
const pluginPlatformsFolderPath = pluginData . pluginPlatformsFolderPath ( IOSProjectService . IOS_PLATFORM_NAME ) ;
926
937
938
+ const sourcePath = path . join ( pluginPlatformsFolderPath , "src" ) ;
939
+ if ( this . $fs . exists ( pluginPlatformsFolderPath ) && this . $fs . exists ( sourcePath ) ) {
940
+ await this . prepareNativeSourceCode ( pluginData . name , sourcePath , projectData ) ;
941
+ }
942
+
927
943
await this . prepareFrameworks ( pluginPlatformsFolderPath , pluginData , projectData ) ;
928
944
await this . prepareStaticLibs ( pluginPlatformsFolderPath , pluginData , projectData ) ;
929
945
await this . prepareCocoapods ( pluginPlatformsFolderPath , projectData ) ;
@@ -1103,6 +1119,30 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
1103
1119
return childProcess ;
1104
1120
}
1105
1121
1122
+ private async prepareNativeSourceCode ( pluginName : string , pluginPlatformsFolderPath : string , projectData : IProjectData ) : Promise < void > {
1123
+
1124
+ const project = this . createPbxProj ( projectData ) ;
1125
+ const group = this . getRootGroup ( pluginName , pluginPlatformsFolderPath ) ;
1126
+ project . addPbxGroup ( group . files . map ( f => f . path ) , group . name , group . path , null , { isMain :true } ) ;
1127
+ project . addToHeaderSearchPaths ( group . path ) ;
1128
+ this . savePbxProj ( project , projectData ) ;
1129
+ }
1130
+
1131
+ private getRootGroup ( name : string , rootPath : string ) {
1132
+ const filesArr : INativeSourceCodeDescription [ ] = [ ] ;
1133
+ const rootGroup : INativeSourceCodeGroup = { name : name , files : filesArr , path : rootPath } ;
1134
+
1135
+ if ( this . $fs . exists ( rootPath ) && ! this . $fs . isEmptyDir ( rootPath ) ) {
1136
+ this . $fs . readDirectory ( rootPath ) . forEach ( fileName => {
1137
+ const filePath = path . join ( rootGroup . path , fileName ) ;
1138
+ const file : INativeSourceCodeDescription = { name : fileName , path : filePath } ;
1139
+ filesArr . push ( file ) ;
1140
+ } ) ;
1141
+ }
1142
+
1143
+ return rootGroup ;
1144
+ }
1145
+
1106
1146
private async prepareFrameworks ( pluginPlatformsFolderPath : string , pluginData : IPluginData , projectData : IProjectData ) : Promise < void > {
1107
1147
for ( const fileName of this . getAllLibsForPluginWithFileExtension ( pluginData , ".framework" ) ) {
1108
1148
await this . addFramework ( path . join ( pluginPlatformsFolderPath , fileName ) , projectData ) ;
0 commit comments