From 80584025e29da8123acecfb2de8a7462a99af3f5 Mon Sep 17 00:00:00 2001 From: Van Date: Tue, 10 Jan 2017 15:06:45 +0800 Subject: [PATCH] support RN 0.40.0 --- README.md | 11 ++++------- ios/RCTQQSDK/RCTConvert+QQShareScene.h | 2 +- ios/RCTQQSDK/RCTQQSDK.h | 6 +++--- package.json | 2 +- scripts/postlink/postlink.js | 17 ++++++----------- scripts/postunlink/postunlink.js | 19 ++++++------------- 6 files changed, 21 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 57db758..1643d03 100644 --- a/README.md +++ b/README.md @@ -66,17 +66,14 @@ npm install --save react-native-qqsdk@latest 6. Click the plus sign underneath the "Link Binary With Libraries" list and add the TencentOpenAPI.framework which locate in `../node_modules/react-native-qqsdk/ios/RCTQQSDK`. Then Under the "Build Settings" tab of your project configuration, find the "Framework Search Paths" section and edit the value. Add a new value, `$(SRCROOT)/../node_modules/react-native-qqsdk/ios/RCTQQSDK`. -7. Under the "Build Settings" tab of your project configuration, find the "Header Search Paths" section and edit the value. -Add a new value, `$(SRCROOT)/../node_modules/react-native-qqsdk/ios/RCTQQSDK` and select "recursive" in the dropdown. +7. Under the "Info" tab of your project configuration, find the "URL Types" section and add your app Id. -8. Under the "Info" tab of your project configuration, find the "URL Types" section and add your app Id. - -9. Under the "Info" tab of your project configuration, add LSApplicationQueriesSchemes For QQ SDK. +8. Under the "Info" tab of your project configuration, add LSApplicationQueriesSchemes For QQ SDK. ![Add LSApplicationQueriesSchemes](https://github.com/iVanPan/react-native-qqsdk/blob/master/asset/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202016-12-13%2013.47.15.png) -10. add following code to your AppDelegate.m +9. add following code to your AppDelegate.m ```objectiv-c ... -#import "RCTLinkingManager.h" +#import - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation diff --git a/ios/RCTQQSDK/RCTConvert+QQShareScene.h b/ios/RCTQQSDK/RCTConvert+QQShareScene.h index 9a752ab..fd76f33 100644 --- a/ios/RCTQQSDK/RCTConvert+QQShareScene.h +++ b/ios/RCTQQSDK/RCTConvert+QQShareScene.h @@ -6,7 +6,7 @@ // Copyright © 2016年 Van. All rights reserved. // -#import +#import #import "RCTQQSDK.h" @interface RCTConvert(QQShareScene) + (QQShareScene)QQShareScene:(id)json; diff --git a/ios/RCTQQSDK/RCTQQSDK.h b/ios/RCTQQSDK/RCTQQSDK.h index eaccca8..081d434 100644 --- a/ios/RCTQQSDK/RCTQQSDK.h +++ b/ios/RCTQQSDK/RCTQQSDK.h @@ -7,11 +7,11 @@ // #import -#import "RCTBridgeModule.h" +#import #import #import -#import "RCTBridge.h" -#import "RCTEventEmitter.h" +#import +#import typedef NS_ENUM(NSInteger, QQShareScene) { QQ, diff --git a/package.json b/package.json index c283e12..ae8e269 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-qqsdk", - "version": "0.6.4", + "version": "0.6.5", "description": "react-native wrapper for qq sdk", "main": "index.js", "scripts": { diff --git a/scripts/postlink/postlink.js b/scripts/postlink/postlink.js index ba9b45a..52c1782 100644 --- a/scripts/postlink/postlink.js +++ b/scripts/postlink/postlink.js @@ -37,7 +37,7 @@ addQueriesSchemes(); function addRCTLinkManagerHeader() { - var linkHeaderImportStatement = `#import "RCTLinkingManager.h"`; + var linkHeaderImportStatement = `#import `; if (~appDelegateContents.indexOf(linkHeaderImportStatement)) { console.log(`"RCTLinkingManager.h" header already imported.`); } else { @@ -159,7 +159,7 @@ function addFrameworkAndSearchPath() { if (error) { console.log('xcode project error is', error); } else { - var target = project.getFirstTarget().uuid; + var target = project.getFirstTarget().uuid; var file = new pbxFile(project_relative,{customFramework: true, target:target}); file.uuid = project.generateUuid(); file.fileRef = project.generateUuid(); @@ -169,13 +169,14 @@ function addFrameworkAndSearchPath() { project.addToPbxFileReferenceSection(file); // PBXFileReference project.addToFrameworksPbxGroup(file); // PBXGroup project.addToPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase - addSearchPaths(project,'"$(SRCROOT)/../node_modules/react-native/Libraries/**"','"$(SRCROOT)/../node_modules/react-native-qqsdk/ios/RCTQQSDK/**"'); + //project.addToFrameworkSearchPaths(file); + addSearchPaths(project,'"$(SRCROOT)/../node_modules/react-native-qqsdk/ios/RCTQQSDK/**"'); fs.writeFileSync(projectPath, project.writeSync()); } }); } -function addSearchPaths(project, headerSearchPath, frameworkSearchPath) { +function addSearchPaths(project, frameworkSearchPath) { const config = project.pbxXCBuildConfigurationSection(); const INHERITED = '"$(inherited)"'; Object @@ -184,14 +185,8 @@ function addSearchPaths(project, headerSearchPath, frameworkSearchPath) { .forEach(ref => { const buildSettings = config[ref].buildSettings; const shouldVisitBuildSettings = ( - Array.isArray(buildSettings.HEADER_SEARCH_PATHS) ? - buildSettings.HEADER_SEARCH_PATHS : - []).filter(path => path.indexOf('react-native/React/**') >= 0).length > 0; + buildSettings['PRODUCT_NAME'] === package.name); if (shouldVisitBuildSettings) { - var headerIndex = _.findIndex(buildSettings['HEADER_SEARCH_PATHS'], function(path) { return path == headerSearchPath; }); - if (headerIndex === -1) { - buildSettings['HEADER_SEARCH_PATHS'].push(headerSearchPath); - } if (!buildSettings['FRAMEWORK_SEARCH_PATHS'] || buildSettings['FRAMEWORK_SEARCH_PATHS'] === INHERITED) { buildSettings['FRAMEWORK_SEARCH_PATHS'] = [INHERITED]; diff --git a/scripts/postunlink/postunlink.js b/scripts/postunlink/postunlink.js index a2d9c94..ae11672 100644 --- a/scripts/postunlink/postunlink.js +++ b/scripts/postunlink/postunlink.js @@ -35,9 +35,9 @@ removeFrameworkAndSearchPath(); function removeRCTLinkManagerHeader() { - var linkHeaderImportStatement = `#import "RCTLinkingManager.h"`; + var linkHeaderImportStatement = `#import `; if (~appDelegateContents.indexOf(linkHeaderImportStatement)) { - console.log(`"RCTLinkingManager.h" header already imported.`); + console.log(`"RCTLinkingManager.h" header delete.`); appDelegateContents = appDelegateContents.replace(linkHeaderImportStatement,''); } fs.writeFileSync(appDelegatePath, appDelegateContents); @@ -119,13 +119,14 @@ function removeFrameworkAndSearchPath() { project.removeFromPbxFileReferenceSection(file); // PBXFileReference project.removeFromFrameworksPbxGroup(file); // PBXGroup project.removeFromPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase - removeSearchPaths(project,'"$(SRCROOT)/../node_modules/react-native/Libraries/**"','"$(SRCROOT)/../node_modules/react-native-qqsdk/ios/RCTQQSDK/**"'); + //project.removeFromFrameworkSearchPaths(file); + removeSearchPaths(project,'"$(SRCROOT)/../node_modules/react-native-qqsdk/ios/RCTQQSDK/**"'); fs.writeFileSync(projectPath, project.writeSync()); } }); } -function removeSearchPaths(project, headerSearchPath, frameworkSearchPath) { +function removeSearchPaths(project, frameworkSearchPath) { const config = project.pbxXCBuildConfigurationSection(); Object .keys(config) @@ -133,16 +134,8 @@ function removeSearchPaths(project, headerSearchPath, frameworkSearchPath) { .forEach(ref => { const buildSettings = config[ref].buildSettings; const shouldVisitBuildSettings = ( - Array.isArray(buildSettings.HEADER_SEARCH_PATHS) ? - buildSettings.HEADER_SEARCH_PATHS : - []).filter(path => path.indexOf('react-native/React/**') >= 0).length > 0; + buildSettings['PRODUCT_NAME'] === package.name); if (shouldVisitBuildSettings) { - if (buildSettings['HEADER_SEARCH_PATHS']) { - const paths = _.remove(buildSettings['HEADER_SEARCH_PATHS'], function(path) { - return path !== headerSearchPath; - }); - buildSettings['HEADER_SEARCH_PATHS'] = paths; - } if (buildSettings['FRAMEWORK_SEARCH_PATHS']) { const paths = _.remove(buildSettings['FRAMEWORK_SEARCH_PATHS'], function(path) { return path !== frameworkSearchPath;