Skip to content

Commit

Permalink
chore(ios): update hippy demo, adapt to hippy3
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Nov 28, 2024
1 parent 7ef301c commit 1618489
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
10 changes: 8 additions & 2 deletions examples/ios-demo/HippyDemo/TestModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@
*/

#import "TestModule.h"
#import "HippyRootView.h"
#import <hippy/HippyRootView.h>
#import <hippy/HippyBridge.h>
#import <hippy/HippyBridgeDelegate.h>
#import "AppDelegate.h"
#import "HippyBundleURLProvider.h"
#import "DemoConfigs.h"

@interface TestModule ()<HippyBridgeDelegate>

/// The debug bundle url
@property (nonatomic, strong) NSURL *debugBundleUrl;

@end

@implementation TestModule
Expand Down Expand Up @@ -78,6 +83,7 @@ - (dispatch_queue_t)methodQueue
}

NSURL *url = [NSURL URLWithString:urlString];
self.debugBundleUrl = url;
NSDictionary *launchOptions = @{@"EnableTurbo": @(DEMO_ENABLE_TURBO), @"DebugMode": @(YES)};
HippyBridge *bridge = [[HippyBridge alloc] initWithDelegate:self
bundleURL:url
Expand All @@ -101,7 +107,7 @@ - (BOOL)shouldStartInspector:(HippyBridge *)bridge {
}

- (NSURL *)inspectorSourceURLForBridge:(HippyBridge *)bridge {
return bridge.bundleURL;
return self.debugBundleUrl;
}

#pragma mark - Hippy Bridge Delegate
Expand Down
15 changes: 10 additions & 5 deletions examples/ios-demo/HippyDemo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
*/

#import "ViewController.h"
#import "HippyRootView.h"
#import "HippyLog.h"
#import "HippyBundleURLProvider.h"
#import "DemoConfigs.h"
#import "HippyBridge.h"
#import <hippy/HippyBundleURLProvider.h>
#import <hippy/HippyRootView.h>
#import <hippy/HippyLog.h>
#import <hippy/HippyBridge.h>
#import <hippy/HippyAssert.h>
#import <sys/utsname.h>


Expand All @@ -38,6 +39,9 @@ @interface ViewController () <HippyBridgeDelegate, HippyMethodInterceptorProtoco
/// Hippy Root View
@property (nonatomic, strong) HippyRootView *hippyRootView;

/// The debug bundle URL
@property (nonatomic, strong) NSURL *debugBundleUrl;

@end

static NSString *formatLog(NSDate *timestamp, HippyLogLevel level, NSString *fileName, NSNumber *lineNumber, NSString *message) {
Expand Down Expand Up @@ -92,6 +96,7 @@ - (void)viewDidLoad {
NSDictionary *launchOptions = @{@"EnableTurbo": @(DEMO_ENABLE_TURBO), @"DebugMode": @(YES)};
NSString *bundleStr = [HippyBundleURLProvider sharedInstance].bundleURLString;
NSURL *bundleUrl = [NSURL URLWithString:bundleStr];
self.debugBundleUrl = bundleUrl;
HippyBridge *bridge = [[HippyBridge alloc] initWithDelegate:self
bundleURL:bundleUrl
moduleProvider:nil
Expand Down Expand Up @@ -171,7 +176,7 @@ - (BOOL)shouldStartInspector:(HippyBridge *)bridge {
}

- (NSURL *)inspectorSourceURLForBridge:(HippyBridge *)bridge {
return bridge.bundleURL;
return self.debugBundleUrl;
}


Expand Down

0 comments on commit 1618489

Please sign in to comment.