浏览代码

add bridging header and simple c example

Jonas Reinsch 7 年之前
父节点
当前提交
6ab90a2984

+ 14 - 0
deltachat-ios.xcodeproj/project.pbxproj

@@ -11,6 +11,7 @@
 		7A9FB1461FB061E2001FEA36 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9FB1451FB061E2001FEA36 /* ViewController.swift */; };
 		7A9FB14B1FB061E2001FEA36 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7A9FB14A1FB061E2001FEA36 /* Assets.xcassets */; };
 		7A9FB14E1FB061E2001FEA36 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7A9FB14C1FB061E2001FEA36 /* LaunchScreen.storyboard */; };
+		7A9FB1591FB06540001FEA36 /* test.c in Sources */ = {isa = PBXBuildFile; fileRef = 7A9FB1571FB06540001FEA36 /* test.c */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
@@ -20,6 +21,9 @@
 		7A9FB14A1FB061E2001FEA36 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
 		7A9FB14D1FB061E2001FEA36 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
 		7A9FB14F1FB061E2001FEA36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+		7A9FB1561FB06540001FEA36 /* deltachat-ios-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "deltachat-ios-Bridging-Header.h"; sourceTree = "<group>"; };
+		7A9FB1571FB06540001FEA36 /* test.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = test.c; sourceTree = "<group>"; };
+		7A9FB1581FB06540001FEA36 /* test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = test.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -53,10 +57,13 @@
 			isa = PBXGroup;
 			children = (
 				7A9FB1431FB061E2001FEA36 /* AppDelegate.swift */,
+				7A9FB1571FB06540001FEA36 /* test.c */,
+				7A9FB1581FB06540001FEA36 /* test.h */,
 				7A9FB1451FB061E2001FEA36 /* ViewController.swift */,
 				7A9FB14A1FB061E2001FEA36 /* Assets.xcassets */,
 				7A9FB14C1FB061E2001FEA36 /* LaunchScreen.storyboard */,
 				7A9FB14F1FB061E2001FEA36 /* Info.plist */,
+				7A9FB1561FB06540001FEA36 /* deltachat-ios-Bridging-Header.h */,
 			);
 			path = "deltachat-ios";
 			sourceTree = "<group>";
@@ -93,6 +100,7 @@
 				TargetAttributes = {
 					7A9FB13F1FB061E2001FEA36 = {
 						CreatedOnToolsVersion = 9.1;
+						LastSwiftMigration = 0910;
 						ProvisioningStyle = Automatic;
 					};
 				};
@@ -132,6 +140,7 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				7A9FB1591FB06540001FEA36 /* test.c in Sources */,
 				7A9FB1461FB061E2001FEA36 /* ViewController.swift in Sources */,
 				7A9FB1441FB061E2001FEA36 /* AppDelegate.swift in Sources */,
 			);
@@ -262,12 +271,15 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_STYLE = Automatic;
 				DEVELOPMENT_TEAM = S595XJ38G3;
 				INFOPLIST_FILE = "deltachat-ios/Info.plist";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = "com.jonasreinsch.deltachat-ios";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				SWIFT_OBJC_BRIDGING_HEADER = "deltachat-ios/deltachat-ios-Bridging-Header.h";
+				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
 				SWIFT_VERSION = 4.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 			};
@@ -277,12 +289,14 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_STYLE = Automatic;
 				DEVELOPMENT_TEAM = S595XJ38G3;
 				INFOPLIST_FILE = "deltachat-ios/Info.plist";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = "com.jonasreinsch.deltachat-ios";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				SWIFT_OBJC_BRIDGING_HEADER = "deltachat-ios/deltachat-ios-Bridging-Header.h";
 				SWIFT_VERSION = 4.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 			};

+ 3 - 0
deltachat-ios/AppDelegate.swift

@@ -24,6 +24,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
         window.rootViewController = ViewController()
         window.makeKeyAndVisible()
         window.backgroundColor = UIColor.white
+        
+        hello()
+        
         return true
     }
 

+ 5 - 0
deltachat-ios/deltachat-ios-Bridging-Header.h

@@ -0,0 +1,5 @@
+//
+//  Use this file to import your target's public headers that you would like to expose to Swift.
+//
+
+#include "test.h"

+ 13 - 0
deltachat-ios/test.c

@@ -0,0 +1,13 @@
+//
+//  test.c
+//  deltachat-ios
+//
+//  Created by Jonas Reinsch on 06.11.17.
+//  Copyright © 2017 Jonas Reinsch. All rights reserved.
+//
+
+#include "test.h"
+
+void hello() {
+    printf("Hello World\n");
+}

+ 16 - 0
deltachat-ios/test.h

@@ -0,0 +1,16 @@
+//
+//  test.h
+//  deltachat-ios
+//
+//  Created by Jonas Reinsch on 06.11.17.
+//  Copyright © 2017 Jonas Reinsch. All rights reserved.
+//
+
+#ifndef test_h
+#define test_h
+
+#include <stdio.h>
+
+void hello(void);
+
+#endif /* test_h */