CocoaPod with debug only dependency fails on xcodebuild - ios

I am working on a private iOS Swift CocoaPod which is supposed to be used for DEBUG builds only. It uses one other CocoaPod as a dependency, which should also be included for DEBUG only. All code in the source files that use this dependency are inside the if #DEBUG swift flag, To achieve this I added it to my PodSpec with the following line:
s.dependency 'OHHTTPStubs/Swift', '~> 9.0', :configurations => :debug
However when I run pod lib lint it fails on Building with `xcodebuild`. step, when I run the lint with --verbose argument I get the following result:
ld: framework not found OHHTTPStubs
clang: error: linker command failed with exit code 1 (use -v to see invocation)
warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')
** BUILD FAILED **
The following build commands failed:
Ld /Users/<username>/Library/Developer/Xcode/DerivedData/App-dvhxmheoxqefvffloemufugtmpli/Build/Products/Release-iphonesimulator/<cocoapod_name>/<cocoapod_name>.framework/<cocoapod_name> normal
(1 failure)
When I don't include , :configurations => :debug argument everything works as expected, however when I then add my CocoaPod to my iOS project, this will include the OHHTTPStubs framework in release builds, even when I add my CocoaPod with the , :configurations => :debug argument in the Podfile of my iOS project.

Related

Setting up Google SSO with Podfile in Swift

