Unable to build Project after pod init in an old xcode project - ios

I am trying to init pod in an old code base. Whatever I do, I am not able to run my project after git init. There is always build error. I am getting following error,
ld: warning: directory not found for option
'-F/Users/usr/Library/Developer/Xcode/DerivedData/MyApp-some_code/Build/Products/Debug-iphonesimulator/FBSDKCoreKit'
ld: warning: directory not found for option
'-F/Users/usr/Library/Developer/Xcode/DerivedData/MyApp-some_code/Build/Products/Debug-iphonesimulator/FBSDKShareKit'
ld: warning: directory not found for option
'-F/Users/usr/Library/Developer/Xcode/DerivedData/MyApp-some_code/Build/Products/Debug-iphonesimulator/FacebookCore'
ld: warning: directory not found for option
'-F/Users/usr/Library/Developer/Xcode/DerivedData/MyApp-some_code/Build/Products/Debug-iphonesimulator/FacebookShare'
ld: framework not found FBSDKCoreKit
Even if my dependency pod file is empty then I get
pods framework not found.
My Framework Search Paths is set to to $(inherited), which is build/Debug-iphoneos/FBSDKCoreKit.. I have also tried to set this path to pods folder under project. But nothings works. Even I have same issue with another project also.
Xcode version : 12.3
Code base is in Objective C.

I have experienced a similar problem before in the past, using FacebookSDK frameworks.
Of course, if you were using Swift, you could easily import it with Swift Package Manager.
Try to perform the following steps
1. Edit your podfile
Making explicit reference to the version and project name
pod 'FBSDKCoreKit', ‘version’ :project_name => ‘myapp’
2. Delete build data
MyApp-some_code being the appropriate folder name for your app
~/Library/Developer/Xcode/DerivedData/MyApp-some_code
3. Reinstall your pods
The command that you have probably tried a couple of times already
pod deintegrate
pod install
4. Manually add FBSDKCoreKit in Link Binary with Libraries
Navigate to Project->Targets->Build Phases->Link Binary With Libraries
From there click on the plus button and manually add the FBSDKCoreKit framework
5. Deselect copy items to destination's group folder
As per Facebook official documentation, available here.
Check out the point number 3, in particular.

Related

ld: library not found for -lASIHTTPRequest : XCode13.4

I've opened a old project, I can not able to run the code because of the following error
ld: library not found for -lASIHTTPRequest
I tried
Re Install all the pods
I Opened .WorkSpace
I Tried,
Delete Library Search Paths
I Tried, $(inhereted) in Library paths
Sometimes it happens when the pod gets updated, and the pod owner gets rid of some internal dependencies (in your case ASIHTTPRequest), but the Cocoapods fails to remove all the references to the removed dependency completely for some unknown to me reason.
In such cases you can do that manually.
Open the build settings of your target, and search for "Other Linker Flags".
Double click on it, locate ASIHTTPRequest, and remove both: that line and the line before it: "-framework".

Error - linker command failed with exit code 1

