Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Xcode11 or later build faild #132

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dsBridge.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ Pod::Spec.new do |s|
# the deployment target. You can optionally include the target after the platform.
#

s.platform = :ios, "8.0"
s.platform = :ios, "10.0"
# s.platform = :ios, "5.0"

# When using multiple platforms
s.ios.deployment_target = "8.0"
s.ios.deployment_target = "10.0"
# s.osx.deployment_target = "10.7"
# s.watchos.deployment_target = "2.0"
# s.tvos.deployment_target = "9.0"
Expand Down
6 changes: 4 additions & 2 deletions dsbridge.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,13 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = XTLLEQZMD7;
INFOPLIST_FILE = dsbridgedemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = wendu.dsbridgedemo.xx;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "dsbridgedemo/dsbridgedemo-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -479,11 +480,12 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = XTLLEQZMD7;
INFOPLIST_FILE = dsbridgedemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = wendu.dsbridgedemo.xx;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "dsbridgedemo/dsbridgedemo-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
103 changes: 52 additions & 51 deletions dsbridge/DWKWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ @implementation DWKWebView
void (^confirmHandler)(BOOL);
void (^promptHandler)(NSString *);
void(^javascriptCloseWindowListener)(void);
int dialogType;
int callId;
bool jsDialogBlock;
NSMutableDictionary<NSString *,id> *javaScriptNamespaceInterfaces;
NSMutableDictionary *handerMap;
NSMutableArray<DSCallInfo *> * callInfoList;
NSDictionary<NSString*,NSString*> *dialogTextDic;
UITextField *txtName;
UInt64 lastCallTime ;
NSString *jsCache;
bool isPending;
Expand All @@ -27,8 +25,6 @@ @implementation DWKWebView

-(instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
{
txtName=nil;
dialogType=0;
callId=0;
alertHandler=nil;
confirmHandler=nil;
Expand Down Expand Up @@ -92,21 +88,27 @@ - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSSt
initiatedByFrame:frame
completionHandler:completionHandler];
}else{
dialogType=3;
if(jsDialogBlock){
promptHandler=completionHandler;
}
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:prompt
message:@""
delegate:self
cancelButtonTitle:dialogTextDic[@"promptCancelBtn"]?dialogTextDic[@"promptCancelBtn"]:@"取消"
otherButtonTitles:dialogTextDic[@"promptOkBtn"]?dialogTextDic[@"promptOkBtn"]:@"确定",
nil];
[alert setAlertViewStyle:UIAlertViewStylePlainTextInput];
txtName = [alert textFieldAtIndex:0];
txtName.text=defaultText;
[alert show];

UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:prompt message:@"" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
UITextField *textFile = alertVC.textFields.firstObject;
self->promptHandler(textFile.text);
self->promptHandler=nil;
}];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
self->promptHandler=nil;
}];
[alertVC addAction:sureAction];
[alertVC addAction:cancelAction];
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
[keyWindow.rootViewController presentViewController:alertVC animated:YES completion:nil];
[alertVC addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"请输入";
textField.text = defaultText;
}];
}
}
}
Expand All @@ -126,17 +128,24 @@ - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSStrin
initiatedByFrame:frame
completionHandler:completionHandler];
}else{
dialogType=1;
if(jsDialogBlock){
alertHandler=completionHandler;
}
UIAlertView *alertView =
[[UIAlertView alloc] initWithTitle:dialogTextDic[@"alertTitle"]?dialogTextDic[@"alertTitle"]:@"提示"
message:message
delegate:self
cancelButtonTitle:dialogTextDic[@"alertBtn"]?dialogTextDic[@"alertBtn"]:@"确定"
otherButtonTitles:nil,nil];
[alertView show];
NSString *aMessage = @"";
if (message != nil) {
aMessage = message;
} else if (dialogTextDic[@"alertTitle"] != nil) {
aMessage = dialogTextDic[@"alertTitle"];
}
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:aMessage preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
self->alertHandler();
self->alertHandler=nil;
}];

[alertVC addAction:sureAction];
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
[keyWindow.rootViewController presentViewController:alertVC animated:YES completion:nil];
}
}

Expand All @@ -153,17 +162,28 @@ -(void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSStri
initiatedByFrame:frame
completionHandler:completionHandler];
}else{
dialogType=2;
if(jsDialogBlock){
confirmHandler=completionHandler;
}
UIAlertView *alertView =
[[UIAlertView alloc] initWithTitle:dialogTextDic[@"confirmTitle"]?dialogTextDic[@"confirmTitle"]:@"提示"
message:message
delegate:self
cancelButtonTitle:dialogTextDic[@"confirmCancelBtn"]?dialogTextDic[@"confirmCancelBtn"]:@"取消"
otherButtonTitles:dialogTextDic[@"confirmOkBtn"]?dialogTextDic[@"confirmOkBtn"]:@"确定", nil];
[alertView show];
NSString *aMessage = @"";
if (message != nil) {
aMessage = message;
} else if (dialogTextDic[@"confirmTitle"] != nil) {
aMessage = dialogTextDic[@"confirmTitle"];
}
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:aMessage preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
self->confirmHandler(YES);
self->confirmHandler=nil;
}];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
self->confirmHandler(NO);
self->confirmHandler=nil;
}];
[alertVC addAction:sureAction];
[alertVC addAction:cancelAction];
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
[keyWindow.rootViewController presentViewController:alertVC animated:YES completion:nil];
}
}

Expand Down Expand Up @@ -211,25 +231,6 @@ - (void)webView:(WKWebView *)webView commitPreviewingViewController:(UIViewContr
}
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(dialogType==1 && alertHandler){
alertHandler();
alertHandler=nil;
}else if(dialogType==2 && confirmHandler){
confirmHandler(buttonIndex==1?YES:NO);
confirmHandler=nil;
}else if(dialogType==3 && promptHandler && txtName) {
if(buttonIndex==1){
promptHandler([txtName text]);
}else{
promptHandler(@"");
}
promptHandler=nil;
txtName=nil;
}
}

- (void) evalJavascript:(int) delay{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{
@synchronized(self){
Expand Down