3

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
Abbas
  • 3,529
  • 5
  • 36
  • 64
  • Did you try checking if there are any unwanted Frameworks listed in `Embedded Binaries` and `Linked Frameworks and Libraries` under `General` – iCode Oct 15 '19 at 09:45
  • There are no embedded binaries, as for Frameworks and Libraries they are all justifiable there (though I cannot be sure), I've inherited this project from a colleague who has quit. I've never worked on any apple app development before, so have close to no idea what is going on. – Abbas Oct 15 '19 at 09:55
  • Although, and I haven't mentioned this in the post. But there are a couple frameworks which are showing red on the left folder/directory panel namely **`Foundation.Framework`** and **`Pods_.framework`**. The later's color normalize if I select `Generic iOS Device`. – Abbas Oct 15 '19 at 09:58
  • Try deleting Podfile.lock and then pod update – jsstackguru Oct 18 '19 at 13:57

6 Answers6

1

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

iCode
  • 113
  • 1
  • 10
  • Already tried updating pod, didn't work. Will try again and let you know if it works. – Abbas Oct 15 '19 at 10:21
  • Did you try updating `CocoaPod` itself? Else remove the Pod if not needed. – iCode Oct 15 '19 at 10:25
  • Yes, I updated cocoapods to the latest 1.8.3 I think and then reverted back to 1.5.3. – Abbas Oct 15 '19 at 10:28
  • Yes, the issue is still there running `pod update` has no effect. As far as I can tell, the xCode version might be responsible for that, you see the system it runs on has xCode v10.3. Or it has something to do with linking the libraries to the project. – Abbas Oct 15 '19 at 11:21
0

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,

  1. Differentiate that frameworks which gives you an error and remove that pods from your pod file and run pod install command and delete DerivedData.
  2. Download that framework's code in your system.
  3. 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,

  1. Open your downloaded project of framework.
  2. Select any simulator target and build project.
  3. Get generated .framework file from Products folder.
  4. Add this framework in your project like this.
  5. Now build your project for simulator.
  6. 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.

Komal Goyani
  • 779
  • 6
  • 25
  • Thanks for the answer. I did try to delete Derived data not once but many times. Did you read the question? I added a solution that worked for me. In the solution I pointed out a specific file `Pods_.framework` which when deleted, fixed the issue, however as stated in the question the file comes back after each `pod install` and I have to remove the framework file again. Currently I'm looking for a way to not allow the file to come back. – Abbas Oct 21 '19 at 06:43
  • You haven't understood my answer properly. I say that remove specific pod which gives you an error. Could you give me your pod list? I can solve your error because of i have faced this issue before. – Komal Goyani Oct 21 '19 at 06:49
  • I've added the `podfile`, there is only one dependency listed there. – Abbas Oct 21 '19 at 07:27
  • The `-ObjC` flag is already present in the `Other Linker Flags`. Following is the complete instruction `-ObjC $(inherited)`. – Abbas Oct 21 '19 at 08:10
  • Have you followed complete guidelines from https://developers.google.com/admob/ios/quick-start ? – Komal Goyani Oct 21 '19 at 08:22
  • Yes. Although I can't find which `info.plist` file to update, there are quite a few. Or is it only applicable for manual download? – Abbas Oct 21 '19 at 08:32
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/201191/discussion-between-komal-goyani-and-abbas). – Komal Goyani Oct 21 '19 at 08:42
0

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.

Ly Boung
  • 185
  • 9
  • As I said earlier deleting the DerivedData and deintegrate pod didn't work. I tried that many times. – Abbas Oct 22 '19 at 06:04
0

Adding -ObjC $(inherited) in the Other Linker Flags fixes my issue

Ram G.
  • 3,045
  • 2
  • 25
  • 31
0

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.

zeusstl
  • 1,673
  • 18
  • 19
-1

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

alxlives
  • 5,084
  • 4
  • 28
  • 50
  • Thanks for the answer, I've found a sorta solution (still looking for a better approach). But before I found the solution I tried deleting all the files (probably 10 times I kid you not) you mentioned and deleting them didn't help. – Abbas Oct 18 '19 at 17:36