I'm new to XCode Mac and IPhone development. So probably I'm missing something obvious here.
While trying to build the project I'm getting the following warnings and error. I can't figure out what is wrong here, I've looked at this answer and checked my Framework Search Path value and there is none in BuildSettings.
ld: warning: directory not found for option '-F/Users/macbook/Desktop/<app_name>__main/build/Release-iphoneos'
ld: warning: directory not found for option '-F/Users/macbook/Desktop/<app_name>__main/build/Debug-iphoneos'
ld: framework not found Pods_<app_name>
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've been banging my head for several hours now and finally given up.
The path mentioned in the error does not exist and when I looked into where build folder is located in XCode project, I realized they are in a shared directory ~/Library/Developer/Xcode/DerivedData. So I don't understand why XCode is looking for these files in the project's relative path, where build folder doesn't exist.
I'm using
XCode 10.1
CocoasPod 1.5.3 1.8.4
MacOS High Sierra
Note: The same workspace builds successfully on another system.
Edit:
If I copy the project.pbxproj from the other system onto this one, the project on this machine builds successfully too. project.pbxproj is located under *.xcodeproj file.
Also if I select Generic iOS Device the project builds fine, but as soon as I switch to any other target device I get the same error.
Edit 2:
I see a couple of framework files in red in the left side folder/directory's panel.
Foundation.framework
Pods_<application_name>.framework
Solution:
So right now I've found a solution what I believe to be a workaround and not the actual solution.
In my project's folder structure I saw multiple .framework files in red. some of them had different extensions then the ones present in the xCode package. So I updated them with the newer extension files and that got rid of most of the red file frameworks and left just one Pods_.framework the same framework in the error above. I removed the framework from the Libraries and Framework list in the General section. After I did that project build fine and I was able to run the app.
However, I noticed the Pods_<app_name>.framework file is always regenerated after running pod install. So I have to manually remove this unwanted dependency from the list each time starting a new workspace which is pain to say the least.
And so now I'm looking for a way to correct this so I don't have to remove the Pods_<app_name>.framework file each time.
While I was searching for the solution I found a closed cocoapods bug which reported the same issue for an older version. I've lost the thread and cannot find it again otherwise I would've linked the bug.
As noted in one of the answer's comment I now have updated cocoapods version 1.8.4.
Edit 3:
Podfile
# Uncomment this line to define a global platform for your project
# platform :ios, '7.0'
# Uncomment this line if you're using Swift
use_frameworks!
target '<app_name>' do
pod 'Google-Mobile-Ads-SDK', '~> 7.39.0'
end
Based on your comment and build logs I believe the podfile Pods_<application_name> is not available to your project(its added but not downloaded).
Pods are a way to share code across projects and maintain versioning.
You just need to update the pod so that it gets downloaded and added to your project. For that just launch Terminal app, cd to your project folder and fire pod update (you may refer to https://freakycoder.com/ios-notes-12-how-to-update-pods-249ecf88fe57)
If you do not have pod installed you can head to https://guides.cocoapods.org/using/using-cocoapods.html
I used to run into that problem once but I already solved it the same way #alxlive answer and it worked.
The problem happened to me because of the pod that we already installed.
During that time, I already installed my cocoapod for my project. Then, I added 2 new Build Configurations.
Your problem might be the same because you did mention copying others project.pbxproj from other system and it made your project work fine. So that might be the case.
By deintegrate and install the pod back on, that will solve the problem.
Xcode has different build system for simulator and real devices. So it will generate different app for both. If you select any Simulator target then it will builds app for simulator and if you select Generic iOS Device or any real device target then it will builds different build.
May be you are using some frameworks which are builded for iOS devices, So
follow this steps,
Differentiate that frameworks which gives you an error and remove that pods from your pod file and run pod install command and delete DerivedData.
Download that framework's code in your system.
Add project files of framework in your workspace. For that you can refer this and this.
If you don't want to add whole code of framework in your project then you can add particular( for device or simulator ) build of framework in your xcode project.
For that follow this steps,
Open your downloaded project of framework.
Select any simulator target and build project.
Get generated .framework file from Products folder.
Add this framework in your project like this.
Now build your project for simulator.
Follow above steps for devices target if you want to build for devices.
For Google Mobile Ads you can follow this guidelines. Add the -ObjC linker flag to Other Linker Flags in your project's build settings
I hope this will work for you.
Adding -ObjC $(inherited) in the Other Linker Flags fixes my issue
For me it was due to having a space in the Configuration name like "Development Debug". Once I removed the space and made it "DevelopmentDebug", the error message went away.
The pods need to be installed once per mac. The configuration set in the project.pbxproj depends on the Cocoapods version and the Xcode version on the machine.
Try the following:
1 - Delete the Podfile.lock file and the Pods folder from the local project
2 - Delete the content of the Derived Data folder: ~/Library/Developer/Xcode/DerivedData
3 - Run the command:
pod deintegrate
4 - Run the command
pod install
5 - Run the project again

Why do I get iOS linker errors with my static libraries?

I have a problem with linking my mixed language framework to a project.
I create a framework with Swift and Objective-C classes.
The main logic was stored in the Swift file. For example the class with a method that calls NSLog("Swift log was called").
Objective-C file has a class that has a method in which I create an instance of Swift class and call Swift-log method.
I link this framework with my Objective-C project, I can call all that I need in this project, but when I want to build this project I receive error linker command failed with exit code 1 (use -v to see invocation)
And warnings:
ld: warning: Could not find auto-linked library 'swiftFoundation'
ld: warning: Could not find auto-linked library 'swiftDarwin'
ld: warning: Could not find auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find auto-linked library 'swiftCore'
ld: warning: Could not find auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find auto-linked library 'swiftObjectiveC'
ld: warning: Could not find auto-linked library 'swiftDispatch'
ld: warning: Could not find auto-linked library 'swiftSwiftOnoneSupport'
I also saw the solution with importing empty Swift-file, but it necessary to make a project without any trash.
Open ios/YourAppName.xcodeproj in Xcode
Right-click on Your App Name in the Project Navigator on the left, and click New File…
Create a single empty Swift file to the project (make sure that Your App Name target is selected when adding)
when Xcode asks, press Create Bridging Header and do not remove Swift file then.
re-run your build.
This should fix the problem
In my case it was a React-Native project after adding a Swift Pods library. Maybe just the step 2 can work:
Adding a new Swift file and a Brigde header:
1) File -> New -> File
2) Select Swift File
3) Confirm Create Bridging Header
Go to Build Settings and set Always Embed Swift Standard Libraries to YES
Apparently for pure objective-c projects you will need to add this $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) to the library search paths of your target. This worked for me when I was including a library written in swift to a project in objective-c
I have export my unity project. Earlier it was working just to add empty swift file with press create Bridging Header.
but recently i have updated my xCode to 12.3 and it stop working.
So, tried few other ways.
I have added $(SDKROOT)/usr/lib/swift to Build settings > Search paths > Library search paths.
but still it doesn't work. So, i have added in same path i.e Build settings > Search paths > Library search paths.
$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
Now it working perfect. Didn't get exact problem or solution but it works well with this way.
I just add these three in Build settings > Search paths > Library search paths.
$(SDKROOT)/usr/lib/swift
$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
Separately TOOLCHAIN_DIR directories doesn't work. If i add $(SDKROOT)/usr/lib/swift then only it work.
For XCode 11 beta 4 Library Search Paths should be:
$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
Right click project name and add a new swift file leave it as File.swift
it will ask you to create a new bridging header accept
Run the project again
Try this workaround https://stackoverflow.com/a/50495316/1658268
Basically just add a dummy swift file in your project, and re-run your build.
If you have issue after update xCode to version 12 and errors
Could not find or use auto-linked library 'swiftWebKit'
and two more.
Just addd $(SDKROOT)/usr/lib/swift to the Build settings > Search paths > Library search paths.
Hope its help :)
If your Xcode version is >=12.2
Go to
BuildSettings -> Linking -> runpath search path
and add /usr/lib/swift as your 1st argument like this:
Xcode 12.5, React Native.
Change: 'Library Search Paths' from Swift-5.0 to Swift-5.2
What worked for me in a React Native project is to move $(inherited) to the bottom of the list in Build Settings -> Library Search Paths
I've got the same errors when accidentally compiling a project with a Swift 5.0 Snapshot configured in the Xcode preferences » Components » Toolchain.
XCode 11.3 beta, Swift 5.0
I just add my targets to the podfile:
platform :ios, '9.0'
use_frameworks!
inhibit_all_warnings!
def shared_pods
# Pods for NamaIOS
pod 'Alamofire'
pod 'RxSwift'
end
target 'MyApp' do
use_frameworks!
shared_pods
end
target 'MyApp-Test' do
use_frameworks!
shared_pods
end
target 'MyApp-Development' do
use_frameworks!
shared_pods
end
if you come from lottie-react-native install instructions just add use_frameworks! to podFile #536 (comment)
I am android programmer.
It took me a while understand what they were doing.
I have currently Xcode 13.2.1
And flutter 1 awful combination I know.
Please edit in other side xcode will take the enter like "I end"
I change Build settings > Search paths > Library search paths.:
From:
$(inherited) $(PROJECT_DIR)/Flutter
to:
$(inherited) $(PROJECT_DIR)/Flutter $(SDKROOT)/usr/lib/swift
$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
Thats all,
I hope to help some folk.
I am getting this error after installing Lottie-react-native?
The solution only works if it is caused by adding Lottie package.
This worked for me:
yarn add lottie-react-native
yarn add lottie-ios#3.2.3
And then must run:
pod install or pod update
I am using:
"lottie-ios": "3.2.3",
"lottie-react-native": "^5.0.1",
"react": "17.0.2",
"react-native": "0.67.3"
In case you encounter this error while using Xcode 11 beta 4 in combination with carthage see this workaround:
https://github.com/Carthage/Carthage/issues/2825
Basically it consists of creating a xcconfig with the fixes and inject these into each build.
I only forget to Add the new Framework to my pod file :)
target 'Data' do
inherit! :search_paths
pod 'AlamofireObjectMapper', '~> 5.2'
end
for Xcode 12.2
Create an Empty Swift file using Xcode, such as named Void.swift, and every issue will be solved by Xcode automatically.
I ran into this issue with our project and the issue was that there were orphaned references to lottie in our xcode project file. Opening that in a text editor and removing them fixed the issue for me.
What solved it for me when trying to integrate Lottie in my React Native project was to uninstall the lottie-ios and lottie-react-native modules with npm.
npm uninstall lottie-react-native lottie-ios
Make sure the files are unlinked as well
npx react-native unlink lottie-react-native lottie-ios
I also had the bridging-file in my project from previously trying that method without success so in order to replicate my process, follow the suggested answer and add that file to your project as well.
After these steps, I went ahead and deleted my Pods folder, cleaned my build from xcproject and xcworkspace (maybe one of these is enough).
After that I went ahead and installed the modules again
npm i --save lottie-react-native lottie-ios#3.1.3
(Make sure to check the current docks over at the lottie repo for the up-to-date versions.)
After you have reinstalled the modules, cd into your ios folder and run pod install.
Open up your xcworkspace in Xcode and run your project (make sure your build is clean).
This solved my issue.
Best of luck.

