Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

source: unbound variable error when using Cocoapods for Firebase

I have integrated Firebase and GoogleTagManager into my iOS app target using Cocoapods. When I build my target, Xcode constantly gives me error:


Showing Recent Messages
PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks 

mkdir -p /Users/xxx.xxx/Library/Developer/Xcode/DerivedData/MyApp-enzvpdzsyhjszqbnwiclnpszlyri/Build/Products/Debug-iphonesimulator/MyApp.app/Frameworks


/Users/xxx.xxx/Projects/MyApp/Applications/MyApp/Pods/Target Support Files/Pods-MyApp/Pods-MyApp-frameworks.sh: line 43: source: unbound variable


Command /bin/sh failed with exit code 1

I've cleaned my project multiple times, deleted the derived data folder but none of these seem to work.

My Podfile looks like this:

platform :ios, '11.0'

target 'MyApp' do

  use_frameworks!

  # Pods for MyApp
    pod 'Firebase/Core', '~> 5.19'
    pod 'Firebase/ABTesting'
    pod 'Firebase/Performance'
    pod 'Firebase/RemoteConfig'
    pod 'Firebase/Analytics'
    pod 'GoogleTagManager', '~> 7.1'
 end

Cocoapods Environment

CocoaPods : 1.5.3
        Ruby : ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
    RubyGems : 2.6.8
        Host : Mac OS X 10.14 (18A391)
       Xcode : 10.1 (10B61)
         Git : git version 2.17.2 (Apple Git-113)
Ruby lib dir : /Users/xxx.xxx/.rbenv/versions/2.4.0/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 7c9a708dce25221eabc35ed39

What is it that I am missing in my project settings that is causing this error ?

I have spent several days looking for a solution on SO / Cocoapods but in vain.

Any help in this regards would be really appreciated.

Thanks

like image 621
Tas Avatar asked May 03 '19 07:05

Tas


1 Answers

I had the same issue when my framework was built with M1 chip. I was able to resolve that by removing ONLY_ACTIVE_ARCH from the Podfile installer section.

So I replaced this:

post_install do |installer|

installer.pods_project.targets.each do |target|

target.build_configurations.each do |config|
  config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
  config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'

 end
end

With this:

post_install do |installer|

installer.pods_project.targets.each do |target|

target.build_configurations.each do |config|
  config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
 end
end

Note: I added ['ONLY_ACTIVE_ARCH'] = 'NO' from the beginning in order to run my app in simulator with the "problematic" framework when the framework was built with non M1 chip. So I still need this line depending on the chip of the build machine.

like image 63
EdiZ Avatar answered Nov 09 '22 07:11

EdiZ