Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios - linking error #19

Closed
crazyhappygame opened this issue Jul 24, 2019 · 6 comments

Comments

@crazyhappygame
Copy link

commented Jul 24, 2019

What library should be linked to fix below error?
xcode: 10.3
macos: 10.14.5

I would like to stay with command line and cmake and do not use CocoaPods and open xcode.

In documentation I see "Integrate without CocoaPods"
https://firebase.google.com/docs/ios/setup#frameworks

This is my cmake:

# Add Firebase libraries to the target using the function from the SDK.
add_subdirectory(${EXTERNAL_DIR}/firebase_cpp_sdk bin/ EXCLUDE_FROM_ALL)

# The core Firebase library (firebase_app) is required to use any Firebase product,
# and it must always be listed last.
target_link_libraries(${PROJECT_NAME}
    firebase_analytics
    firebase_remote_config
    firebase_app)

Error:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_FIROptions", referenced from:
      objc-class-ref in firebase(app_ios_814e1620d4f88024cea4bade26623a67.o)
  "_OBJC_CLASS_$_FIRConfiguration", referenced from:
      objc-class-ref in firebase(log_ios_dd26aec5b8537064a4c15d38b58b4640.o)
  "_OBJC_CLASS_$_FIRRemoteConfigSettings", referenced from:
      objc-class-ref in firebase_remote_config(remote_config_ios_e6d2ed559f32c182ac8412737f5fb36a.o)
  "_OBJC_CLASS_$_FIRRemoteConfig", referenced from:
      objc-class-ref in firebase_remote_config(remote_config_ios_e6d2ed559f32c182ac8412737f5fb36a.o)
  "_OBJC_CLASS_$_FIRApp", referenced from:
      objc-class-ref in firebase(app_ios_814e1620d4f88024cea4bade26623a67.o)
  "_OBJC_CLASS_$_FIRAnalytics", referenced from:
      objc-class-ref in libfirebase_analytics.a(analytics_ios_d28a0e676a7367b8f2d91944bb505d87.o)
  "_FIRRemoteConfigThrottledEndTimeInSecondsKey", referenced from:
      ____ZN8firebase13remote_config5FetchEy_block_invoke in firebase_remote_config(remote_config_ios_e6d2ed559f32c182ac8412737f5fb36a.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@crazyhappygame

This comment has been minimized.

Copy link
Author

commented Jul 24, 2019

@dantti

This comment has been minimized.

Copy link

commented Jul 24, 2019

if your try with CMake gave the same link error then I have no idea of what else to try...

@chkuang-g chkuang-g added the type: bug label Jul 27, 2019

@frankosterfeld

This comment has been minimized.

Copy link

commented Jul 31, 2019

You might miss the native FirebaseIOS libs which the firebase-cpp-sdk wraps. I also had to tell QMake LIBS += -ObjC to make it link the objective C libs properly, otherwise app (or storage?) initialization failed at runtime.

@dantti

This comment has been minimized.

Copy link

commented Aug 1, 2019

Thanks, I've put the app on hold, as I have another more important ATM, but probably next week I'll try, I didn't know the cpp sdk was a wrap around the Firebase IOS libs, I think this is a bit confusing due "supported" way being using cocoa pods..

@patm1987

This comment has been minimized.

Copy link

commented Aug 19, 2019

Hi @crazyhappygame,

I'm poking around a little at your issue, and just want to ask a few more questions if possible.

It looks like you're following the instructions on https://firebase.google.com/docs/ios/setup#frameworks, but only using the firebase-cpp SDK. The former actually links to this additional zip file to pull down: https://firebase.google.com/download/ios

I will say that, without seeing your entire CMakeLists.txt I may be making incorrect assumptions, so thank you for your patience if I say something totally out of left field.

First, I don't see any -framework calls as mentioned here: https://stackoverflow.com/questions/27585896/how-to-use-framework-using-cmake, although this may just work for system dependencies. The frameworks included in the download link I provided above includes a lot of the native hooks required by Firebase to integrate well with iOS. If you don't wish to use cocoapods, you should pull in the native iOS framework dependencies in whichever way your build pipeline permits.

I'm assuming that the plugins you want are Remote Config and Analytics. If you're following the iOS instructions for not using cocoapods, the Readme.md lists:

## RemoteConfig (~> Analytics)
- FirebaseABTesting.framework
- FirebaseRemoteConfig.framework
- Protobuf.framework

and

## Analytics
- FIRAnalyticsConnector.framework
- FirebaseAnalytics.framework
- FirebaseCore.framework
- FirebaseCoreDiagnostics.framework
- FirebaseInstanceID.framework
- GoogleAppMeasurement.framework
- GoogleDataTransport.framework
- GoogleDataTransportCCTSupport.framework
- GoogleUtilities.framework
- nanopb.framework

as the frameworks you'll need.

Once you have all of those, the C++ SDK should function correctly on iOS. These are a lot of dependencies, which is why cocoapods is so handy in this case.

I'm sure you've found it, but there is a good example project here: https://github.com/firebase/quickstart-cpp/tree/master/remote_config/testapp
It does use CocoaPods to manage the dependencies I listed above, but it might shed some light on how to setup a C++ project on iOS

Let me know if that helps at all,
--Patrick

@crazyhappygame

This comment has been minimized.

Copy link
Author

commented Sep 7, 2019

@patm1987 thank you for explanation. It was really helpful!
Finally I successfully build my project with CMake only.

In deed linker error are because I did not link against libraries from:
https://firebase.google.com/download/ios

@dantti you have to additionally download https://firebase.google.com/download/ios and link proper frameworks.

@stewartmiles I think that below section should be updated for CMake and iOS:
https://github.com/firebase/firebase-cpp-sdk/blob/master/README.md#including-in-projects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.