Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode keeps forgetting imported Frameworks

I have Xcode 6.3, using Swift, importing a Parse 1.7.1 Framework as usual (dragging, copying) and I set it up in a group: Frameworks.

I compile and everything works fine for a while with it, until the compiler does not recognize this sentence anymore:

import Parse

It gives me the error:

No such module 'Parse'

A workaround is to delete the Framework and copy it again, but after a while it starts getting annoying, and I would really like to know the cause.

I only code and build in the meantime (and occasionally creating new swift files), so I can't explain why this happens.

like image 210
cduguet Avatar asked May 04 '15 00:05

cduguet


People also ask

How do I manually import framework in Xcode?

To include a framework in your Xcode project, choose Project > Add to Project and select the framework directory. Alternatively, you can control-click your project group and choose Add Files > Existing Frameworks from the contextual menu.

How do I link an external framework in Xcode?

In general, to use an external framework in Xcode, you need to: Add a some kind of synchronised link to the external repository and download it. Add the . xcodeproj (Xcode project) file from the external repo as a sub-project to your own project, in Xcode's File Navigator.

Why are frameworks red in Xcode?

Products appear in red in Xcode when they don't currently exist.


2 Answers

If you're targeting iOS 8 and above, you can tell Cocoapods to use frameworks, by putting

use_frameworks!

in your Podfile, like this example:

use_frameworks!
platform :ios, '8.0'

# Parse
pod 'Parse', '~> 1.7'

I could fix the same problem by doing so.

like image 162
aslisabanci Avatar answered Sep 20 '22 13:09

aslisabanci


I just fixed this same issue today with my project. I imported my obj-c framework in a swift project and it worked for a while, then xcode seemed to forget it causing the same error you have.

apple docs

I fixed it by referencing the bridging header in Build Settings.

Under Build Settings, make sure the Objective-C Bridging Header build setting under Swift Compiler - Code Generation has a path to the header. The path should be relative to your project, similar to the way your Info.plist path is specified in Build Settings. In most cases, you should not need to modify this setting.

I just typed in the name of the bridging header folderName/xxxx-BridgingHeader.h in the field that states bridging header and all was well again.

like image 30
Garret Avatar answered Sep 20 '22 13:09

Garret