How to use cocoapods in an exist ios project - ios

I have an ios project first made in Xcode4.6. I have update it to Xcode5.0.2. Now I want to change the project to using cocoapods to manage the third party pods.
Due to a newer to cocoapods.I search the Internet to how to install cocoapods and so on.Now it's OK.So I run the pod install to get "AFFnetworking 2.1.0". .xcworkspace generate successfully.Then I open the workspace.I saw this in the navigation
There are many question mark.I think this means that Xcode5.0.2 didn't know the AFNetworking 2.1.0 added by cocoapods. And If I write the "#import "AFNetworking.h" in a .m file. Xcode will say that can't find the "AFNetworking.h".
I am a newer to cocoapods. So home someone could help me. Tanks a lot.

Because AFNetworking is linked as a library you need to use the < > import style. So #import <AFNetworking/AFNetworking.h>.

The question marks are coming from your version-control system, not from Xcode itself; they indicate that the files added by CocoaPods are new to version control. I’d recommend committing all of the CocoaPods-related files right away so that you have just one commit that represents “moving to CocoaPods”.

I guess you are using git repository.Add files pod to repository, currently they are untracked thats the reason for '?' there.if the error persists then see the following discussion
AFNetworking Cause Error while using XCTest in Xcode5

Related

Issue with building project after addition of AFNetworking in Xcode 8

I just added AFNetworking in my project and have this problem.If you will say that I need to add a security.framework I will answer that I did it already.Here is screenshots. Problem screenshot
I have already added framework screenshot
On screenshot I see that you added Apple Security.framework, and problem is with AFNetworking framework. Are you sure that you added AFNetworking to your project. If it was also added - then next question comes:
Was CocoaPods used for this, or there was another source. CocoaPods should install newest version of framework but if framework is for example copied from older project - then it can cause many issues. For example framework may not support arm64 architecture.
So first attempt to solve this problem will be using fresh version of framework (using CocoaPods recommended), eventually check architectures supported by framework (see here).
Clean your build folder and run pod install.

Modules are disabled - but why?

I'm struggeling with Modules in a project. Where I use #import I get "Use of '#import' when modules are disabled". But why are they disabled?
In my build settings I have "Enable modules (C and Objective-C)" set to Yes for all targets.
Setting "Link Frameworks Automatically" to Yes or No does not impact this (compile-time) error
Although the project used to have Objective-C++ and some C++ code, it doesn't anymore. Are there any project-settings I can have missed that were set because of this?
I have no more .pch files in the project, and the build settings have no mention of them
I use CocoaPods (0.39.0) with "use_frameworks!" and the modules I wish #import are from there. But the same error happens if I replace the '#import ' or '#import ' with '#import Foundation;' and '#import UIKit', so I expect this is not related
The project is from pre-iOS7 so I might have missed a setting that used to be on by default
The project requires iOS 8 and builds against iOS 9.2.
I realize that loading third-party modules will probably slow down the apps loading time. I'm converting to CocoaPods with use_frameworks! so that I can measure by how much. If it's not too bad, I'd like to use as I'm planning to move multiple swift-only parts of the codebase into their own frameworks (as open source coocapods)
I believe that this is not be a duplicate of other questions on SO since I've gone through the ones I found (big thank-you to this one), followed the links, re-watched WWDC'13 session 404, and read the related posts on Apples forums, so I believe I've done my homework. :-)
In my project I have a bridging header to bridge from ObjC to Swift, and there is a generated header file to bridge from Swift to ObjC. It turns out that if the bridging header referenced headers where the implementation file referenced the bridge file from Swift to ObjC, module support is disabled. So be careful about what you put in your bridging file, and be careful about when you import the generated -Swift.h file.
Firstly go to the terminal and type xcode-select -p. It should say, /Applications/Xcode.app/Contents/Developer. If it doesn't, then type, sudo xcode-select -s /Applications/Xcode.app and hit enter and type in your password.
If that doesn't fix it, try deleting your project's derived data directory. Go to the Projects view and delete the derived data for your project. Then clean your build folder (command-shift-K). Run Analyze (command-shift-B) and resolve any issues in blue and yellow.
Now if #import is still not working, create a brand new XCode project. Verify that #import works in it. If it doesn't, then your XCode installation got screwed up probably, or your HDD is dying. Delete XCode and re-download it, see if that works. Restart into the recovery partition and see if you have some disk issues (unlikely, but hey).
If #import works in the new project, try taking all your from your current project and copying them into the new project. Make sure you have the latest version of cocoapods and then freshly install your pods into the new project.
If all of that doesn't fix it, you probably left an #end statement out somewhere or have a missing } ...

