firebase / geofire-objc

GeoFire for Objective-C - Realtime location queries with Firebase
MIT License
436 stars 180 forks source link

clang: error: linker command failed with exit code 1 (use -v to see invocation) #89

Closed alexanderkhitev closed 5 years ago

alexanderkhitev commented 7 years ago

Hello! I'm using GeoFire (2.0.0) in the Swift project, after today's update pods when the project is going to Xcode shows clang: error: linker command failed with exit code 1 (use -v to see invocation) in the Geofire framework. Tell me, how can I fix this?

I install Geofire via Cocaopods as follows pod 'GeoFire', :git => 'https://github.com/firebase/geofire-objc.git'

Update: ld: framework not found nanopb clang: error: linker command failed with exit code 1 (use -v to see invocation)

zgosalvez commented 7 years ago

nanopb was introduced in Firebase iOS Version 4.0.4. You can set your dependency to pod 'Firebase', '4.0.3' to workaround the issue.

alexanderkhitev commented 7 years ago

Hi @zgosalvez I set

Firebase

    pod 'Firebase/Core', '~> 4.0.3'
    pod 'Firebase/Auth', '~> 4.0.3'
    pod 'Firebase/Database', '~> 4.0.3'
    pod 'Firebase/Storage', '~> 4.0.3'
    # Push notification
    pod 'Firebase/Core', '~> 4.0.3'
    pod 'Firebase/Messaging', '~> 4.0.3'

But it doesn't help me

alexanderkhitev commented 7 years ago

@zgosalvez I see this in the terminal

Using Firebase (4.0.4)
Using FirebaseAnalytics (4.0.2)
Using FirebaseAuth (4.0.0)
Using FirebaseCore (4.0.4)
Using FirebaseDatabase (4.0.0)
Using FirebaseInstanceID (2.0.0)
Using FirebaseMessaging (2.0.0)
Using FirebaseStorage (2.0.0)
Using GTMSessionFetcher (1.1.11)
Installing GeoFire 2.0.0 (was 2.0.0)
Using GoogleMaps (2.3.1)
Using GooglePlaces (2.3.1)
Using GoogleToolboxForMac (2.1.1)
zgosalvez commented 7 years ago

@alexsanderkhitev, I only altered the 'Firebase' dependency. Paste this as is, as this will tell CocoaPods to install the specific version, not a variant of it.

pod 'Firebase', '4.0.3'
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Database'
# ...
alexanderkhitev commented 7 years ago

@zgosalvez thank you so much. Interesting situation with subsequent updates, it turns out if you use Geofire it will not work to update Firebase on versions higher than 4.0.3

bdomok commented 7 years ago

You can fix this by adding nanopb as a library search path for geofire in the post_install phase. I already had to do this for GoogleToolboxForMac:

post_install do |installer|
  installer.pods_project.targets.each do |target|
  if target.name == 'GeoFire' then
    target.build_configurations.each do |config|
      config.build_settings['FRAMEWORK_SEARCH_PATHS'] = "#{config.build_settings['FRAMEWORK_SEARCH_PATHS']} ${PODS_ROOT}/FirebaseDatabase/Frameworks/ $PODS_CONFIGURATION_BUILD_DIR/GoogleToolboxForMac $PODS_CONFIGURATION_BUILD_DIR/nanopb"
      config.build_settings['OTHER_LDFLAGS'] = "#{config.build_settings['OTHER_LDFLAGS']} -framework FirebaseDatabase"
    end
  end
end
asciimike commented 7 years ago

Note that we're also planning on switching Firebase 4.x dependencies to the FirebaseCommunity Pod in #95

emido commented 7 years ago

I get the same error: clang: error: linker command failed with exit code 1 (use -v to see invocation)

But none of these solutions worked for me. Is there any other way to resolve this error?

marioqtanjr commented 7 years ago

In addition to coli88's answer, you will also need to add leveldb-library as a framework search path:

post_install do |installer|
  installer.pods_project.targets.each do |target|
  if target.name == 'GeoFire' then
    target.build_configurations.each do |config|
      config.build_settings['FRAMEWORK_SEARCH_PATHS'] = "#{config.build_settings['FRAMEWORK_SEARCH_PATHS']} ${PODS_ROOT}/FirebaseDatabase/Frameworks/ $PODS_CONFIGURATION_BUILD_DIR/GoogleToolboxForMac $PODS_CONFIGURATION_BUILD_DIR/nanopb $PODS_CONFIGURATION_BUILD_DIR/leveldb-library"
      config.build_settings['OTHER_LDFLAGS'] = "#{config.build_settings['OTHER_LDFLAGS']} -framework FirebaseDatabase"
    end
  end
end
morganchen12 commented 5 years ago

Closing since this has staled. If you're still having build issues, please open a new issue and I'll address it.