Skip to content

Commit baca2a5

Browse files
committed
use of mix library in another library
1 parent 186028a commit baca2a5

File tree

7 files changed

+333
-0
lines changed

7 files changed

+333
-0
lines changed

.DS_Store

2 KB
Binary file not shown.

MixLibraryTwo/MixLibraryTwo.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,26 @@
66
// Copyright © 2019 Ashis Laha. All rights reserved.
77
//
88

9+
10+
/*
11+
import MixLibraryOne - access objective c files through module.modulemap
12+
13+
import swiftmodule - to access swift classes x86_64.swiftmodule
14+
15+
both swiftmodule and module.modulemap must refer PRODUCT_MODULE_NAME which is used to import in other static library
16+
*/
917
import MixLibraryOne
1018

1119
class MixLibraryTwo {
1220

1321
public func test() {
22+
23+
// access objective c files
1424
let obj = MixLibOneObjcFileA()
1525
obj.test()
26+
27+
// access swift class
28+
let obj2 = MixLibOneSwiftOne()
29+
obj2.test()
1630
}
1731
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// MixLibraryTwoObjCFileA.h
3+
// PlayWithLibraries
4+
//
5+
// Created by Ashis Laha on 29/12/19.
6+
// Copyright © 2019 Ashis Laha. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@interface MixLibraryTwoObjCFileA : NSObject
14+
15+
@end
16+
17+
NS_ASSUME_NONNULL_END
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// MixLibraryTwoObjCFileA.m
3+
// PlayWithLibraries
4+
//
5+
// Created by Ashis Laha on 29/12/19.
6+
// Copyright © 2019 Ashis Laha. All rights reserved.
7+
//
8+
9+
#import "MixLibraryTwoObjCFileA.h"
10+
11+
/*
12+
import MixLibraryOne - access objective c files through module.modulemap
13+
*/
14+
@import MixLibraryOne;
15+
16+
/*
17+
import objective c header file - access swift classes
18+
*/
19+
#import "MixLibOne-Swift.h"
20+
21+
@implementation MixLibraryTwoObjCFileA
22+
23+
-(void) testInMixLibraryTwo {
24+
25+
// use of objective c classes
26+
MixLibOneObjcFileA *obj = [[MixLibOneObjcFileA alloc] init];
27+
[obj test];
28+
29+
// use of swift classes
30+
MixLibOneSwiftOne *obj2 = [[MixLibOneSwiftOne alloc] init];
31+
[obj2 test];
32+
}
33+
34+
@end

PlayWithLibraries.xcodeproj/project.pbxproj

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
555EA19523A52958003227E8 /* SwiftLibraryFour.swift in Sources */ = {isa = PBXBuildFile; fileRef = 555EA19423A52958003227E8 /* SwiftLibraryFour.swift */; };
3131
555EA1A423A52CE5003227E8 /* ObjCLibraryFour.m in Sources */ = {isa = PBXBuildFile; fileRef = 555EA1A323A52CE5003227E8 /* ObjCLibraryFour.m */; };
3232
555EA1A523A52CE5003227E8 /* ObjCLibraryFour.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 555EA1A223A52CE5003227E8 /* ObjCLibraryFour.h */; };
33+
5586F3F023B8ED9000AFD5E4 /* MixLibraryTwoObjCFileA.m in Sources */ = {isa = PBXBuildFile; fileRef = 5586F3EF23B8ED9000AFD5E4 /* MixLibraryTwoObjCFileA.m */; };
34+
5586F3F123B8ED9000AFD5E4 /* MixLibraryTwoObjCFileA.m in Sources */ = {isa = PBXBuildFile; fileRef = 5586F3EF23B8ED9000AFD5E4 /* MixLibraryTwoObjCFileA.m */; };
3335
558AC0CF23ACA4C0005FD5B7 /* MixLibOneObjcFileA.m in Sources */ = {isa = PBXBuildFile; fileRef = 558AC0CE23ACA4C0005FD5B7 /* MixLibOneObjcFileA.m */; };
3436
558AC0D323ACACB4005FD5B7 /* MixLibOneObjcFileA.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 558AC0CD23ACA4C0005FD5B7 /* MixLibOneObjcFileA.h */; };
3537
55929AF123AF9E210043C6A9 /* MixLibraryTwo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55929AF023AF9E210043C6A9 /* MixLibraryTwo.swift */; };
@@ -224,6 +226,8 @@
224226
555EA1A023A52CE5003227E8 /* libObjCLibraryFour.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libObjCLibraryFour.a; sourceTree = BUILT_PRODUCTS_DIR; };
225227
555EA1A223A52CE5003227E8 /* ObjCLibraryFour.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ObjCLibraryFour.h; sourceTree = "<group>"; };
226228
555EA1A323A52CE5003227E8 /* ObjCLibraryFour.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ObjCLibraryFour.m; sourceTree = "<group>"; };
229+
5586F3EE23B8ED9000AFD5E4 /* MixLibraryTwoObjCFileA.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MixLibraryTwoObjCFileA.h; sourceTree = "<group>"; };
230+
5586F3EF23B8ED9000AFD5E4 /* MixLibraryTwoObjCFileA.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MixLibraryTwoObjCFileA.m; sourceTree = "<group>"; };
227231
558AC0C023AC6142005FD5B7 /* libMixLibraryOne.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMixLibraryOne.a; sourceTree = BUILT_PRODUCTS_DIR; };
228232
558AC0CA23AC7D19005FD5B7 /* MixLibOne.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = MixLibOne.xcconfig; sourceTree = "<group>"; };
229233
558AC0CB23AC7DA8005FD5B7 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
@@ -463,6 +467,8 @@
463467
isa = PBXGroup;
464468
children = (
465469
55929AF023AF9E210043C6A9 /* MixLibraryTwo.swift */,
470+
5586F3EE23B8ED9000AFD5E4 /* MixLibraryTwoObjCFileA.h */,
471+
5586F3EF23B8ED9000AFD5E4 /* MixLibraryTwoObjCFileA.m */,
466472
);
467473
path = MixLibraryTwo;
468474
sourceTree = "<group>";
@@ -642,6 +648,7 @@
642648
558AC0BE23AC6142005FD5B7 /* CopyFiles */,
643649
558AC0BC23AC6142005FD5B7 /* Sources */,
644650
558AC0BD23AC6142005FD5B7 /* Frameworks */,
651+
5586F3F223B8FA1D00AFD5E4 /* ShellScript */,
645652
);
646653
buildRules = (
647654
);
@@ -743,12 +750,14 @@
743750
};
744751
55929AED23AF9E210043C6A9 = {
745752
CreatedOnToolsVersion = 11.3;
753+
LastSwiftMigration = 1130;
746754
};
747755
55929AF823B055840043C6A9 = {
748756
CreatedOnToolsVersion = 11.3;
749757
};
750758
559724A8239E8BD400688A06 = {
751759
CreatedOnToolsVersion = 11.2.1;
760+
LastSwiftMigration = 1130;
752761
};
753762
};
754763
};
@@ -845,6 +854,23 @@
845854
shellPath = /bin/sh;
846855
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n# target directory is Project root directory\ntarget_dir=${SRCROOT}/include/\n\n# Ensure the target include path exists\nmkdir -p ${target_dir}\n\n# Copy any file that looks like a Swift generated header to the include path\ncp ${DERIVED_SOURCES_DIR}/*-Swift.h ${target_dir}\n";
847856
};
857+
5586F3F223B8FA1D00AFD5E4 /* ShellScript */ = {
858+
isa = PBXShellScriptBuildPhase;
859+
buildActionMask = 2147483647;
860+
files = (
861+
);
862+
inputFileListPaths = (
863+
);
864+
inputPaths = (
865+
);
866+
outputFileListPaths = (
867+
);
868+
outputPaths = (
869+
);
870+
runOnlyForDeploymentPostprocessing = 0;
871+
shellPath = /bin/sh;
872+
shellScript = "# target directory is Project root directory\ntarget_dir=${SRCROOT}/include/\n\n# Ensure the target include path exists\nmkdir -p ${target_dir}\n\n# Copy any file that looks like a Swift generated header to the include path\ncp ${DERIVED_SOURCES_DIR}/*-Swift.h ${target_dir}\n";
873+
};
848874
559724B5239E8F1700688A06 /* ShellScript */ = {
849875
isa = PBXShellScriptBuildPhase;
850876
buildActionMask = 2147483647;
@@ -940,6 +966,7 @@
940966
buildActionMask = 2147483647;
941967
files = (
942968
55929AF123AF9E210043C6A9 /* MixLibraryTwo.swift in Sources */,
969+
5586F3F123B8ED9000AFD5E4 /* MixLibraryTwoObjCFileA.m in Sources */,
943970
);
944971
runOnlyForDeploymentPostprocessing = 0;
945972
};
@@ -956,6 +983,7 @@
956983
buildActionMask = 2147483647;
957984
files = (
958985
559724B1239E8C1300688A06 /* SwiftStaticLibraryTwoFileA.swift in Sources */,
986+
5586F3F023B8ED9000AFD5E4 /* MixLibraryTwoObjCFileA.m in Sources */,
959987
);
960988
runOnlyForDeploymentPostprocessing = 0;
961989
};
@@ -1396,10 +1424,18 @@
13961424
55929AF223AF9E210043C6A9 /* Debug */ = {
13971425
isa = XCBuildConfiguration;
13981426
buildSettings = {
1427+
CLANG_ENABLE_MODULES = YES;
13991428
CODE_SIGN_STYLE = Automatic;
1429+
HEADER_SEARCH_PATHS = "${SRCROOT}/include/";
1430+
LD_RUNPATH_SEARCH_PATHS = (
1431+
"$(inherited)",
1432+
"@executable_path/Frameworks",
1433+
"@loader_path/Frameworks",
1434+
);
14001435
OTHER_LDFLAGS = "-ObjC";
14011436
PRODUCT_NAME = "$(TARGET_NAME)";
14021437
SKIP_INSTALL = YES;
1438+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
14031439
SWIFT_VERSION = 5.0;
14041440
TARGETED_DEVICE_FAMILY = "1,2";
14051441
USER_HEADER_SEARCH_PATHS = (
@@ -1412,7 +1448,14 @@
14121448
55929AF323AF9E210043C6A9 /* Release */ = {
14131449
isa = XCBuildConfiguration;
14141450
buildSettings = {
1451+
CLANG_ENABLE_MODULES = YES;
14151452
CODE_SIGN_STYLE = Automatic;
1453+
HEADER_SEARCH_PATHS = "${SRCROOT}/include/";
1454+
LD_RUNPATH_SEARCH_PATHS = (
1455+
"$(inherited)",
1456+
"@executable_path/Frameworks",
1457+
"@loader_path/Frameworks",
1458+
);
14161459
OTHER_LDFLAGS = "-ObjC";
14171460
PRODUCT_NAME = "$(TARGET_NAME)";
14181461
SKIP_INSTALL = YES;
@@ -1458,12 +1501,19 @@
14581501
559724AD239E8BD400688A06 /* Debug */ = {
14591502
isa = XCBuildConfiguration;
14601503
buildSettings = {
1504+
CLANG_ENABLE_MODULES = YES;
14611505
CODE_SIGN_STYLE = Automatic;
14621506
DEFINES_MODULE = NO;
14631507
HEADER_SEARCH_PATHS = "";
1508+
LD_RUNPATH_SEARCH_PATHS = (
1509+
"$(inherited)",
1510+
"@executable_path/Frameworks",
1511+
"@loader_path/Frameworks",
1512+
);
14641513
OTHER_LDFLAGS = "-ObjC";
14651514
PRODUCT_NAME = "$(TARGET_NAME)";
14661515
SKIP_INSTALL = YES;
1516+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
14671517
SWIFT_VERSION = 5.0;
14681518
TARGETED_DEVICE_FAMILY = "1,2";
14691519
};
@@ -1472,9 +1522,15 @@
14721522
559724AE239E8BD400688A06 /* Release */ = {
14731523
isa = XCBuildConfiguration;
14741524
buildSettings = {
1525+
CLANG_ENABLE_MODULES = YES;
14751526
CODE_SIGN_STYLE = Automatic;
14761527
DEFINES_MODULE = NO;
14771528
HEADER_SEARCH_PATHS = "";
1529+
LD_RUNPATH_SEARCH_PATHS = (
1530+
"$(inherited)",
1531+
"@executable_path/Frameworks",
1532+
"@loader_path/Frameworks",
1533+
);
14781534
OTHER_LDFLAGS = "-ObjC";
14791535
PRODUCT_NAME = "$(TARGET_NAME)";
14801536
SKIP_INSTALL = YES;

0 commit comments

Comments
 (0)