Can't archive project when use new MagicalRrecord

I add to my project MagicalRecord as submodule as described here
https://github.com/magicalpanda/MagicalRecord/blob/master/Docs/Installing-MagicalRecord.md
Then i add it's to my project and i got modified content on submodule.
Just then i open my project.
Why? And also i can't archive my project, because can't found
I added MagicalRecord frame work to Link libraries but it's red
But it's build and run on simulator or iphone device.
Problem just then try make archive my app.
I would highly recommend using the CocoaPods method. I have used it for MagicalRecord many times with no issues. Relatively easy to install and keeps your code up to date.
I also ran into a similar issue when I tried a submodule and couldn't get it to work. Make sure your project has CoreData.framework linked and also trying linking libMagicalRecord.dylib and libMagicalRecord.a.

Cannot load underlying module for 'Charts'

I'm just getting started with the iOS charts library :
I followed all the steps described under 'Usage' on the main page (https://github.com/danielgindi/ios-charts):
I added a UIView and made it subclass LineChartView
--> in ViewController.swift: the line import Charts gives an error: Cannot load underlying module for 'Charts'
Why is that ?
Thank you !
It's possibly related to this issue too: https://github.com/Alamofire/Alamofire/issues/122
In short: Seems like there's a bug in Xcode 6.3.1, where new projects have problems when importing Embedded Frameworks. In such a case, you need to let the project build first, and then add the framework to the project.
Sounds like your project haven't added the framework successfully. I just started with ios-charts as well, and I followed the steps on github as well and it worked like a charm. What I did was to just drag the Charts.xcodeproj into my Project Navigator and it worked like a charm. If this doesn't work for you, however, make sure you are using iOS 8. If you are not, then you have to add the .swift-files to your project. If you are using iOS 8 and the approach still doesn't work, I'd try to install it using CocoaPods instead. I'm fairly new in CocoaPods so can't really help you there, but just google on how to install frameworks using CocoaPods and you should find what you seek.
Sorry if I wasn't of much help!
The answer comes a bit late, but what solved the problem for me was to clean my project by selecting the option Product > Clean from my status bar. Hope it might help someone else in case you solved the problem already.
After cleaning the product once I received this error. I then removed the framework from embedded binaries, cleaned the product, then added it once more to embedded libraries. I then built the product and retried the import statement. The import statement worked.
I had the same issue with KeychainAccess pod. Even though the pod was installed it use to throw an error
‘Cannot load underlying module for KeychainAccess’.
The fix that worked for me :
Uninstall the pod and install it again
Delete the derived data content
Quit Xcode and start again
Make sure your scheme is targeting an iOS device or simulator. If you build for your Mac it'll give you this error.
Build the project and this error will go away

Integrating CocoaLumberjack into iOS Project via Drag-and-Drop

I'm trying to integrate CocoaLumberjack into my iOS project by dragging-and-dropping the Lumberjack.Xcode file into my project. That works fine, but now my project has 9 new targets. I don't need all of that overhead. So my question is, how do I cut down on the number of targets to just the needed stuff for iOS?
It seems every time I drag over only the mobile project that it is missing needed files. Upon my research, it seems that there are no up-to-date tutorials related to integrating Lumberjack specifically to iOS, which seems like a tool that would be commonly used so that is odd. Being new to all of this, it is troublesome and I would love some help.
Other information: I'm doing a manual installation since Cocoapods is not an option for me. I am following their Installation Guide:
Installation Guide
The very first line in the manual installation guide is
git submodule add git#github.com:CocoaLumberjack/CocoaLumberjack.git
I do not want to add yet another submodule to my project, so I'm dragging and dropping Lumberjack.Xcode into my project.
Before I learned how to use CocoaPods, I used to just clone the repo and copy all of the .h and .m files into my project, ensuring they're added to the correct target.
The only issue you have to make sure to avoid is missing one or more files. Not 100% sure with CocoaLumberjack, but I'd look at just adding everything from here:
https://github.com/CocoaLumberjack/CocoaLumberjack/tree/master/Classes
Instead of adding it as a submodule, you can simply clone the repo and add it to your project. The rest of the instructions remain the same. So replace the line you quoted above with:
git clone git#github.com:CocoaLumberjack/CocoaLumberjack.git
rm -r CocoaLumberjack/.git/
Then follow the rest of the instructions in the install guide.
Instructions from CocoaLumberJack
https://github.com/CocoaLumberjack/CocoaLumberjack/blob/master/Documentation/GettingStarted.md

Resources