Skip to content

Commit

Permalink
Add target ObjectiveCAppExample to InstanaAgentExample to demonstrate…
Browse files Browse the repository at this point in the history
… how to integrate iOSAgent with Objective-C app
  • Loading branch information
Hongyan Jiang authored and GitHub Enterprise committed Jan 3, 2024
1 parent 13f68fb commit 9a92ce9
Show file tree
Hide file tree
Showing 15 changed files with 491 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Add more meta data to crash beacon
- Add more exceptionType processing to crash beacon
- Display crash terminationReason as meta data rather than error message
- Add Objective-C target ObjectiveCAppExample to InstanaAgentExample

## 1.6.7
- Add more raw crash payload info to stackTrace
Expand Down
190 changes: 190 additions & 0 deletions Dev/InstanaAgentExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
72976A9A2681C45800A284F6 /* Webserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72976A992681C45800A284F6 /* Webserver.swift */; };
729C88B5270DE98200492486 /* AFNetworking in Frameworks */ = {isa = PBXBuildFile; productRef = 729C88B4270DE98200492486 /* AFNetworking */; };
729C88B8270DF13700492486 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 729C88B7270DF13700492486 /* Alamofire */; };
A46F87782B44DE8D00302343 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A46F87772B44DE8D00302343 /* AppDelegate.m */; };
A46F877B2B44DE8D00302343 /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A46F877A2B44DE8D00302343 /* SceneDelegate.m */; };
A46F877E2B44DE8D00302343 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A46F877D2B44DE8D00302343 /* ViewController.m */; };
A46F87812B44DE8D00302343 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A46F877F2B44DE8D00302343 /* Main.storyboard */; };
A46F87832B44DE8E00302343 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A46F87822B44DE8E00302343 /* Assets.xcassets */; };
A46F87862B44DE8E00302343 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A46F87842B44DE8E00302343 /* LaunchScreen.storyboard */; };
A46F87892B44DE8E00302343 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A46F87882B44DE8E00302343 /* main.m */; };
A46F87912B44E79600302343 /* InstanaAgent in Frameworks */ = {isa = PBXBuildFile; productRef = A46F87902B44E79600302343 /* InstanaAgent */; };
A4EFD6A12A9983FB00B9A9A3 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4EFD6A02A9983FB00B9A9A3 /* WebKit.framework */; };
CE322E492A6E3CEF00414F37 /* TopRatedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE322E482A6E3CEF00414F37 /* TopRatedViewController.swift */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -70,6 +78,18 @@
727AF73A263AA0FA00B9C59B /* EventListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventListViewController.swift; sourceTree = "<group>"; };
72976A992681C45800A284F6 /* Webserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Webserver.swift; path = "../../Tests/InstanaAgentTests/Test helpers/Webserver.swift"; sourceTree = "<group>"; };
72FBE8A7263AACDB00CF2CDE /* InstanaAgentExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = InstanaAgentExample.entitlements; sourceTree = "<group>"; };
A46F87742B44DE8D00302343 /* ObjectiveCAppExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ObjectiveCAppExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
A46F87762B44DE8D00302343 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
A46F87772B44DE8D00302343 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
A46F87792B44DE8D00302343 /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = "<group>"; };
A46F877A2B44DE8D00302343 /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = "<group>"; };
A46F877C2B44DE8D00302343 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
A46F877D2B44DE8D00302343 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
A46F87802B44DE8D00302343 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
A46F87822B44DE8E00302343 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
A46F87852B44DE8E00302343 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
A46F87872B44DE8E00302343 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A46F87882B44DE8E00302343 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
A4EFD6A02A9983FB00B9A9A3 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/iOSSupport/System/Library/PrivateFrameworks/WebKit.framework; sourceTree = DEVELOPER_DIR; };
CE322E482A6E3CEF00414F37 /* TopRatedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopRatedViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -101,6 +121,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
A46F87712B44DE8D00302343 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A46F87912B44E79600302343 /* InstanaAgent in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
Expand All @@ -124,6 +152,7 @@
727AF687263A9EBD00B9C59B /* InstanaAgentExample */,
727AF71A263AA09C00B9C59B /* iOSAgentUITests */,
725029D0263AB32300302532 /* macAgentExample */,
A46F87752B44DE8D00302343 /* ObjectiveCAppExample */,
727AF686263A9EBD00B9C59B /* Products */,
727AF710263A9FC800B9C59B /* Frameworks */,
);
Expand All @@ -135,6 +164,7 @@
727AF685263A9EBD00B9C59B /* InstanaAgentExample.app */,
727AF719263AA09C00B9C59B /* iOSAgentUITests.xctest */,
725029CF263AB32300302532 /* macAgentExample.app */,
A46F87742B44DE8D00302343 /* ObjectiveCAppExample.app */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -178,6 +208,24 @@
path = iOSAgentUITests;
sourceTree = "<group>";
};
A46F87752B44DE8D00302343 /* ObjectiveCAppExample */ = {
isa = PBXGroup;
children = (
A46F87762B44DE8D00302343 /* AppDelegate.h */,
A46F87772B44DE8D00302343 /* AppDelegate.m */,
A46F87792B44DE8D00302343 /* SceneDelegate.h */,
A46F877A2B44DE8D00302343 /* SceneDelegate.m */,
A46F877C2B44DE8D00302343 /* ViewController.h */,
A46F877D2B44DE8D00302343 /* ViewController.m */,
A46F877F2B44DE8D00302343 /* Main.storyboard */,
A46F87822B44DE8E00302343 /* Assets.xcassets */,
A46F87842B44DE8E00302343 /* LaunchScreen.storyboard */,
A46F87872B44DE8E00302343 /* Info.plist */,
A46F87882B44DE8E00302343 /* main.m */,
);
path = ObjectiveCAppExample;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -246,6 +294,26 @@
productReference = 727AF719263AA09C00B9C59B /* iOSAgentUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
A46F87732B44DE8D00302343 /* ObjectiveCAppExample */ = {
isa = PBXNativeTarget;
buildConfigurationList = A46F878C2B44DE8E00302343 /* Build configuration list for PBXNativeTarget "ObjectiveCAppExample" */;
buildPhases = (
A46F87702B44DE8D00302343 /* Sources */,
A46F87712B44DE8D00302343 /* Frameworks */,
A46F87722B44DE8D00302343 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = ObjectiveCAppExample;
packageProductDependencies = (
A46F87902B44E79600302343 /* InstanaAgent */,
);
productName = ObjectiveCAppExample;
productReference = A46F87742B44DE8D00302343 /* ObjectiveCAppExample.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
Expand All @@ -265,6 +333,9 @@
CreatedOnToolsVersion = 12.4;
TestTargetID = 727AF684263A9EBD00B9C59B;
};
A46F87732B44DE8D00302343 = {
CreatedOnToolsVersion = 15.0;
};
};
};
buildConfigurationList = 727AF680263A9EBD00B9C59B /* Build configuration list for PBXProject "InstanaAgentExample" */;
Expand All @@ -287,6 +358,7 @@
727AF684263A9EBD00B9C59B /* InstanaAgentExample */,
727AF718263AA09C00B9C59B /* iOSAgentUITests */,
725029CE263AB32300302532 /* macAgentExample */,
A46F87732B44DE8D00302343 /* ObjectiveCAppExample */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -318,6 +390,16 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
A46F87722B44DE8D00302343 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A46F87862B44DE8E00302343 /* LaunchScreen.storyboard in Resources */,
A46F87832B44DE8E00302343 /* Assets.xcassets in Resources */,
A46F87812B44DE8D00302343 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -452,6 +534,17 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
A46F87702B44DE8D00302343 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A46F877E2B44DE8D00302343 /* ViewController.m in Sources */,
A46F87782B44DE8D00302343 /* AppDelegate.m in Sources */,
A46F87892B44DE8E00302343 /* main.m in Sources */,
A46F877B2B44DE8D00302343 /* SceneDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
Expand Down Expand Up @@ -487,6 +580,22 @@
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
A46F877F2B44DE8D00302343 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
A46F87802B44DE8D00302343 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
A46F87842B44DE8E00302343 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
A46F87852B44DE8E00302343 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down Expand Up @@ -732,6 +841,74 @@
};
name = Release;
};
A46F878A2B44DE8E00302343 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ObjectiveCAppExample/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.instana.ios.ObjectiveCAppExample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
A46F878B2B44DE8E00302343 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ObjectiveCAppExample/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.instana.ios.ObjectiveCAppExample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
Expand Down Expand Up @@ -771,6 +948,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
A46F878C2B44DE8E00302343 /* Build configuration list for PBXNativeTarget "ObjectiveCAppExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A46F878A2B44DE8E00302343 /* Debug */,
A46F878B2B44DE8E00302343 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
Expand Down Expand Up @@ -811,6 +997,10 @@
package = 729C88B6270DF13700492486 /* XCRemoteSwiftPackageReference "Alamofire" */;
productName = Alamofire;
};
A46F87902B44E79600302343 /* InstanaAgent */ = {
isa = XCSwiftPackageProductDependency;
productName = InstanaAgent;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 727AF67D263A9EBD00B9C59B /* Project object */;
Expand Down
14 changes: 14 additions & 0 deletions Dev/ObjectiveCAppExample/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// AppDelegate.h
// ObjectiveCAppExample
//
// Created by Helen Jiang on 1/2/24.
//

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>


@end

56 changes: 56 additions & 0 deletions Dev/ObjectiveCAppExample/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// AppDelegate.m
// ObjectiveCAppExample
//
// Created by Helen Jiang on 1/2/24.
//

#import "AppDelegate.h"
@import InstanaAgent;

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//note: explicitly get user permission before set enableCrashReporting to true
InstanaSetupOptions* options = [[InstanaSetupOptions alloc] initWithHttpCaptureConfig: 0
collectionEnabled: true
enableCrashReporting: true
suspendReportingOnLowBattery: true
suspendReportingOnCellular: false
slowSendInterval: 0.0
usiRefreshTimeIntervalInHrs: -1];
(void)[Instana setupWithKey: @"INSTANA_REPORTING_KEY"
reportingURL: [NSURL URLWithString: @"INSTANA_REPORTING_URL"]
options: options];

NSURL* url = [NSURL URLWithString: @"https://www.ibm.com/jp-ja"];
NSURLRequest* request = [NSURLRequest requestWithURL: url];
[[[NSURLSession sharedSession] dataTaskWithRequest: request] resume];

return YES;
}


#pragma mark - UISceneSession lifecycle


- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}


- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 9a92ce9

Please sign in to comment.