AC 3.3 - Swift code completion for imported frameworks

Answered

Hi ,

Using latest AppCode 3.3.2

Not sure whether I've missed something but code completion for imported frameworks ( cocoapods ) doesnt works.
Project builds fine, both xcode and appcode. I can't get any suggestios I would get in XCode. Imported libraries are integrated using cocoapods into my workspace.
Is there any additional steps I need to make in order to have extensions, generics closures and all goodies from frameworks start to comming with autocompletion and live error checks as in Xcode  ?

Thanks

27 comments

Hi Keith.

Could you please specify what frameworks are you using (or provide contents of a podfile)?
Where you experience completion issues: in Swift or Objective-C code? It would be great if you post a snippet where issue manifests.

0
Here is the pod ingredient

target :MyAppTar do
    
platform :ios, '8.0'
    
use_frameworks!
    pod 'NJKWebViewProgress', :head
    
pod 'SDWebImage', :head
    
pod 'Colours' , :head
    
pod 'RestKit', '0.25.0'
    
pod 'Objection', :head
    
pod 'SnapKit', :head
    
pod 'pop', '~> 1.0.8'
    
pod 'Cartography'
    
pod 'CHCSVParser'
    
pod 'SwiftyTimer', :head
    
pod 'ReactiveCocoa','4.0.4-alpha-4'
    
pod 'SwiftyJSON'
    
xcodeproj 'MyAppTar/MyAppTar.xcodeproj'
end



And yes, its regards swift autocompletion.

0

Keith,

Some of those frameworks are written in Objective-C, some in Swift. What I meant to ask in previous comment (sorry, it was unclear): are you having problems with completion of Swift classes (other symbols) in Swift code or with Objective-C classes in Swift code?
Can you provide a screenshot of a problem?

0

I'm experiencing the same issue. I have a swift project that includes OAStackView as a pod. OAStackView is an Objective-C framework.
AppCode does not perform any autocompletion when using this framework.

The other interesting thing is that when I CMD + Click on OAStackView in the editor it takes me to a blank OAStackView.swift.

Podfile is the following:

platform 

:ios, '8.1'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
inhibit_all_warnings!

pod "OAStackView"



Here is the Swift Code that is using the OAStackView

 
let stackView = OAStackView(arrangedSubviews: views)
stackView.axis = .Vertical
stackView.spacing = 8
stackView.translatesAutoresizingMaskIntoConstraints = false
  

Neither the constructor nor any property/method calls autocomplete.

Message was edited by: Matthew Smith

0

Matthew,

Thanks for the snippet provided.
Looks like you're experiencing OC-12315. Please upvote and leave comments there as you see fit.

0

I'm experiencing the same issue.

The cocoapods library is written in Objective-C.

When I go to the definition of the library, a blank .swift file shows up.

But when I open the library files in XCode, it shows the swift code, as if the library was written in swift.

0

Has this issue been resolved as yet? I just imported https://github.com/PureLayout/PureLayout via CocoaPods and I am not getting any autocompletion at all.

0

Hi Joel.

We are working on the related issues right now during our work on AppCode 3.4 EAP. This issue also is planned to be fixed soon.

0

Still experiencing the same issue, 

As Ewan said,

>"But when I open the library files in XCode, it shows the swift code, as if the library was written in swift."

For instance, when i typed "PFPush." it doesn't show anything, however in XCode 7.3 it works as follows

PFPush.subscribeToChannelInBackground

1) Appcode version is 2016.1.2 build oc-145.972

2) Here is my pod file.

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'Material', '~> 1.0'
pod 'Parse'

end

....

0

I get this issue with cocoa frameworks too. Specifically, AppCode can't resolve the 'CMDeviceMotion' class and as such auto complete won't resolve. Using:

AppCode 2016.3.2
Build #OC-163.12024.9, built on January 25, 2017
JRE: 1.8.0_112-release-408-b6 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

0

Chris,

Do you have

import CoreMotion

 statement in the file?

If no, would it help if you add it?

0

Hi, 

 

Yes I do, the line is not clickable. See photo:

