7

I have noticed this problem as closed before but I am getting the same problem.

screen shot 2017-05-12 at 10 56 07 am

P.S - I have imported Alamofire in the class mentioned in the screenshot

Here is my pod details

platform :ios, '10.0'

use_frameworks!
target 'PhotoTagger' do
     pod 'Alamofire'
end

Also the only thing being auto completed is AlamofireVersionNumber and i cannot access anything when I am trying to use the auto complete feature. Now if i write Alamofire by hand then I can access some methods, but then again something is going wrong and code is not compiling, which i think boils down to the issue that the class isnt being fetched by auto complete.

I have tried -

In Project settings > Build settings

  1. Always search user path To YES
  2. Header search path to only include "$(inherited)" as non-recursive

All other pods are working fine, except Alamofire. Also after writing class name by hand or copy pasting, some of the methods that are being auto completed does not have the same signature of the actual method of the Alamofire class

Please please please !! help me sort this out, so that someone out there when facing this can help themselves too. There isnt any solution to this as of now.

P.S

I had opened an issue on Alamofire's Github page, but they responded with

Sorry, we're not responsible for Xcode's autocomplete issues.
In the future, you should open questions like this on Stack Overflow
and tag alamofire.

Cheers. 

Please help, I am stuck with this for quite some time.

EDIT :

Here is my project settings details enter image description here Also, I have build the project and still the problem persists.

P.S - Writing the class manually by hand , and the methods even, it compiles but everytime, I have to go to the github page, to copy paste the method signature, The problem is that with Autocomplete, i can navigate all method signatures and know about the public available methods. But I am only restricted to the example methods available in github, as everytime I have to copy paste the methods and the overwrite the implementation. Again, this compiles and runs, but the auto complete is not working, not for the class, or for the functions.

Community
  • 1
  • 1
Saheb Roy
  • 5,899
  • 3
  • 23
  • 35

10 Answers10

1

Solution 1

Probably this is not about Alamofire or pod libraries but Swift and XCode. This answer could be your solution, shortly:

  • Go to Xcode > Preferences > Text Editing Under Code completion
  • Uncheck 'Suggest completions while typing' Quit out of Xcode and then
  • relaunch Xcode. Go to Xcode > Preferences > Text Editing again Again
  • go to Code completion and check 'Suggest completions while typing'.
  • Try typing library function or enum...

Solution 2

Or you can try this answer if your XCode have some cache file issue, shortly close XCode and remove file below:

~/Library/Caches/com.apple.dt.Xcode

and try again.

Solution 3

Or you can try this answer, shortly:

Find any commented out (/* abc */) code after @end in your files and delete.

Let me know if any solution it works.

MGY
  • 7,245
  • 5
  • 41
  • 74
  • Please be sure that all files in your code working correct, no errors in other classes, sometimes this can cause this problem, but X Code will not say this but just stop working correctly. – MGY May 31 '17 at 08:36
  • Yes build successfully but still problem persists – Saheb Roy May 31 '17 at 08:45
  • Tried solution 2 and 3 both, didnt work P.S - This is only for Alamofire, for all the other pod I have installed, everything is working properly ie autocomplete and class recognition is working – Saheb Roy May 31 '17 at 09:50
  • Strange but solution 1 was the one that fix the problem. Is there some explanation why? – m1sh0 May 16 '18 at 15:09
1

I had the same problem once. I can’t remember exactly what worked, but we will figure that out now.

In «Build Settings -> Search path -> Framework Search Paths» check to see if you have the following:

Always Search user Paths : NO
Framework Search Paths: $(inherited), "$PODS_CONFIGURATION_BUILD_DIR/Alamofire", "${PODS_ROOT}/Alamofire/" 

These search path might not be the same as yours, so just double check that the path above is correct, according to where the files are saved.

Before you do changes in the config files, take a backup in case something get's messed up.

When you do changes, build your project and restart Xcode.


I just did a test project with Alamofire:

Installing pod: pod 'Alamofire', '~> 4.4'

Opening xcworkspace first time: Autocompletion doesn't work. Xcode doesn't recognize import Alamofire.

Then:

Build project: Project -> Build

Xcode recognizes import Alamofire.

When typing Alamofire it doesn't work, only AlamofireVersionNumber is autocompleted.

But when typing Alamofire.(and typing a known command from alamofire it will autocomplete)

JoakimE
  • 1,820
  • 1
  • 21
  • 30
  • Yes I know, manually writing upto a part of Alamofire.Post then it gets auto completed, My Question is why isnt the class being recognised and being auto completed. This is a huge setback, as normally we use auto complete to get to know the public classes available, rather than going to the source file for documented methods and their signatures. Also , I am editing the question, Your suggestion didnt work – Saheb Roy Jun 05 '17 at 05:42
  • It's not working as expected. Really annoying thing. It seems to be that only some frameworks are affected. I haven't had any problems using e.g. Firebase before. It could be some CocoaPods settings for Alamofire issue. – JoakimE Jun 05 '17 at 13:42
  • I have literally tried everything, I have reset my pod setup in my local repo, reinstalled cocoapods, reset pod setup reinstalled xcode even. – Saheb Roy Jun 05 '17 at 13:47
1

For me adding anything to the Build Settings didn't work, but deleting Derived Data and building the Pod scheme explicitely did the trick.

Go to "Manage Schemes" and check the Pods-MyProject scheme and the one of the pod which doesn't autocomplete. Close the window. First select the scheme of the broken pod (button next to the run and stop button) and Build for Running shift + cmd + R. Second select the Pods-MyProject scheme and Build this for Running too. Switch back to your normal scheme and you should be fine.

fruechtemuesli
  • 2,809
  • 3
  • 17
  • 15
0

Did you delete the derived data for your project or the whole of it? I've had this happen, wipe it all.

Fernando Mazzon
  • 3,562
  • 1
  • 19
  • 21
0

I had this exact problem a few days back. I think this is happening because Xcode is not able to find the Alamofire header libraries. What I did to resolve was :

1) Go to build settings and search for 'User Header Search Paths'

2) Enter its value as "${PODS_ROOT}/BuildHeaders" including the quotes

3) Click the thing again and in the right side , change the value of the selection to 'recursive'

Now Restart Xcode and build the project. Now the autocomplete works fine

Pm Abi
  • 225
  • 5
  • 8
0

Sometimes when you install some pod from the terminal's window you need to restart xcode or also the mac, before see the import name correctly.

Andrea Merli
  • 85
  • 1
  • 7
  • Well this is the first step that I do, after pod installing, i restart the xcode. But again, this does not work – Saheb Roy Jun 07 '17 at 09:46
0

Unfortunately this is Xcode being stupid. Same issue is happening with most advanced libraries even when using server side SPM. Until apple improves xcode some things will just stay hidden to us unfortunately.

I am currently using Xcode 9.2

Ondrej Rafaj
  • 4,342
  • 8
  • 42
  • 65
0

Just go for a build after removing any code with error (any incomplete alamofire call attempts or so).

Rémi Belzanti
  • 413
  • 5
  • 12
0

SOLUTION

Start by writing "AF" and then the desired function.

AF.request(url...

AF is global namespace containing API

Murphy
  • 849
  • 7
  • 6
-1

Your pod string may be wrong. Please try this

pod 'Alamofire', '~> 4.4'

Thanks.

Bala AP
  • 37
  • 5
  • I have tried this but this does not work as well. Also, not giving a version in the podfile, will automatically fetch the latest version of the pod. here it is 4.4 – Saheb Roy May 29 '17 at 06:21