I am trying to set up Google SSO.
My Podfile looks like this:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Recreation-iOS' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for Google SSO
pod 'GoogleSignIn'
# Pods for Recreation-iOS
target 'Recreation-iOSTests' do
inherit! :search_paths
# Pods for testing
end
target 'Recreation-iOSUITests' do
# Pods for testing
end
end
Then in Terminal I ran pod install from inside the repo, but I get an error when I run it:
[!] Oh no, an error occurred.
Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.0%2Flib%2Fffi_c.bundle%2C+0x0009%29%3A+missing+compatible+arch+in+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.0%2Flib%2Fffi_c.bundle+-+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.0%2Flib%2Fffi_c.bundle&type=Issues
If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new
Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md
Don't forget to anonymize any private data!
Looking for related issues on cocoapods/cocoapods...
- missing compatible arch in ...
https://github.com/CocoaPods/CocoaPods/issues/10541 [open] [3 comments]
4 weeks ago
- I got error when doing pod install, something to do with M1 chip
https://github.com/CocoaPods/CocoaPods/issues/10569 [open] [2 comments]
a week ago
- CocoaPods compatibility with Apple DTK (Apple Silicon)
https://github.com/CocoaPods/CocoaPods/issues/9907 [open] [105 comments]
a day ago
and 3 more at:
https://github.com/cocoapods/cocoapods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.0%2Flib%2Fffi_c.bundle%2C%200x0009%29%3A%20missing%20compatible%20arch%20in%20%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.0%2Flib%2Fffi_c.bundle%20-%20%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.0%2Flib%2Fffi_c.bundle&type=Issues&utf8=✓
[!] Automatically assigning platform `iOS` with version `14.0` on target `Recreation-iOS` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`
This error message is not descriptive, so I don't know where to go from here.
--
EDIT: I tried the suggestion below and it seemed to work, but I still cannot get it to compile. Am getting this error now:
linker command failed with exit code 1 (use -v to see invocation)
----------------------------------------
SchemeBuildError: Failed to build the scheme "Recreation-iOS"
linker command failed with exit code 1 (use -v to see invocation)
Build target Recreation-iOS:
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the Recreation-iOS editor. (in target 'Recreation-iOS' from project 'Recreation-iOS')
Link Recreation-iOS (arm64):
ld: warning: directory not found for option '-F/Users/mycomputer/Library/Developer/Xcode/DerivedData/Recreation-iOS-dkyyujebjzhwjjayuxvhtjejkuie/Build/Intermediates.noindex/Previews/Recreation-iOS/Products/Debug-iphonesimulator/AppAuth'
ld: warning: directory not found for option '-F/Users/mycomputer/Library/Developer/Xcode/DerivedData/Recreation-iOS-dkyyujebjzhwjjayuxvhtjejkuie/Build/Intermediates.noindex/Previews/Recreation-iOS/Products/Debug-iphonesimulator/GTMAppAuth'
ld: warning: directory not found for option '-F/Users/mycomputer/Library/Developer/Xcode/DerivedData/Recreation-iOS-dkyyujebjzhwjjayuxvhtjejkuie/Build/Intermediates.noindex/Previews/Recreation-iOS/Products/Debug-iphonesimulator/GTMSessionFetcher'
ld: framework not found AppAuth
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run custom shell script '[CP] Embed Pods Frameworks':
mkdir -p /Users/mycomputer/Library/Developer/Xcode/DerivedData/Recreation-iOS-dkyyujebjzhwjjayuxvhtjejkuie/Build/Intermediates.noindex/Previews/Recreation-iOS/Products/Debug-iphonesimulator/Recreation-iOS.app/Frameworks
/Users/mycomputer/Documents/Git/Recreation-iOS/Pods/Target Support Files/Pods-Recreation-iOS/Pods-Recreation-iOS-frameworks.sh: line 42: source: unbound variable
Command PhaseScriptExecution failed with a nonzero exit code
There's a link in the 3rd line of the error message. Following it led to a page with the search string:
dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0/lib/ffi_c.bundle, 0x0009): missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0/lib/ffi_c.bundle - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0/lib/ffi_c.bundle
Googling "missing compatible arch" and "2.6.0" led me to this answer (https://github.com/CocoaPods/CocoaPods/issues/10220#issuecomment-730963835):
sudo arch -x86_64 gem install ffi
Then
arch -x86_64 pod install

Build error with bit code enabled; ld: -bundle and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together

I have a pod project, containing an example that demonstrates the usage of the pod. The bitcode enabled setting is set to yes, both on the example and Pod targets. The following is the Podfile of the example:
use_frameworks!
platform :ios, '10.0'
target 'MyPod_Example' do
pod 'MyPod', :path => '../'
target 'MyPod_Tests' do
inherit! :search_paths
end
end
The example app runs well on the Simulator, but while trying to run it on an iPhone 6S, I get the following build error:
ld: -bundle and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
clang: error: linker command failed with exit code 1 (use -v to see invocation).
How do I fix this?
Another project that I have that has the same pod, but downloads the pod from its repo works fine on iPhone, with bitcode enabled. The following shows the Podfile structure of the app that works:
source '<my pod spec repo>'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
target 'MyPodTest' do
use_frameworks!
# Pods for MyPodTest
pod 'MyPod'
target 'MyPodTestTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyPodTestUITests' do
inherit! :search_paths
# Pods for testing
end
end
The -bitcode_bundle flag being passed to ld is described in the error message ("Xcode setting ENABLE_BITCODE=YES"), but the -bundle flag is not, which can make this confusing and hard to debug.
If you look at the lines preceding this error, you will likely see two important ones:
WriteAuxiliaryFile /Users/YOURUSER/Library/Developer/Xcode/DerivedData/YOURPROJECT-xxxxx/Build/Intermediates.noindex/YOURPROJECT.build/Release-SDK/TARGET.build/DerivedSources/TARGET_vers.c (in target 'TARGET' from project 'YOURPROJECT')
CompileC /Users/YOURUSER/Library/Developer/Xcode/DerivedData/YOURPROJECT-xxxxx/Build/Intermediates.noindex/YOURPROJECT.build/Release-SD/TARGET.build/Objects-normal/arm64/TARGET_vers.o /Users/YOURUSER/Library/Developer/Xcode/DerivedData/YOURPROJECT-xxxxx/Build/Intermediates.noindex/YOURPROJECT.build/Release-SDK/TARGET.build/DerivedSources/TARGET_vers.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'TARGET' from project 'YOURPROJECT')
These two lines are the real meat of your problem. Your bundle, which formerly had no binary files in it (only PNGs, XIBs, and other resources), now has a binary file. One that was created by Xcode. Because this binary was created as part of a resource bundle target, it's compiled as a CFBundleExecutable using the -bundle flag, which is incompatible with ENABLE_BITCODE. Instead of disabling bitcode, though, you should prevent this binary from being generated in the first place.
This binary is being created by Apple Generic Versioning. To get rid of it, go to your build settings tab (on your resource bundle target), click the "all" button to see all settings, then search for "versioning system". Change this from "Apple Generic" to "None". Resource bundles do not properly support versioning.

Firebase.h file not found with CocoaPods

I am trying to add Firebase into my project. I just added below pods into my Xcode project.
pod 'Firebase'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'Firebase/Database'
pod 'Firebase/Auth'
After installing podfile, I try to import firebase into my project. But it gives me an error that Firebase.h is not found.
Above issue will occur when I uncheck the Run script only when installing from [CP] Check pods Manifest.lock. After that I will installed pod using pod install. And then issue will occur.
Error which I got after uncheck the checkbox:
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
I had the same issues on my project,
I wrote manually link the project and its libraries to solve the problem I followed this link steps it worked
https://github.com/invertase/react-native-firebase-docs/blob/master/docs/installation/ios.md
Also, you must check you link binary with libraries on your Xcode project.
Another solution you can delete all pod depend on libs then you pod init
add manual pod libs after pod install
I am having the same error when I execute, on command line, "cordova build ios --release --device" and I am sure the compilation is using the .xcworkspace file. When I build the project from xCode is working ok.
Cordova version: 8.0.0 and 9.0.0
Ionic: 1.0.0
cordova-android: ^8.1.0
cordova-ios: ^5.1.1
This is the log ...
Checking config.xml for pods.
No new pods detects
Reading build config file: /mobile/build.json
Building project: /mobile/platforms/ios/MyProject.xcworkspace
Configuration: Release
Platform: device
Target:
Adding xcodebuildArg: -UseModernBuildSystem=0
Running command: xcodebuild -workspace MyProject.xcworkspace -scheme MyProject -configuration Release -destination generic/platform=iOS -archivePath MyProject.xcarchive archive CONFIGURATION_BUILD_DIR=/mobile/platforms/ios/build/device SHARED_PRECOMPS_DIR=/mobile/platforms/ios/build/sharedpch -UseModernBuildSystem=0
User defaults from command line:
IDEArchivePathOverride = /mobile/platforms/ios/MyProject.xcarchive
UseModernBuildSystem = 0
Build settings from command line:
CONFIGURATION_BUILD_DIR = /mobile/platforms/ios/build/device
SHARED_PRECOMPS_DIR = /mobile/platforms/ios/build/sharedpch
Prepare build
note: Using legacy build system
...
/mobile/platforms/ios/MyProject/Plugins/cordova-plugin-fcm-with-dependecy-updated/FCMPlugin.m:7:9: fatal error:
'Firebase.h' file not found
#import "Firebase.h"
^~~~~~~~~~~~
1 error generated.
** ARCHIVE FAILED **
The following build commands failed:
CompileC /Users/myUser/Library/Developer/Xcode/DerivedData/MyProject-dwfxupwwzcbssmamqfftsijvblyb/Build/Intermediates.noindex/ArchiveIntermediates/MyProject/IntermediateBuildFilesPath/MyProject.build/Release-iphoneos/MyProject.build/Objects-normal/armv7/FCMPlugin.o MyProject/Plugins/cordova-plugin-fcm-with-dependecy-updated/FCMPlugin.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
(node:8380) UnhandledPromiseRejectionWarning: Error: xcodebuild: Command failed with exit code 65
at ChildProcess.whenDone (/mobile/node_modules/cordova-common/src/superspawn.js:135:23)
at ChildProcess.emit (events.js:197:13)
at maybeClose (internal/child_process.js:984:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
(node:8380) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8380) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

ld: library not found for -lCocoaLumberjack

I updated pods for SalesforceSDKCore 4.3.1 and SalesforceRESTApi 4.3.1. When I did pod install it in turn installed cocoaLumberjack library which is a dependent library I suppose. After successful install of Pods, I couldn't build successfully, as I am getting this error -
ld: library not found for -lCocoaLumberjack
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I deleted my Library search paths, added/deleted inerited in Other linker Flags, nothing seem to work. These are my search path and other linker flag settings.
My Pod file -
# platform :ios, '8.0'
target 'Custom' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for Custom
source 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS-Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
pod 'SalesforceSDKCore'
pod 'XMLDictionary', '~> 1.4'
pod 'SalesforceNetwork'
pod 'SmartStore'
pod 'SmartSync'
end
I had the same problem. I tried many solutions, some of them are:
File/Workspace Settings/Derived Data Arrow -> Delete DerivedData folder, empty trash
Terminal -> pod deintegrate , pod install
If you renamed your target's name, then:
Target/Build Settings/Test Host :: $(BUILT_PRODUCTS_DIR)/TargetName.app/TargetName
I really hate this linker command failed problem. I get it all the time and every time I need to follow another solution to solve this. I must have given over 30 hours of my life to this s#$t.

how to add cocos2d together with AFNetworking in Xcode

My project start with cocos2d v3 and run smooth. However, when I add AFNetworking to my project,
the problem
"ld: library not found for -lPods-AFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)" happen.
I used pod install and pod file is
platform :ios, ‘7.0’
pod 'AFNetworking', '~> 2.0'
during the installing, below messages show out
[!] The abc [Debug] target overrides the HEADER_SEARCH_PATHS build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
[!] The abc [Release] target overrides the HEADER_SEARCH_PATHS build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
so I go to project->target->build setting-> header search paths and put $(inherited) inside, then it can install success.
However, the cocos2d library wasn't call. So I go to Pods.debug.xcconfig and Pods.release.xcconfig to add
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "$(SRCROOT)/$(PROJECT_NAME)/Libraries/kazmath/include" "$(SRCROOT)/$(PROJECT_NAME)/Libraries/Chipmunk/chipmunk/include" "$(SRCROOT)/$(PROJECT_NAME)/Libraries/Chipmunk/objectivec/include"
finally the problem "ld: library not found for -lPods-AFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)" still happen.
Are the above steps not correct? Or is there any other way to add cocos2d and AFNetworking together? Thank you.

Resources