Skip to content

Commit

Permalink
iOS tv-casting-app: Building, linking and calling libTvCastingCommon.a (
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadb-amazon authored Jun 6, 2022
1 parent 28a7b28 commit 092a0ee
Show file tree
Hide file tree
Showing 9 changed files with 378 additions and 1 deletion.
4 changes: 4 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
"${chip_root}/src/setup_payload/java",
]
}

if (build_tv_casting_common_a) {
deps += [ "${chip_root}/examples/tv-casting-app/tv-casting-common:tvCastingCommon" ]
}
}

if (chip_build_tools) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

@interface CastingServerBridge : NSObject

+ (CastingServerBridge *)getSharedInstance;

// TBD: placeholder will be replaced with true CastingServer functions
- (int)add:(int)a secondNum:(int)b;

@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,44 @@
*/

#import "CastingServerBridge.h"
#import "CastingServer.h"

#include <lib/support/CHIPMem.h>
#include <platform/PlatformManager.h>

@implementation CastingServerBridge

+ (CastingServerBridge *)getSharedInstance
{
static CastingServerBridge * instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[self alloc] init];
});
return instance;
}

- (instancetype)init
{
if (self = [super init]) {
CHIP_ERROR err = chip::Platform::MemoryInit();
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "MemoryInit failed: %s", ErrorStr(err));
return nil;
}

err = chip::DeviceLayer::PlatformMgr().InitChipStack();
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "InitChipStack failed: %s", ErrorStr(err));
return nil;
}

CastingServer::GetInstance()->Init();
}
return self;
}

