Skip to content

Instantly share code, notes, and snippets.

@simonbengtsson
Created June 1, 2018 07:43
Show Gist options
  • Select an option

  • Save simonbengtsson/45c9bbb2f7fabbca1707ebcfe78e08d7 to your computer and use it in GitHub Desktop.

Select an option

Save simonbengtsson/45c9bbb2f7fabbca1707ebcfe78e08d7 to your computer and use it in GitHub Desktop.
Podfile for react native and swift
const fs = require('fs')
const os = require('os');
if (os.platform() === 'win32') {
console.log("Fixes are not needed on windows")
return
}
// Fixes for using react native 0.55.4 as cocoa pods with swift
const changeLinesInFile = (filePath, changeFunc) => {
console.log(`Fixing ${filePath}...`);
const contents = fs
.readFileSync(filePath)
.toString()
.split(/\r?\n/)
const fixedContents = changeFunc(contents)
fs.writeFileSync(filePath, fixedContents.join('\n'))
}
changeLinesInFile('./ios/Pods/Target Support Files/yoga/yoga-umbrella.h', lines => {
const unsupportedImports = ['#import "Utils.h"',
'#import "YGLayout.h"',
'#import "YGNode.h"',
'#import "YGNodePrint.h"',
'#import "YGStyle.h"',
'#import "Yoga-internal.h"']
return lines.map(line => {
return unsupportedImports.includes(line) ? `// ${line}` : line
})
})
changeLinesInFile('./node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceSizeMeasureMode.h', lines => {
if (!lines[27].includes("#ifdef __cplusplus")) {
lines.splice(27, 0, '#ifdef __cplusplus');
lines.splice(34, 0, '#endif')
}
return lines
})
changeLinesInFile('./node_modules/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h', lines => {
return lines.map(line => (
line.includes('#import <RCTAnimation/RCTValueAnimatedNode.h>') ? '#import "RCTValueAnimatedNode.h"' : line
))
})
changeLinesInFile('./node_modules/react-native/Libraries/WebSocket/RCTReconnectingWebSocket.m', lines => {
return lines.map(line => (
line.includes("#import <fishhook/fishhook.h>") ? '#import "fishhook.h"' : line
))
});
// Fix warnings
changeLinesInFile('./node_modules/react-native/React/Views/RCTFont.h', lines => {
if (!lines[0].includes("#pragma clang system_header")) {
lines.splice(0, 0, '#pragma clang system_header')
}
return lines
})
changeLinesInFile('./node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.h', lines => {
if (!lines[0].includes("#pragma clang system_header")) {
lines.splice(0, 0, '#pragma clang system_header')
}
return lines
})
changeLinesInFile('./ios/Pods/Target Support Files/yoga/yoga-umbrella.h', lines => {
if (!lines[0].includes("#pragma clang system_header")) {
lines.splice(0, 0, '#pragma clang system_header')
}
return lines
})
console.log('All fixes performed successfully')
target 'Equilab' do
platform :ios, '10.0'
use_frameworks!
inhibit_all_warnings!
pod 'Charts'
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
pod 'Realm'
pod 'RealmSwift'
pod 'ReachabilitySwift'
# pod 'EstimoteIndoorSDK'
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Firestore'
pod 'Firebase/Storage'
pod 'Firebase/Analytics'
pod 'Firebase/RemoteConfig'
pod 'Firebase/DynamicLinks'
pod 'Firebase/Performance'
pod 'Firebase/Messaging'
pod 'JSQMessagesViewController'
pod 'FirebaseUI/Storage'
pod 'SwiftGen'
pod 'SwiftLint'
pod 'Whisper'
pod 'Fabric'
pod 'Crashlytics'
pod 'GSKStretchyHeaderView'
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'DevSupport',
'RCTAnimation',
'RCTActionSheet',
'RCTText',
'RCTImage',
'RCTNetwork',
'RCTWebSocket',
'CxxBridge',
'RCTLinkingIOS'
]
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
pod 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk/ios'
pod 'RNI18n', :path => '../node_modules/react-native-i18n'
# pod 'react-native-video', :path => '../node_modules/react-native-video'
pod 'RNSVG', :path => '../node_modules/react-native-svg'
target 'Tests' do
inherit! :search_paths
end
end
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
post_install do |installer|
system("cd .. && node ./scripts/fixReactNativePods.js")
end
@simonbengtsson
Copy link
Author

Should also add that we are fixing some warnings by making some yoga headers private instead of public in the yoga pod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment