5

I've recently added https://github.com/chemerisuk/cordova-plugin-firebase-messaging to my cordova project which has a framework dependency on

    <framework src="Firebase/Core" type="podspec" spec="~> 5.0"/>
    <framework src="Firebase/Messaging" type="podspec" spec="~> 5.2"/>

I was originally testing code and everything on Android and it works like a charm.

However, upon switching my efforts to test my changes on iOS I quickly ran into some issues when running cordova run android or any other build commands. They tend to fail with errors alluding to CocoaPods Linking issues. Such as:

platforms/ios/Pods/FirebaseCore/Firebase/Core/FIRNetwork.m:23:9: 
    fatal error: 'GoogleToolboxForMac/GTMNSData+zlib.h' file not found
#import <GoogleToolboxForMac/GTMNSData+zlib.h>

I have found various SO posts that mention to fix the Search Paths or to modify the .m files to reference the relative paths (which is a terrible idea and far too much work).

But here's the issue, I know the project is correct. If I open my .xcworkspace and run it from XCode it works perfectly! It only has issues when running from the commandline.

Installed platforms:
android 7.1.0
ios 4.5.5

$ cordova -version
8.0.0

Xcode 9.4.1
Build version 9F2000

$ pod --version
1.5.3

I am completely at a loss. Any help would be greatly appreciated!

My Podfile in case it helps

# DO NOT MODIFY -- auto-generated by Apache Cordova
platform :ios, '8.0'
target 'VeociSTAGE' do
        project 'VeociSTAGE.xcodeproj'
        pod 'Firebase/Core', '~> 5.0'
        pod 'Firebase/Messaging', '~> 5.2'
        pod 'GoogleToolboxForMac', '~> 2.1.4'
end

EDIT:

Podfile.lock

PODS:
  - Firebase/Core (5.2.0):
    - Firebase/CoreOnly
    - FirebaseAnalytics (= 5.0.1)
  - Firebase/CoreOnly (5.2.0):
    - FirebaseCore (= 5.0.3)
  - Firebase/Messaging (5.2.0):
    - Firebase/CoreOnly
    - FirebaseMessaging (= 3.0.2)
  - FirebaseAnalytics (5.0.1):
    - FirebaseCore (~> 5.0)
    - FirebaseInstanceID (~> 3.0)
    - "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
    - nanopb (~> 0.3)
  - FirebaseCore (5.0.3):
    - "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
  - FirebaseInstanceID (3.1.0):
    - FirebaseCore (~> 5.0)
  - FirebaseMessaging (3.0.2):
    - FirebaseCore (~> 5.0)
    - FirebaseInstanceID (~> 3.0)
    - GoogleToolboxForMac/Logger (~> 2.1)
    - Protobuf (~> 3.1)
  - GoogleToolboxForMac (2.1.4):
    - GoogleToolboxForMac/Core (= 2.1.4)
    - GoogleToolboxForMac/Defines (= 2.1.4)
    - GoogleToolboxForMac/GeometryUtils (= 2.1.4)
    - GoogleToolboxForMac/KVO (= 2.1.4)
    - GoogleToolboxForMac/Logger (= 2.1.4)
    - "GoogleToolboxForMac/NSData+zlib (= 2.1.4)"
    - "GoogleToolboxForMac/NSDictionary+URLArguments (= 2.1.4)"
    - "GoogleToolboxForMac/NSFileHandle+UniqueName (= 2.1.4)"
    - "GoogleToolboxForMac/NSScanner+JSON (= 2.1.4)"
    - "GoogleToolboxForMac/NSString+HTML (= 2.1.4)"
    - "GoogleToolboxForMac/NSString+URLArguments (= 2.1.4)"
    - "GoogleToolboxForMac/NSString+XML (= 2.1.4)"
    - "GoogleToolboxForMac/NSThread+Blocks (= 2.1.4)"
    - GoogleToolboxForMac/Regex (= 2.1.4)
    - GoogleToolboxForMac/StringEncoding (= 2.1.4)
    - GoogleToolboxForMac/SystemVersion (= 2.1.4)
    - GoogleToolboxForMac/URLBuilder (= 2.1.4)
  - GoogleToolboxForMac/Core (2.1.4):
    - GoogleToolboxForMac/Defines (= 2.1.4)
  - GoogleToolboxForMac/DebugUtils (2.1.4):
    - GoogleToolboxForMac/Defines (= 2.1.4)
  - GoogleToolboxForMac/Defines (2.1.4)
  - GoogleToolboxForMac/GeometryUtils (2.1.4):
    - GoogleToolboxForMac/Defines (= 2.1.4)
  - GoogleToolboxForMac/KVO (2.1.4):
    - GoogleToolboxForMac/Core (= 2.1.4)
    - GoogleToolboxForMac/DebugUtils (= 2.1.4)
  - GoogleToolboxForMac/Logger (2.1.4):
    - GoogleToolboxForMac/Defines (= 2.1.4)
  - "GoogleToolboxForMac/NSData+zlib (2.1.4)":
    - GoogleToolboxForMac/Defines (= 2.1.4)
  - "GoogleToolboxForMac/NSDictionary+URLArguments (2.1.4)":
    - GoogleToolboxForMac/DebugUtils (= 2.1.4)
    - GoogleToolboxForMac/Defines (= 2.1.4)
    - "GoogleToolboxForMac/NSString+URLArguments (= 2.1.4)"
  - "GoogleToolboxForMac/NSFileHandle+UniqueName (2.1.4)":
    - GoogleToolboxForMac/Defines (= 2.1.4)
  - "GoogleToolboxForMac/NSScanner+JSON (2.1.4)":
    - GoogleToolboxForMac/Defines (= 2.1.4)
  - "GoogleToolboxForMac/NSString+HTML (2.1.4)":
    - GoogleToolboxForMac/Core (= 2.1.4)
  - "GoogleToolboxForMac/NSString+URLArguments (2.1.4)"
  - "GoogleToolboxForMac/NSString+XML (2.1.4)":
    - GoogleToolboxForMac/Defines (= 2.1.4)
  - "GoogleToolboxForMac/NSThread+Blocks (2.1.4)":
    - GoogleToolboxForMac/Defines (= 2.1.4)
  - GoogleToolboxForMac/Regex (2.1.4):
    - GoogleToolboxForMac/Defines (= 2.1.4)
  - GoogleToolboxForMac/StringEncoding (2.1.4):
    - GoogleToolboxForMac/Defines (= 2.1.4)
  - GoogleToolboxForMac/SystemVersion (2.1.4):
    - GoogleToolboxForMac/Defines (= 2.1.4)
  - GoogleToolboxForMac/URLBuilder (2.1.4):
    - GoogleToolboxForMac/Core (= 2.1.4)
    - GoogleToolboxForMac/Defines (= 2.1.4)
    - "GoogleToolboxForMac/NSDictionary+URLArguments (= 2.1.4)"
    - "GoogleToolboxForMac/NSString+URLArguments (= 2.1.4)"
  - nanopb (0.3.8):
    - nanopb/decode (= 0.3.8)
    - nanopb/encode (= 0.3.8)
  - nanopb/decode (0.3.8)
  - nanopb/encode (0.3.8)
  - Protobuf (3.6.0)

DEPENDENCIES:
  - Firebase/Core (~> 5.0)
  - Firebase/Messaging (~> 5.2)
  - GoogleToolboxForMac (~> 2.1.4)

SPEC REPOS:
  https://github.com/cocoapods/specs.git:
    - Firebase
    - FirebaseAnalytics
    - FirebaseCore
    - FirebaseInstanceID
    - FirebaseMessaging
    - GoogleToolboxForMac
    - nanopb
    - Protobuf

SPEC CHECKSUMS:
  Firebase: 25ed0412036d7d008568d1fb4d2e9d81ea8a0a2c
  FirebaseAnalytics: b3628aea54c50464c32c393fb2ea032566e7ecc2
  FirebaseCore: a3c87242451633fff8490183898075ce77d168d2
  FirebaseInstanceID: 05d779cbb97bd5bd5c51a38a903fc9cfe1b2454a
  FirebaseMessaging: 6894b8fe0a0cf26c3b13dad729f1131654ae0bdb
  GoogleToolboxForMac: 91c824d21e85b31c2aae9bb011c5027c9b4e738f
  nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
  Protobuf: 0fc0ad8bec688b2a3017a139953e01374fedbd5f

PODFILE CHECKSUM: 6a610b85e4adb104d20d7784dc2566b45be5418c

COCOAPODS: 1.5.3

EDIT

Here's the interesting thing I just ran xcodebuild -workspace Project.xcworkspace -scheme Project and it built successfully. I have a feeling that cordova is targeting the .xcodeproj as opposed to .xcworkspace. More investigation to come...

EDIT It's not targeting the xcodeproj and it is targeting the xcworkspace but there seems to be an issue with the .xcconfig that is specified in platforms/ios/cordova/lib/build.js

James Gilchrist
  • 2,242
  • 3
  • 20
  • 35

3 Answers3

1

This is a known issue.

The problem seems to be related to cordova build command using -xcconfig flag and that flag is causing the problems for some unknown reason. It's being investigated at the moment.

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
0

If I were you, I would try the following -

  1. Do you think the pods are installing as expected? I would create a after_prepare hook with pod install --project-directory=platforms/ios/ or pod install --project-directory=platforms/android/ based on platform.

  2. I observed that the Xcode fails though the pods are installed and everything in place. so, I would try a clean state.

    • Remove node modules
    • Remove plugins folder
    • Remove platform folders: ios and android
    • install node modules/ bower dependencies
    • Add platform folders back.
0

I found that the lib/build.js will run this command behind the sense:

xcodebuild -workspace <app_name>.xcworkspace -scheme <app_name> -configuration Debug -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 12 Pro Max" build CONFIGURATION_BUILD_DIR=/path/to/project/platforms/ios/build/emulator SHARED_PRECOMPS_DIR=/path/to/project/platforms/ios/build/sharedpch

If I remove the bold code line build CONFIGURATION_BUILD_DIR=/path/to/project/platforms/ios/build/emulator SHARED_PRECOMPS_DIR=/path/to/project/platforms/ios/build/sharedpch, it builds succeed. Not sure why?

Dustin Le
  • 91
  • 1
  • 4