I can't build my app on iOS due to linking error. I mostly work on Ubuntu/Android. I don't know exactly when it started failing on iOS.
I'm using the use_framework! trick to add them as static library.
I've found #394 #434 (second part) that might be linked.
As suggested in these issues, I deleted derivedData, node_modules, and Pods. But I end up with the same error.
Error message:
Showing Recent Messages
: "_OBJC_CLASS_$_RNPermissionHandlerPhotoLibrary", referenced from:
: Objc-class-ref in RNPermissions.o
: "_OBJC_CLASS_$_RNPermissionHandlerMediaLibrary", referenced from:
: Objc-class-ref in RNPermissions.o
: "_OBJC_CLASS_$_RNPermissionHandlerCamera", referenced from:
: Objc-class-ref in RNPermissions.o
: Symbol(s) not found for architecture x86_64
: Linker command failed with exit code 1 (use -v to see invocation)
Package.json info:
"react": "16.12.0",
"react-native": "^0.61.5",
"react-native-permissions": "2.1.0",
podfile info:
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
workspace 'MyApp'
target 'MyApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
$static_frameworks = [
# list your permission handlers here
'Permission-Camera',
'Permission-MediaLibrary',
'Permission-PhotoLibrary'
]
# Convert all permissions handlers into static libraries
pre_install do |installer|
installer.pod_targets.each do |pod|
if $static_frameworks.include?(pod.name)
puts "Link #{pod.name} as static_library"
def pod.build_type;
# Uncomment one line depending on your CocoaPods version
# Pod::BuildType.static_library # >= 1.9
Pod::Target::BuildType.static_library # < 1.9
end
end
end
end
# Pods for MyApp
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
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'
use_native_modules!
pod 'RNFileViewer', :path => '../node_modules/react-native-file-viewer'
pod 'SentryReactNative', :path => '../node_modules/react-native-sentry'
pod 'react-native-webview', :path => '../node_modules/react-native-webview'
pod 'react-native-camera', :path => '../node_modules/react-native-camera'
pod 'RNShare', :path => '../node_modules/react-native-share'
pod 'react-native-document-picker', :path => '../node_modules/react-native-document-picker'
pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
pod 'RNFS', :path => '../node_modules/react-native-fs'
pod 'RNReanimated', :path => '../node_modules/react-native-reanimated'
pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'
pod 'react-native-rsa-native', :path => '../node_modules/react-native-rsa-native'
pod 'react-native-cookies', :path => '../node_modules/react-native-cookies/ios'
pod 'react-native-config', :path => '../node_modules/react-native-config'
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary.podspec"
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"
end
Environment Info:
System:
OS: macOS 10.15.4
CPU: (4) x64 Intel(R) Core(TM) i3-8100B CPU @ 3.60GHz
Memory: 403.19 MB / 8.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 10.15.3 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
IDEs:
Xcode: 11.4/11E146 - /usr/bin/xcodebuild
Help would be very much appreciated !
@roaringUnicorn Do you, by any chance, use react-native run-ios instead of running your app via Xcode? 🙂
I got The following build commands failed:
Ld /Users/xyz/Library/Developer/Xcode/DerivedData/token-ffxxblbzilscbfeohrkmvhaiupoa/Build/Products/Debug-iphonesimulator/RNPermissions/RNPermissions.framework/RNPermissions normal x86_64
(1 failure) when I use react-native run-ios. And I have cleaned the cache by npx react-native clean-project-auto before running
@XuNeal npx react-native clean-project will not delete the DerivedData files. Uninstall the app, delete rm -rf /Users/xyz/Library/Developer/Xcode/DerivedData/token-ffxxblbzilscbfeohrkmvhaiupoa.
@zoontek Tried as you commented, still get the same error like @XuNeal .
And when I build via Xcode, get the error like @roaringUnicorn .
Then I remove pre_install part, it builds successfully, but
#if RCT_DEV
if ([available count] == 0) {
NSMutableString *message = [NSMutableString new];
[message appendString:@"âš No permission handler detected.\n\n"];
[message appendString:@"• Check that you link at least one permission handler in your Podfile.\n"];
[message appendString:@"• Uninstall this app, delete your Xcode DerivedData folder and rebuild it.\n"];
[message appendString:@"• If you use `use_frameworks!`, follow the workaround guide in the project README."];
RCTLogError(@"%@", message);
}
#endif
Here I got available count is 0, although I pod some permissions in Podfile
@chezhe Submit your Podfile
CocoaPod version: 1.9
React-Native version: 0.62.1
use_frameworks!
# Convert all permissions handlers into static libraries
pre_install do |installer|
installer.pod_targets.each do |pod|
if pod.name.start_with?('Permission-')
def pod.build_type;
# Uncomment one line depending on your CocoaPods version
Pod::BuildType.static_library # >= 1.9
# Pod::Target::BuildType.static_library # < 1.9
end
end
end
end
platform :ios, '10.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'token' do
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-BluetoothPeripheral', :path => "#{permissions_path}/BluetoothPeripheral.podspec"
pod 'Permission-Calendars', :path => "#{permissions_path}/Calendars.podspec"
pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
pod 'Permission-FaceID', :path => "#{permissions_path}/FaceID.podspec"
pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec"
pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary.podspec"
pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec"
pod 'Permission-Motion', :path => "#{permissions_path}/Motion.podspec"
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true
# pod 'Yoga', :podspec => '../node_modules/react-native/ReactCommon/yoga/yoga.podspec'
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'
target 'tokenTests' do
inherit! :search_paths
end
use_native_modules!
end
# change imKeyConnector ENABLE_BITCODE
post_install do |installer|
# flipper_post_install(installer)
installer.pods_project.targets.each do |target|
# target.static_framework = true
target.build_configurations.each do |config|
# puts "#{target.name}"
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
config.build_settings['ARCHS'] = 'arm64'
config.build_settings['VALID_ARCHS'] = 'arm64'
if target.name == 'imKeyConnector'
# puts "#{config.build_settings}"
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['SWIFT_VERSION'] = '4.2'
end
# if target.name == "React"
# target.remove_from_project
# end
# # It removes React & Yoga from the Pods project, as it is already included in the main project.
# targets_to_ignore = %w(React yoga)
# if targets_to_ignore.include? target.name
# target.remove_from_project
# end
end
rnfirebase = installer.pods_project.targets.find { |target| target.name == 'RNFirebase' }
rnfirebase.build_configurations.each do |config|
config.build_settings['HEADER_SEARCH_PATHS'] = '$(inherited) ${PODS_ROOT}/Headers/Public/**'
end
end
# system("mkdir -p Pods/Headers/Public/FirebaseCore && cp Pods/FirebaseCore/FirebaseCore/Sources/Public/* Pods/Headers/Public/FirebaseCore/")
end
@chezhe Is that all? You don't use CocoaPods to install React parts?
I deleted that parts cause too long.
I added.
Got it. RNPermissions need to be statically linked too.
pre_install do |installer|
installer.pod_targets.each do |pod|
if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
def pod.build_type;
# Uncomment one line depending on your CocoaPods version
Pod::BuildType.static_library # >= 1.9
# Pod::Target::BuildType.static_library # < 1.9
end
end
end
end
@zoontek Thanks a lot! it works fine now.
Works for me too ! Thanks !
@zoontek
@XuNeal
npx react-native clean-projectwill not delete theDerivedDatafiles. Uninstall the app, deleterm -rf /Users/xyz/Library/Developer/Xcode/DerivedData/token-ffxxblbzilscbfeohrkmvhaiupoa.
That is not necessarily true, one of the best parts about react-native-clean-project is that it does exactly that, I know because I wrote that part https://github.com/pmadruga/react-native-clean-project/pull/19/files
:-)
@mikehardy Didn't know it has been added (I only remember the old behavior)! Really good to know, it will be much easier to provides support.
I was having the same issue with React Native 0.63.2.
Solution was
1 - to update my cocopods version with
sudo gem install cocoapods --pre
2 - remove the following code from my pod file
pre_install do |installer|
installer.pod_targets.each do |pod|
if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
def pod.build_type;
# Uncomment one line depending on your CocoaPods version
Pod::BuildType.static_library # >= 1.9
#Pod::Target::BuildType.static_library # < 1.9
end
end
end
end
After that, I did a pod install and everything was working again.
Had the same error on RN 0.63.3.
I _think_ I solved it by updating cocoapods.
Had the same error on RN 0.63.3.
I _think_ I solved it by updating cocoapods.
how?
Most helpful comment
Got it.
RNPermissionsneed to be statically linked too.