// TBD: placeholder will be replaced with true CastingServer functions
- (int)add:(int)a secondNum:(int)b
{
return a + b;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
3C75075C284B080900D7DB3A /* libmbedtls.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C75075B284B07E800D7DB3A /* libmbedtls.a */; settings = {ATTRIBUTES = (Required, ); }; };
3C9ACC05284ABF4000718B2D /* libTvCastingCommon.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C9ACC04284ABF2F00718B2D /* libTvCastingCommon.a */; };
3CC0E8FA2841DD3400EC6A18 /* TvCastingApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CC0E8F92841DD3400EC6A18 /* TvCastingApp.swift */; };
3CC0E8FC2841DD3400EC6A18 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CC0E8FB2841DD3400EC6A18 /* ContentView.swift */; };
3CC0E8FE2841DD3500EC6A18 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3CC0E8FD2841DD3500EC6A18 /* Assets.xcassets */; };
Expand All @@ -15,6 +17,9 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
3C75075B284B07E800D7DB3A /* libmbedtls.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmbedtls.a; path = lib/libmbedtls.a; sourceTree = BUILT_PRODUCTS_DIR; };
3C75075E284C1DF800D7DB3A /* TvCasting.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = TvCasting.entitlements; sourceTree = "<group>"; };
3C9ACC04284ABF2F00718B2D /* libTvCastingCommon.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTvCastingCommon.a; path = lib/libTvCastingCommon.a; sourceTree = BUILT_PRODUCTS_DIR; };
3CC0E8F62841DD3400EC6A18 /* TvCasting.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TvCasting.app; sourceTree = BUILT_PRODUCTS_DIR; };
3CC0E8F92841DD3400EC6A18 /* TvCastingApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TvCastingApp.swift; sourceTree = "<group>"; };
3CC0E8FB2841DD3400EC6A18 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand All @@ -31,19 +36,31 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3C9ACC05284ABF4000718B2D /* libTvCastingCommon.a in Frameworks */,
3C75075C284B080900D7DB3A /* libmbedtls.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
3C9ACC02284ABBD600718B2D /* Frameworks */ = {
isa = PBXGroup;
children = (
3C75075B284B07E800D7DB3A /* libmbedtls.a */,
3C9ACC04284ABF2F00718B2D /* libTvCastingCommon.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
3CC0E8ED2841DD3400EC6A18 = {
isa = PBXGroup;
children = (
3CC0E90C2841DECC00EC6A18 /* README.md */,
3CC0E8F82841DD3400EC6A18 /* TvCasting */,
3CC0E9072841DD4B00EC6A18 /* MatterBridge */,
3CC0E8F72841DD3400EC6A18 /* Products */,
3C9ACC02284ABBD600718B2D /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -58,6 +75,7 @@
3CC0E8F82841DD3400EC6A18 /* TvCasting */ = {
isa = PBXGroup;
children = (
3C75075E284C1DF800D7DB3A /* TvCasting.entitlements */,
3CC0E8F92841DD3400EC6A18 /* TvCastingApp.swift */,
3CC0E8FB2841DD3400EC6A18 /* ContentView.swift */,
3CC0E8FD2841DD3500EC6A18 /* Assets.xcassets */,
Expand Down Expand Up @@ -86,11 +104,23 @@
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
3C75075D284BD20000D7DB3A /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */

/* Begin PBXNativeTarget section */
3CC0E8F52841DD3400EC6A18 /* TvCasting */ = {
isa = PBXNativeTarget;
buildConfigurationList = 3CC0E9042841DD3500EC6A18 /* Build configuration list for PBXNativeTarget "TvCasting" */;
buildPhases = (
3C9ACC012849D55B00718B2D /* Run Script */,
3C75075D284BD20000D7DB3A /* Headers */,
3CC0E8F22841DD3400EC6A18 /* Sources */,
3CC0E8F32841DD3400EC6A18 /* Frameworks */,
3CC0E8F42841DD3400EC6A18 /* Resources */,
Expand Down Expand Up @@ -150,6 +180,27 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
3C9ACC012849D55B00718B2D /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Run Script";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "./chip_xcode_build_connector.sh\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
3CC0E8F22841DD3400EC6A18 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -206,7 +257,9 @@
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
CHIP_HAVE_CONFIG_H,
"DEBUG=1",
"CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down Expand Up @@ -264,6 +317,7 @@
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = CHIP_HAVE_CONFIG_H;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -285,12 +339,40 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CHIP_ROOT = "$(PROJECT_DIR)/../../../..";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = TvCasting/TvCasting.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"TvCasting/Preview Content\"";
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_PREVIEWS = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
CHIP_HAVE_CONFIG_H,
"CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>",
"DEBUG=1",
"$(inherited)",
);
GENERATE_INFOPLIST_FILE = YES;
HEADER_SEARCH_PATHS = (
"${CHIP_ROOT}/examples/tv-casting-app/tv-casting-common/include",
"$(CHIP_ROOT)/src",
"$(CHIP_ROOT)/src/include",
"$(CHIP_ROOT)/src/lib",
"$(CHIP_ROOT)/src/app",
"$(CHIP_ROOT)/config/ios",
"$(CHIP_ROOT)/src/darwin/Framework/CHIP/",
"$(CHIP_ROOT)/src/app/util",
"$(CHIP_ROOT)/third_party/nlassert/repo/include",
"$(CHIP_ROOT)/third_party/nlio/repo/include",
"$(TEMP_DIR)/out/gen/include",
"$(CHIP_ROOT)/zzz_generated/",
"$(CHIP_ROOT)/zzz_generated/app-common",
"$(CHIP_ROOT)/zzz_generated/controller-clusters",
);
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand All @@ -300,9 +382,37 @@
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = "$(TEMP_DIR)/out/lib";
MARKETING_VERSION = 1.0;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"-Wformat",
"-Wformat-nonliteral",
"-Wformat-security",
);
"OTHER_LDFLAGS[arch=*]" = (
"-framework",
CoreData,
"-framework",
Foundation,
"-framework",
CoreBluetooth,
"-lnetwork",
"-Wl,-unexported_symbol,\"__Z*\"",
);
"OTHER_LDFLAGS[sdk=macosx*]" = (
"-framework",
IOKit,
"-lnetwork",
"-framework",
CoreBluetooth,
"-framework",
CoreData,
"-Wl,-unexported_symbol,\"__Z*\"",
);
PRODUCT_BUNDLE_IDENTIFIER = com.matter.TvCasting;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "MatterBridge/TvCasting-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -316,12 +426,39 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CHIP_ROOT = "$(PROJECT_DIR)/../../../..";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = TvCasting/TvCasting.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"TvCasting/Preview Content\"";
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_PREVIEWS = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
CHIP_HAVE_CONFIG_H,
"CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>",
"$(inherited)",
);
GENERATE_INFOPLIST_FILE = YES;
HEADER_SEARCH_PATHS = (
"${CHIP_ROOT}/examples/tv-casting-app/tv-casting-common/include",
"$(CHIP_ROOT)/src",
"$(CHIP_ROOT)/src/include",
"$(CHIP_ROOT)/src/lib",
"$(CHIP_ROOT)/src/app",
"$(CHIP_ROOT)/config/ios",
"$(CHIP_ROOT)/src/darwin/Framework/CHIP/",
"$(CHIP_ROOT)/src/app/util",
"$(CHIP_ROOT)/third_party/nlassert/repo/include",
"$(CHIP_ROOT)/third_party/nlio/repo/include",
"$(TEMP_DIR)/out/gen/include",
"$(CHIP_ROOT)/zzz_generated/",
"$(CHIP_ROOT)/zzz_generated/app-common",
"$(CHIP_ROOT)/zzz_generated/controller-clusters",
);
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand All @@ -331,9 +468,17 @@
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = "$(TEMP_DIR)/out/lib";
MARKETING_VERSION = 1.0;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"-Wformat",
"-Wformat-nonliteral",
"-Wformat-security",
);
PRODUCT_BUNDLE_IDENTIFIER = com.matter.TvCasting;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "MatterBridge/TvCasting-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import SwiftUI

struct ContentView: View {
var body: some View {
Text("Hello Objective-C from Swift! " + String(CastingServerBridge().add(5, secondNum: 6)))
Text("Hello tv-casting-common C++, from Objective-C, from Swift! Sum: " + String(CastingServerBridge.getSharedInstance().add(5, secondNum: 6)))
.padding()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
</plist>
Loading

0 comments on commit 092a0ee

Please sign in to comment.