Why it shows "ld: framework not found Bolts"

After I install facebook sdk, when I build my project, it shows:
ld: warning: directory not found for option '-F/Users/liyuanliu/Library/Developer/Xcode/DerivedData/c5-dsovqtraubbdgxbqrmiexjmlysxq/Build/Products/Debug-iphonesimulator/Bolts'
ld: warning: directory not found for option '-F/Users/liyuanliu/Library/Developer/Xcode/DerivedData/c5-dsovqtraubbdgxbqrmiexjmlysxq/Build/Products/Debug-iphonesimulator/FBSDKCoreKit'
ld: warning: directory not found for option '-F/Users/liyuanliu/Library/Developer/Xcode/DerivedData/c5-dsovqtraubbdgxbqrmiexjmlysxq/Build/Products/Debug-iphonesimulator/FBSDKLoginKit'
ld: warning: directory not found for option '-F/Users/liyuanliu/Library/Developer/Xcode/DerivedData/c5-dsovqtraubbdgxbqrmiexjmlysxq/Build/Products/Debug-iphonesimulator/FBSDKShareKit'
ld: framework not found Bolts
clang: error: linker command failed with exit code 1 (use -v to see invocation)
But when I install facebook and bolts, it shows I install them successfully:
pod install
Analyzing dependencies
Downloading dependencies
Using Bolts (1.8.4)
Using FBSDKCoreKit (4.14.0)
Using FBSDKLoginKit (4.14.0)
Using FBSDKShareKit (4.14.0)
Using Firebase (3.4.0)
Using FirebaseAnalytics (3.3.0)
Using FirebaseAppIndexing (1.0.4)
Using FirebaseAuth (3.0.4)
Below is my build phases image :
And below cannot find bolts framework image
I cannot find the FBXXXX.framework
After I add frameworks, it still exits:
I solved the problem by deleting the ~/Library/Developer/Xcode/DerivedData/xxxx while xcode was closed and then reopened xcode and did a clean + build. All was fixed up when xcode rebuilt the derived data for the project.
Please try below steps
From Podfile directory run below commands in terminal
pod deintegrate
pod install
Clean Derived Data folder from Xcode
Perform fresh clean build
Go to Project->TARGETS-Build Phases->Link Binary With Libraries Attach your Bolts library here.
Now click on + button ->
Now Click on Add Other.. Button->Find the FBSDK framework on your computer & attach it. Compile & run your application .
Finally, I found a solution to solve this problem. In project->targets->build settings->framework search path, there are many paths already existed. I download 4 frameworks(bolts.framework and 3 other FBXXXX.framework) and copy all of them inside one of these existing paths.
The problem is that the suggestion at https://developers.facebook.com/docs/ios/getting-started of not Deselect Copy items into destination group's folder. is not appropriate on Xcode 8.0, the most popular atm. Dragging the frameworks would move them to the new Frameworks folder.
So follow the tutorial but keep the tick on Copy items into destination group's folder
Finally got solution for them if they are using pod
pod 'FBSDKLoginKit', '4.43.0'
pod 'FBSDKCoreKit', '4.43.0'
Answer on the behalf of the author of the post:
Finally, I found a solution to solve this problem. In project->targets->build settings->framework search path, there are many paths that already existed. I download 4 frameworks (bolts.framework and 3 other FBXXXX.framework) and copy all of them inside one of these existing paths.

adding pods to compile sources (iOS App)

in our last sprint we tried to add some cocoapods to the project.
Unfortunately, the pods are not added automatically to the compile sources in the base project in Xcode.
That means that I needed to copy some relevant .m files to the list.
Well, it worked just fine for one pod.. But now I'm trying to add ShakeKit Pod and it's just not right! Plus, I don't see the benefits of using cocoapods if I need to import every .m file to my project.
Anyone here knows to tell me what I'm doing wrong?
Environment Details:
iOS SDK - 8.3
Xcode - 6.3
I've found that $(inherited) was missing from my Other Linker Flags build setting. Applying this option fixed a missing library issue I was seeing.
Just like the guy from this thread :
Error: ld: library not found for -lPods with CocoaPods

Resources