From de9d44d3397adacf66800fe4698afb5057656b93 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 5 Jan 2018 16:03:41 -0800 Subject: Add example to use gRPC-C++ pod in an iOS application --- .../HelloWorldCpp.xcodeproj/project.pbxproj | 409 +++++++++++++++++++++ .../cocoapods/HelloWorldCpp/AppDelegate.h | 17 + .../cocoapods/HelloWorldCpp/AppDelegate.mm | 51 +++ .../AppIcon.appiconset/Contents.json | 93 +++++ .../Base.lproj/LaunchScreen.storyboard | 25 ++ .../HelloWorldCpp/Base.lproj/Main.storyboard | 24 ++ .../helloworld/cocoapods/HelloWorldCpp/Info.plist | 45 +++ .../cocoapods/HelloWorldCpp/ViewController.h | 15 + .../cocoapods/HelloWorldCpp/ViewController.mm | 97 +++++ .../cpp/helloworld/cocoapods/HelloWorldCpp/main.m | 16 + examples/cpp/helloworld/cocoapods/Podfile | 10 + 11 files changed, 802 insertions(+) create mode 100644 examples/cpp/helloworld/cocoapods/HelloWorldCpp.xcodeproj/project.pbxproj create mode 100644 examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.h create mode 100644 examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.mm create mode 100644 examples/cpp/helloworld/cocoapods/HelloWorldCpp/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/LaunchScreen.storyboard create mode 100644 examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/Main.storyboard create mode 100644 examples/cpp/helloworld/cocoapods/HelloWorldCpp/Info.plist create mode 100644 examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.h create mode 100644 examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.mm create mode 100644 examples/cpp/helloworld/cocoapods/HelloWorldCpp/main.m create mode 100644 examples/cpp/helloworld/cocoapods/Podfile (limited to 'examples/cpp') diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp.xcodeproj/project.pbxproj b/examples/cpp/helloworld/cocoapods/HelloWorldCpp.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..b722b80400 --- /dev/null +++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp.xcodeproj/project.pbxproj @@ -0,0 +1,409 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + 3DC71E95B8670DC619CF8693 /* libPods-HelloWorldCpp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E3077D82811A6434769B437 /* libPods-HelloWorldCpp.a */; }; + 5E9D65611FFD689B00C955D4 /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E9D65601FFD689B00C955D4 /* AppDelegate.mm */; }; + 5E9D65641FFD689B00C955D4 /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E9D65631FFD689B00C955D4 /* ViewController.mm */; }; + 5E9D65671FFD689B00C955D4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5E9D65651FFD689B00C955D4 /* Main.storyboard */; }; + 5E9D65691FFD689B00C955D4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5E9D65681FFD689B00C955D4 /* Assets.xcassets */; }; + 5E9D656C1FFD689B00C955D4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5E9D656A1FFD689B00C955D4 /* LaunchScreen.storyboard */; }; + 5E9D656F1FFD689C00C955D4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E9D656E1FFD689C00C955D4 /* main.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0A6137606FDBA874FCF64753 /* Pods-HelloWorldCpp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorldCpp.release.xcconfig"; path = "Pods/Target Support Files/Pods-HelloWorldCpp/Pods-HelloWorldCpp.release.xcconfig"; sourceTree = ""; }; + 5E9D655C1FFD689B00C955D4 /* HelloWorldCpp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloWorldCpp.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 5E9D655F1FFD689B00C955D4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 5E9D65601FFD689B00C955D4 /* AppDelegate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate.mm; sourceTree = ""; }; + 5E9D65621FFD689B00C955D4 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 5E9D65631FFD689B00C955D4 /* ViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewController.mm; sourceTree = ""; }; + 5E9D65661FFD689B00C955D4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 5E9D65681FFD689B00C955D4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 5E9D656B1FFD689B00C955D4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 5E9D656D1FFD689C00C955D4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 5E9D656E1FFD689C00C955D4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 8E3077D82811A6434769B437 /* libPods-HelloWorldCpp.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HelloWorldCpp.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + AF0FF6EB66DA2C30CFC575EA /* Pods-HelloWorldCpp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorldCpp.debug.xcconfig"; path = "Pods/Target Support Files/Pods-HelloWorldCpp/Pods-HelloWorldCpp.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 5E9D65591FFD689B00C955D4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 3DC71E95B8670DC619CF8693 /* libPods-HelloWorldCpp.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 08FBFA5AB49E037A86EA64D7 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 8E3077D82811A6434769B437 /* libPods-HelloWorldCpp.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + 5E9D65531FFD689B00C955D4 = { + isa = PBXGroup; + children = ( + 5E9D655E1FFD689B00C955D4 /* HelloWorldCpp */, + 5E9D655D1FFD689B00C955D4 /* Products */, + E40B264856595518D408CF3E /* Pods */, + 08FBFA5AB49E037A86EA64D7 /* Frameworks */, + ); + sourceTree = ""; + }; + 5E9D655D1FFD689B00C955D4 /* Products */ = { + isa = PBXGroup; + children = ( + 5E9D655C1FFD689B00C955D4 /* HelloWorldCpp.app */, + ); + name = Products; + sourceTree = ""; + }; + 5E9D655E1FFD689B00C955D4 /* HelloWorldCpp */ = { + isa = PBXGroup; + children = ( + 5E9D655F1FFD689B00C955D4 /* AppDelegate.h */, + 5E9D65601FFD689B00C955D4 /* AppDelegate.mm */, + 5E9D65621FFD689B00C955D4 /* ViewController.h */, + 5E9D65631FFD689B00C955D4 /* ViewController.mm */, + 5E9D65651FFD689B00C955D4 /* Main.storyboard */, + 5E9D65681FFD689B00C955D4 /* Assets.xcassets */, + 5E9D656A1FFD689B00C955D4 /* LaunchScreen.storyboard */, + 5E9D656D1FFD689C00C955D4 /* Info.plist */, + 5E9D656E1FFD689C00C955D4 /* main.m */, + ); + path = HelloWorldCpp; + sourceTree = ""; + }; + E40B264856595518D408CF3E /* Pods */ = { + isa = PBXGroup; + children = ( + AF0FF6EB66DA2C30CFC575EA /* Pods-HelloWorldCpp.debug.xcconfig */, + 0A6137606FDBA874FCF64753 /* Pods-HelloWorldCpp.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 5E9D655B1FFD689B00C955D4 /* HelloWorldCpp */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5E9D65721FFD689C00C955D4 /* Build configuration list for PBXNativeTarget "HelloWorldCpp" */; + buildPhases = ( + 4D66D60BD88AA4D5813859A9 /* [CP] Check Pods Manifest.lock */, + 5E9D65581FFD689B00C955D4 /* Sources */, + 5E9D65591FFD689B00C955D4 /* Frameworks */, + 5E9D655A1FFD689B00C955D4 /* Resources */, + CA89B315EACC5A6F8816FD26 /* [CP] Embed Pods Frameworks */, + 6C4D930C765719D03893663B /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = HelloWorldCpp; + productName = HelloWorldCpp; + productReference = 5E9D655C1FFD689B00C955D4 /* HelloWorldCpp.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 5E9D65541FFD689B00C955D4 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0920; + ORGANIZATIONNAME = gRPC; + TargetAttributes = { + 5E9D655B1FFD689B00C955D4 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 5E9D65571FFD689B00C955D4 /* Build configuration list for PBXProject "HelloWorldCpp" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 5E9D65531FFD689B00C955D4; + productRefGroup = 5E9D655D1FFD689B00C955D4 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 5E9D655B1FFD689B00C955D4 /* HelloWorldCpp */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 5E9D655A1FFD689B00C955D4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5E9D656C1FFD689B00C955D4 /* LaunchScreen.storyboard in Resources */, + 5E9D65691FFD689B00C955D4 /* Assets.xcassets in Resources */, + 5E9D65671FFD689B00C955D4 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 4D66D60BD88AA4D5813859A9 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-HelloWorldCpp-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 6C4D930C765719D03893663B /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-HelloWorldCpp/Pods-HelloWorldCpp-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + CA89B315EACC5A6F8816FD26 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-HelloWorldCpp/Pods-HelloWorldCpp-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 5E9D65581FFD689B00C955D4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5E9D65641FFD689B00C955D4 /* ViewController.mm in Sources */, + 5E9D656F1FFD689C00C955D4 /* main.m in Sources */, + 5E9D65611FFD689B00C955D4 /* AppDelegate.mm in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 5E9D65651FFD689B00C955D4 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 5E9D65661FFD689B00C955D4 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 5E9D656A1FFD689B00C955D4 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 5E9D656B1FFD689B00C955D4 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 5E9D65701FFD689C00C955D4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 5E9D65711FFD689C00C955D4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 5E9D65731FFD689C00C955D4 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = AF0FF6EB66DA2C30CFC575EA /* Pods-HelloWorldCpp.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = EQHXZ8M8AV; + INFOPLIST_FILE = HelloWorldCpp/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.HelloWorldCpp; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 5E9D65741FFD689C00C955D4 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 0A6137606FDBA874FCF64753 /* Pods-HelloWorldCpp.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = EQHXZ8M8AV; + INFOPLIST_FILE = HelloWorldCpp/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.HelloWorldCpp; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 5E9D65571FFD689B00C955D4 /* Build configuration list for PBXProject "HelloWorldCpp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5E9D65701FFD689C00C955D4 /* Debug */, + 5E9D65711FFD689C00C955D4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5E9D65721FFD689C00C955D4 /* Build configuration list for PBXNativeTarget "HelloWorldCpp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5E9D65731FFD689C00C955D4 /* Debug */, + 5E9D65741FFD689C00C955D4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 5E9D65541FFD689B00C955D4 /* Project object */; +} diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.h b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.h new file mode 100644 index 0000000000..0676895a24 --- /dev/null +++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// HelloWorldCpp +// +// Created by Muxi Yan on 1/3/18. +// Copyright © 2018 gRPC. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.mm b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.mm new file mode 100644 index 0000000000..3a4921ff9e --- /dev/null +++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/AppDelegate.mm @@ -0,0 +1,51 @@ +// +// AppDelegate.m +// HelloWorldCpp +// +// Created by Muxi Yan on 1/3/18. +// Copyright © 2018 gRPC. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + + +@end diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..1d060ed288 --- /dev/null +++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,93 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/LaunchScreen.storyboard b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000..f83f6fd581 --- /dev/null +++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/Main.storyboard b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/Main.storyboard new file mode 100644 index 0000000000..d7c78a1255 --- /dev/null +++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Info.plist b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Info.plist new file mode 100644 index 0000000000..16be3b6811 --- /dev/null +++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.h b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.h new file mode 100644 index 0000000000..b5e892cd74 --- /dev/null +++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// HelloWorldCpp +// +// Created by Muxi Yan on 1/3/18. +// Copyright © 2018 gRPC. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.mm b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.mm new file mode 100644 index 0000000000..3b979beadf --- /dev/null +++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.mm @@ -0,0 +1,97 @@ +// +// ViewController.m +// HelloWorldCpp +// +// Created by Muxi Yan on 1/3/18. +// Copyright © 2018 gRPC. All rights reserved. +// + +#import "ViewController.h" +#import +#include +#include + +void* tag(int i) { return (void*)(intptr_t)i; } + +// Serialized Proto bytes of Hello World example +const uint8_t message[] = + {0x0A, 0x0B, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2D, 0x43}; + +@interface ViewController () + +@end + +@implementation ViewController { + grpc::CompletionQueue cli_cq_; + std::unique_ptr generic_stub_; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + // Setup call stub + std::shared_ptr channel = + CreateChannel("localhost:50051", grpc::InsecureChannelCredentials()); + generic_stub_.reset(new grpc::GenericStub(channel)); + + const grpc::string kMethodName("/helloworld.Greeter/SayHello"); + void* got_tag; + bool ok; + + grpc::ClientContext cli_ctx; + std::unique_ptr call = + generic_stub_->Call(&cli_ctx, kMethodName, &cli_cq_, tag(1)); + cli_cq_.Next(&got_tag, &ok); + if (!ok || got_tag != tag(1)) { + NSLog(@"Failed to create call."); + abort(); + } + grpc::Slice send_slice = grpc::Slice(message, sizeof(message) / sizeof(message[0])); + std::unique_ptr send_buffer(new grpc::ByteBuffer(&send_slice, 1)); + call->Write(*send_buffer, tag(2)); + cli_cq_.Next(&got_tag, &ok); + if (!ok || got_tag != tag(2)) { + NSLog(@"Failed to send message."); + abort(); + } + grpc::ByteBuffer recv_buffer; + call->Read(&recv_buffer, tag(3)); + cli_cq_.Next(&got_tag, &ok); + if (!ok || got_tag != tag(3)) { + NSLog(@"Failed to receive message."); + abort(); + } + + grpc::Status status; + call->Finish(&status, tag(4)); + cli_cq_.Next(&got_tag, &ok); + if (!ok || got_tag != tag(4)) { + NSLog(@"Failed to finish call."); + abort(); + } + if (!status.ok()) { + NSLog(@"Received unsuccessful status code: %d", status.error_code()); + abort(); + } + std::vector slices; + recv_buffer.Dump(&slices); + NSString *recvBytes = [[NSString alloc] init]; + for (auto slice : slices) { + auto p = slice.begin(); + while (p != slice.end()) { + recvBytes = + [recvBytes stringByAppendingString:[NSString stringWithFormat:@"%02x ", *p]]; + p++; + } + } + NSLog(@"Hello World succeeded.\nReceived bytes: %@\n" + "Expected bytes: 0a 11 48 65 6c 6c 6f 20 4f 62 6a 65 63 74 69 76 65 2d 43", recvBytes); +} + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + + +@end diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/main.m b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/main.m new file mode 100644 index 0000000000..994e0341b2 --- /dev/null +++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/main.m @@ -0,0 +1,16 @@ +// +// main.m +// HelloWorldCpp +// +// Created by Muxi Yan on 1/3/18. +// Copyright © 2018 gRPC. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/examples/cpp/helloworld/cocoapods/Podfile b/examples/cpp/helloworld/cocoapods/Podfile new file mode 100644 index 0000000000..a471fe03cf --- /dev/null +++ b/examples/cpp/helloworld/cocoapods/Podfile @@ -0,0 +1,10 @@ +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '8.0' + +source 'https://github.com/muxi/grpc-pod.git' + +install! 'cocoapods', :deterministic_uuids => false + +target 'HelloWorldCpp' do + pod 'gRPC-C++' +end -- cgit v1.2.3