Linker error when launching tests after a Project Clean with cocoapods - objective-c

I've recently adopted cocoapods in my project, and everything seems to work fine except for a small annoying thing.
Before cocoapods, hitting cmd+u would have compiled my entire project and run tests; after adding cocoapods if I hit cmd+u after a project clean (Product->clean or shift+cmd+k) I receive a linker error, precisely:
//{Path_To_My_app} is the path to my app's folder and {MyAppName} is my app's name
ld: file not found: /Users/my_name/{Path_To_My_app}/Build/Products/Debug- iphonesimulator/{MyAppName}.app/{MyAppName}
clang: error: linker command failed with exit code 1 (use -v to see invocation)
to make it work I have to build it first and than hit cmd+u.
To be precise I can't remember if this was so before, but I'm pretty sure it wasn't...I can't seem to understand why this happens, and why hitting "cmd+u" is not building the project and than running the tests.
EDIT
I have specified in my podfile to add some pods just to my test target, so it is like:
platform :ios, "7.0"
pod 'SVProgressHUD', :head
pod 'GoogleAnalytics-iOS-SDK', '~> 3.0.7'
pod 'TestFlightSDK', '~> 3.0.2'
target "MyTestTarget" do
pod 'OCMock', '~> 2.2.4'
end

Related

Xcode builds successfully a corrupted archive, not showing in organizer, as soon as cocoapods installs react-native-mapbox-gl from Podfile

The problem seems not new, as here, but the solutions proposed didn't work.
I tried also several other approaches to understand what's going on (see here).
To replicate, this is the process:
I have a working iOS App written in Swift.
I follow the description to integrate this app with Native React this procedure
I add to the package.json the following dependencies, and run yarn install:
"#react-native-mapbox-gl/maps":"^8.1.0-rc.9",
"prop-types": "^15.6.2",
I run pod install --repo-update and Archive on Xcode.
OUTPUT: At this point the organizer displays my Archive.
I implement a basic view on mapbox following this procedure
I add to the Podfile requiring use_framework!, as described here or after use_framework!, no difference in the result after I hit pod install --repo-update.
I hit Archive on Xcode.
OUTPUT: the archive is generated successfully, but doesn't show up on the organizer. If I try to open it, the archive is corrupted.
If I remove the pod file of mapbox and I Archive the project after hitting pod install --repo-update, the archive works and shows up in the organizer. Here the same description.
The project runs both as debug and release on a real iPhone 8. Mapbox works well. However, it doesn't work on simulator, nor archive. I can leave with the former, but I can't push on App store because of the latter.
I would not give up as Mapbox is very nice and provides lots of features. What could it be?
SOLUTION :
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.9.3
rm Podfile.lock
rm -rf Pods
pod install
LAST MESSAGES :
Same here. Impossible to find any solution.
Xcode is building a incomplete archive file. (By incomplete, I mean that in the archive package, some files are missing, like info.plist)
If this can help, I'm using MapboxGL too.
Edit :
Found this https://github.com/react-native-mapbox-gl/maps/issues/1097#issuecomment-725689831
Edit 2:
This link was the solution !
I got the exact same problem with :
#react-native-mapbox-gl/maps": "8.1.0"
COCOAPODS: 1.10.1
Xcode 12.4
The archive was corrupted (missing parts like the plist)
The trick for me was to remove the copy dsym build phase of the #react-native-mapbox-gl-mapbox-static pod
This phase was causing build failure with some config and malformed archive with others, I don't really get the crux of the problem but may be it can help some of you...
It looks like mapbox issue. I had the same issue and instead of downgrading the cocoapods I used this solution:
Edit your package.json, set:
"#react-native-mapbox-gl/maps": "^8.2.0-beta1",
2. Run yarn install or npm install.
3. Put the code into your ios/Podfile between pre_install do |installer| and end:
$RNMBGL.pre_install(installer)
And between post_install do |installer| and end:
$RNMBGL.post_install(installer)
Run cd ios && pod install
After these steps I was able to generate to archive.

CocoaPods integration with CommandLineTool and Dylib targets

For test purposes, I created a new project in Xcode as a Command Line tool (Test), added a dylib target called Networking.
Ran the following commands
pod init
In the pod file, under the Networking Target, Removed use_frameworks!
added
pod 'AFNetworking', '~> 2.0'
pod install
After Installation, In BuildPhases of Test CLI, I added Networking dylib. Created a simple method to call AFHTTPRequestOperationManager to test out. Called this method from TestCLI by Importing Networking.h
From Xcode it builds just fine, even archive works just fine from Xcode but when I try to archive from the following command line
xcodebuild -scheme Test -configuration Production archive -archivePath Test.xcarchive
I get the following error
ld: library not found for -lAFNetworking
The following build commands failed: Ld
/Users/user/Library/Developer/Xcode/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Test/InstallationBuildProductsLocation/usr/local/lib/libNetwork.dylib
normal x86_64 (1 failure)
Any ideas why ?
Try making your build command:
xcodebuild -workspace Test.xcworkspace -scheme Test -configuration Production archive -archivePath Test.xcarchive
I think if you don't specify the workspace setting, xcodebuild would be trying to use your project, which would not contain any Pods or the paths needed for linking.

React Native Xcode build error on react-native-linear-gradient (-lBVLinearGradient)

I have followed all installation process according to the github page for react-native-linear-gradient.
But when I try to compile for ios (both through react-native run-ios command and Xcode), I get the following error:
ld: library not found for -lBVLinearGradient
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've already opened the project through xcworkspace in which most suggests so when using Cocoapods, but the error persists anyhow.
Any clue on this?
I was having the same problem after upgrading 0.62.1 and the following did the trick for me:
Switched my project to new build system (was using legacy)
Manually deleted the .xcworkspace in ios folder
Removed app from simulator (also deleted all derived data) see how
rm -rf node_modules && sudo yarn install
cd ios && pod deintegrate
pod install
Run project in xcode
This worked for me, hope it can help someone

Problems with CocoaPods GoogleCloudMessaging (Xcode 7.2)

I added GoogleCloudMessaging with CocoaPods to the project.
The file "Pods" contains the following code:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.1'
dependency 'libPusher', '1.1'
pod 'Google/CloudMessaging'
After install I had problems with library -lPods, but the problem was solved by removing the content of Build Settings -> Linkers -> Other Linkers Flags.
As result I got next error:
ld: library not found for -lCocoaAsyncSocket
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have solved the problem: it was necessary to use the
$ pod update
from the terminal

Getting error in Adjust library, Integrated with Pods

I am getting this error:
ld: library not found for -lPods-Adjust
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I added this to my Podfile:
pod 'Adjust', :git => 'git://github.com/adjust/ios_sdk.git', :tag => 'v4.2.5'
I have installed pods successfully, but still get the above error.
After running pod install, make sure that you are opening the .xcworkspace instead of the .xcproject in Xcode to be able to build and use Pods in your project.