From 7a55d562346aeb5aa76a317e9c161ec7fa91b1c7 Mon Sep 17 00:00:00 2001 From: Mike Hardy Date: Tue, 6 Jul 2021 14:06:56 -0500 Subject: [PATCH] docs(example): update Swift compile fix, package.json example targets --- README.md | 24 +++++++++++++++++++++--- package.json | 8 ++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a6f38eab..7c87e4b4 100644 --- a/README.md +++ b/README.md @@ -183,15 +183,33 @@ Undefined symbols for architecture x86_64: (maybe you meant: _swift_FORCE_LOAD$swiftWebKit$_FBSDKLoginKit, _swift_FORCE_LOAD$swiftWebKit$_FBSDKShareKit , _swift_FORCE_LOAD$swiftWebKit$_FBSDKCoreKit ) ld: symbol(s) not found for architecture x86_64 ``` - - After **facebook-ios-sdk v7** you need to create a swift file like so ([File.Swift](https://github.com/thebergamo/react-native-fbsdk-next/blob/master/example/ios/RNFBSDKExample/File.swift)) in the main project folder. When you add an empty swift file, XCode will ask you if you want to "Create Bridging Header". - It will include to the Header Search Path on your build settings: + After **facebook-ios-sdk v7** (written with Swift parts) you need to coordinate Swift language usage with Objective-C for iOS. + + Either: + +- add a new file named `File.Swift` in the main project folder and answer "yes" when Xcode asks you if you want to "Create Bridging Header" +The empty swift file makes this change to the Header Search Path on your build settings: ``` $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) ``` +- or add this stanza in the postinstall section of your Podfile as a possible workaround (then `pod deintegrate && pod install`): + + ```ruby + # Mixing Swift and Objective-C in a react-native project may be problematic. + # Workaround: https://github.com/facebookarchive/react-native-fbsdk/issues/755#issuecomment-787488994 + installer.aggregate_targets.first.user_project.native_targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(inherited)', '$(SDKROOT)/usr/lib/swift'] + end + end + ``` + + Both result in fixing search paths. + + ## Usage ### SDK Initialization diff --git a/package.json b/package.json index 0bac8d1f..875d7e4f 100644 --- a/package.json +++ b/package.json @@ -50,11 +50,11 @@ "flow": "flow", "lint": "eslint ./src", "test": "yarn validate:prettier && yarn validate:eslint && yarn validate:flow", - "validate:eslint": "eslint \"src/**/*\" \"example/src/**/*\"", + "validate:eslint": "eslint \"src/**/*\"", "validate:flow": "flow", - "validate:prettier": "prettier \"src/**/*.js\" \"example/src/**/*.js\" --check", - "example:ios": "cd ./example && react-native run-ios", - "example:android": "cd ./example && react-native run-android --no-jetifier", + "validate:prettier": "prettier \"src/**/*.js\" --check", + "example:ios": "cd ./RNFBSDKExample && yarn ios", + "example:android": "cd ./RNFBSDKExample && yarn android --no-jetifier", "semantic-release": "semantic-release" }, "files": [