Skip to content

Commit

Permalink
support RN 0.40.0
Browse files Browse the repository at this point in the history
  • Loading branch information
iVanPan committed Jan 10, 2017
1 parent d1b25b3 commit 8058402
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 36 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <React/RCTLinkingManager.h>
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
Expand Down
2 changes: 1 addition & 1 deletion ios/RCTQQSDK/RCTConvert+QQShareScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2016年 Van. All rights reserved.
//

#import <RCTConvert.h>
#import <React/RCTConvert.h>
#import "RCTQQSDK.h"
@interface RCTConvert(QQShareScene)
+ (QQShareScene)QQShareScene:(id)json;
Expand Down
6 changes: 3 additions & 3 deletions ios/RCTQQSDK/RCTQQSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
//

#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
#import <React/RCTBridgeModule.h>
#import <TencentOpenAPI/QQApiInterface.h>
#import <TencentOpenAPI/TencentOAuth.h>
#import "RCTBridge.h"
#import "RCTEventEmitter.h"
#import <React/RCTBridge.h>
#import <React/RCTEventEmitter.h>

typedef NS_ENUM(NSInteger, QQShareScene) {
QQ,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
17 changes: 6 additions & 11 deletions scripts/postlink/postlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ addQueriesSchemes();


function addRCTLinkManagerHeader() {
var linkHeaderImportStatement = `#import "RCTLinkingManager.h"`;
var linkHeaderImportStatement = `#import <React/RCTLinkingManager.h>`;
if (~appDelegateContents.indexOf(linkHeaderImportStatement)) {
console.log(`"RCTLinkingManager.h" header already imported.`);
} else {
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -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];
Expand Down
19 changes: 6 additions & 13 deletions scripts/postunlink/postunlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ removeFrameworkAndSearchPath();


function removeRCTLinkManagerHeader() {
var linkHeaderImportStatement = `#import "RCTLinkingManager.h"`;
var linkHeaderImportStatement = `#import <React/RCTLinkingManager.h>`;
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);
Expand Down Expand Up @@ -119,30 +119,23 @@ 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)
.filter(ref => ref.indexOf('_comment') === -1)
.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;
Expand Down

0 comments on commit 8058402

Please sign in to comment.