I can't click "attitude" for example even though it is a property of deviceMotion. 

 

Also: 

Unable to click into CMDeviceMotion

0

Apparently, CMDeviceMotion is unresolved (reference is white). Can you navigate into CoreMotion module from you import statement? If yes, would you be able to post the contents of CoreMotion.swift file here.

import CoreMotion<caret> //  CMD+B
0

Hi, 

 

The CoreMotion.swfit file contains:

import CoreMotion.CMAccelerometer
import CoreMotion.CMAltimeter
import CoreMotion.CMAltitude
import CoreMotion.CMAttitude
import CoreMotion.CMAvailability
import CoreMotion.CMDeviceMotion
import CoreMotion.CMError
import CoreMotion.CMErrorDomain
import CoreMotion.CMGyro
import CoreMotion.CMLogItem
import CoreMotion.CMMagnetometer
import CoreMotion.CMMotionActivity
import CoreMotion.CMMotionActivityManager
import CoreMotion.CMMotionManager
import CoreMotion.CMPedometer
import CoreMotion.CMSensorRecorder
import CoreMotion.CMStepCounter

0

Strange, everything looks correct. 

Chris, would you be able to file an issue in tracker and attach sample project to repro (any basic project created from scratch would work). I can't replicate the problem in my environment.

0

When I get a spare moment I may be able to. Is there anything I could reset or check ? TBH it seems intellisense is broken all over the place at the moment.

0

File | Invalidate Caches & Restart may be helpful in that case.

0

Yes that has worked - not for the CoreMotion though...

0

Chris,

You may be also interested in taking a look at OC-13434. Currently AppCode cannot resolve symbols from modules (SDK or custom) that were imported implicitly, we're working on the ticket at the moment. That's why I've asked about explicit import statement and whether it helps or not. With explicit import there should be no problems, that's something new to us.

0

Ah ok - that may be it then? I'll wait for the new release and I'll use Xcode where I can't use AppCode... When is the nest release scheduled?

0

If CMDeviceMotion is not resolved in the file where explicit

import CoreMotion

statement is specified - then no, that's unlikely related to OC-13434. If, say, you're using some SDK framework which implicitly imports CoreMotion module - then it could be it

Upcoming AppCode 2017.1 release is targeted this spring (roughly, late March). However, since we haven't yet finished work on the ticket and it should be carefully tested internally first, we won't be able to include it in 2017.1. Most likely, the fix will be included in one of the 2017.2 EAPs and/or in 2017.1.x updates.

0

Is this resolved? I have AppCode 2018.1 and still see this issue. 

 

Here's my Podfile: 

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'MyPodcastApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# Pods for MyPodcastApp
pod 'Alamofire', '~> 4.7'
pod 'SDWebImage', '~> 4.1.2'
pod 'FeedKit', '~> 7.0.1'
end

I'm trying to import SDWebImage in a swift file and use the methods in it, I don't seem to be getting auto-completion or symbols don't seem to resolve. 

 

Please let me know if I'm missing something?

 

Thanks, 

Ajay 

0

Ajay,

Are you using the workspace?

Also, you property doesn’t return so that’s an error. I’ve sometimes found that if there are build errors in the source, other areas will throw errors too. Also your property is set to never be nil but you have multiple ‘return’ statements that don’t return a value.

0

Hi Chris, 

Thanks for your reply. Yes, I'm using the workspace. 

It's probably not clear from the code I posted, but this is a write-only property which would be set from outside this class. When it is set, the didSet Observer is called and a bunch of initialization is done. This can be thought of as a pseudo initializer. I hope that explains what I'm trying to do. 

Also, there are no built errors.  

Ajay

0

Ah yes I didn’t spot the didSet. Yeah appcode is pretty buggy these days.

0

Hi Ajay.

Works fine for me in AppCode 2018.1.2 EAP (e.g. resolve & completion for sd_setImage() method which fails to resolve on your screenshot):

Maybe there's something else in your project which is influencing. Could you submit a sample to our tracker?

0

Please sign in to leave a comment.