Unable to Import Frameworks/Pods into xcode - ios

I have an issue with xcode where if I try to insert a pod or framework into my project it doesn't see to link. For instance, I added the CoreLocation framework as well as the Firebase/Core pods. In both instances when I go to add:
Import Firebase
Import CoreLocation
the suggestions which appear do not find the desired Framework/Pod to import in my app delegate which leads me to believe there is some sort of linking error. I am further convinced of this because when I try to type things in such as CLLocation Manager and try to run them I get a "build failed" error with the debugger stating "use of unresolved identifier x".
I'm new to stack overflow so hopefully this question isn't too wordy or too general please let me know if any further information is needed.

first, check the pod version and update to the latest version. Then, try building the project multiple times, if nothing happened, remove pod 'Firebase/Core' and do pod install then re-add this line again and do pod install again.
One of the things I've noticed above is that you're not using single quotation marks around the framework name in the podfile.

Related

Are there different ways to include Objective-C pods in swift xcode xcworkspace projects post pod install?

Using pod dependencies, the import behavior is inconsistent.
This behavior is different on different machines for the same pods in Podfile. After successfully installing pods, my team came across the following two situations.
On one it worked through the #import statement in the bridging-header.h file but throws
No such module '<moduleName>' error in the ViewController.swift file when tried that way.
While on another mac it threw errors in the bridging.h file and worked through import <moduleName> in the ViewController.swift file.
Both machines have Xcode 8.1, using Swift 3 syntax and cocoapods version is 1.1.1. We were able to re-create the issue multiple times.
Does anyone know why this happens and if there is some project setting which can be used to produce consistent reults?
We have experienced this behaviour also. We could sometimes 'solve' it via: product>clean.
Sometimes we even had to quit+restart xcode and run clean again.
We agree, it is strange behaviour, probably xcode is losing state information or something.

Connecting Facebook SDK to xcode/swift works, but I'm having issues

I was able to get the Facebook SDK on xcode and I was able to get a login button and such. Works great.
But if I try to CMD click on any of the FB things to view the source code, it says
Couldn't Generate Swift Representation
Error (from SourceKit):
"Could not load module: FBSDKLoginKit"
Seems that something is not linked correctly, but I can't figure out what.
I figured out one of the problems I was having, but I am still having this issue with going to the source code.
There are two occasions when this problem might arise:
Your framework cannot be located.
Fix: Go to target's Build Settings and add a path to Framework Search Paths
/Users/<user>/path-to-framework-parent-directory
Probably path to your framework contains a space in it.
Eg: change /Desktop/App Dev/NewFolder to /Desktop/AppDev/NewFolder
Even if you try to escape it with backslash ../App\ Dev/NewFolder or take the whole path in double-quotes "../App Dev/NewFolder", the SourceKit won't be able to load the module.
Please go for pod installation. do work space creation and use the following lines.
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
pod 'FBSDKMessengerShareKit'

Upgraded Firebase - Now Getting Swift Compile Error

I upgraded Firebase yesterday and now am having a very unusual problem. When I run the simulator, I get a swift compile error "Segmentation fault: 11" The are hundreds of lines of code describing the error, but they are absolutely no help. From the error, the only thing I see that might be giving clues is at the bottom. It says:
1. While loading members for 'ProfileTableViewController' at <invalid loc>
2. While deserializing decl #101 (PATTERN_BINDING_DECL)
3. While deserializing decl #2 (VAR_DECL)
Oddly, the errors I just typed above are not consistent. The view controller mentioned rotates between the three view controllers where I am using Firebase.
To try to solve the problem, I commented out all of the code in the ProfileTableViewController class, but I still got an error referencing that view controller. The only code running in the view controller was:
import UIKit
import Firebase
import FirebaseDatabase
(I'm also using FirebaseAuth in other view controllers).
What does work to fix the problem is to hit "clean", restart xcode, clean again on launch and then run the program. Everything will work fine unless I make any changes to the code in the program. Even if all I do is add a comment, the error will reappear.
I don't want to have to close xcode and restart every time I write a couple lines of code, and I am worried that I will run into problems when uploading to the app store.
I am using XCode 7.3.1 and my deployment target is 9.3
Any insight you can give is greatly appreciated! Thank you!
I was able to figure it out! My Cocoa Pods were not up to date. As soon as I went back and installed the latest Cocoa Pods in the terminal, then updated the podfile for this app, this error disappeared.
Process:
Open terminal
sudo gem install cocoapods
(Cocoapods update) In terminal navigate to app folder, then:
open -a xcode podfile
If needed, make changes in podfile. I didn't need to make any changes. Save and exit.
In terminal
pod update
Open the .xcworkspace file and ta da!
I was also pulling my hair out with this issue for some time.
I tried Eric Duffett's answer but without luck.
I figured out it was an issue with the FirebaseAuth. What I did was this:
Remove FirebaseAuth from Podfile
Update pods with pod update
Download Firebase frameworks from their site (at the bottom)
Follow README file to import FirebaseAuth manually in the project (need to import FirebaseAuth.framework and GoogleNetworkingUtilities.framework)
Clean - Build and no more segmentation fault 11 error
Hope this will help someone.
This is/was really driving me berserk.
This code causes the aforementioned crash:
func ref() -> FIRStorageReference {
return FIRStorage.storage().reference()
}
If I just use it in a function everything works:
FIRStorage.storage().reference().dataWithMaxSize(...
Took hours to figure this out. The error message points to somewhere else. This was probably the most frustrating debugging experience in my entire career.
In your podfile you can try to uncomment use_frameworks!
use_frameworks!
pod 'Firebase'
pod 'Firebase/Database'
pod 'Firebase/Auth'
Then run 'pod update' in the terminal. Restart your Xcode project.
This did it for me after struggling for two days with the Segmentation fault 11
Deleting DerivedData and ModuleCache, then Clean>Build worked for me.
I also had this problem with Firebase.
Xcode would complain on particular class. Just like your "ProfileTableViewController"
What I did to solve this was:
Comment all Firebase related imports in that class -> Clean -> Build (Obviously got some errors) -> Uncomment -> Clean -> Build succeeded
I figured out a different solution that worked for me. I had a few custom functions that returned Firebase-specific variables like FIRUser to files that didn't have import Firebase or import FirebaseAuth at the top. I like keeping my data service methods in a separate file, so I just changed the functions so that they returned Strings, such as FIRUser.uid, instead. This FINALLY got rid of the compiler warnings/crashes for good.
The problem for me occurred when I was explicitly setting the types of the completion block parameters for setValue.
FIRDatabase.database().reference(withPath: "test").childByAutoId().setValue("test1") { (error: Error?, ref: FIRDatabaseReference) in }
Everything works fine when the types for error and ref are removed.

Using Google Maps SDK with Parse.com Project iOS Swift

Im working on a project (xcode 6.3+, swift) using Parse SDK (parse.com) to handle data.
Recently, we decided to use the google maps sdk to provide user with directions using the direction API. As you can use this API without the google map I started integrating it. It's my first time with cocoapods so I followed the instruction and started playing with.
pod init to create the pod specs file
here is my config coming from google Starting Guide
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.1'
pod 'GoogleMaps'
pod install, then launching the project using the .xworkspace
I directly try to build the project and it returns 34 errors.
the type of error is always the same: Apple Match-O Linker Error
So I start looking at google cause I did the same thing on a blank project and everything was working really good.
I start to find information about the fact that using Parse SDK causes conflicts with the -ObjC linker Flags that GoogleMaps needs to work. most of the answers give two potential solutions:
1. addind the Facebook-iOS-SDK framework
tried this using the framework given by facebook, as well as using cocoapods. not working. I still got errors.
2. Force Loading the GoogleMaps framework by replacing the -ObjC flag by the following
-force_load $(PROJECT_DIR)/Pods/GoogleMaps/Frameworks/GoogleMaps.framework
this returns an error as well:
so now Im quite lost about the way to solve this. Is there anybody that found a way to integrate GoogleMaps SDK with Parse?
UPDATE
I tried a different approach by injecting GoogleMaps without cocoapods. To do this I used this method: GoogleMaps without CocoaPods
It seems to integrate itself properly, but the -ObjC flag remains. Using
-force_load $(PROJECT_DIR)/GoogleMaps.framework/GoogleMaps
is now responding but causing duplicate symbols for architecture x86_64errors.
can't seems to find a way to fix that.
You need to do this
Click on your project (targets)
Click on Build Settings
Under Framework search paths (set your framework path)
Following information for getting framework search paths
Right click on your framework folder (for ex: GoogleMaps.framework)
select Get info
copy the path from General->where and paste this path in your framework search path (path should contain in single line)
Good luck
Ok so I managed to find working solution both for integrating GoogleMaps Sdk and Parse with and without cocoapods. However, the use of the -ObjC flags by GoogleMaps forced me to integrate the FacebookSDK to the equation. I couldn't find a way to make this working without it
So this config is working with xcode 6.3+ and it required to use and older version of the Facebook SDK (when not using cocoapods)
With CocoaPods
1/. Add the Parse SDK as described on their website (existing project version)
2/. Add extra Frameworks (AdSupport, Account and Social) as well as libstdc++.6.dylib
3/. Open terminal to the root folder
4/. $ pod init
5/. open Podfile and replace content with the following:
use_frameworks!
platform :ios, ‘8.0’
pod 'GoogleMaps'
6/. $ pod install then $ pod update
7/. download FacebookSDK from this link
8/. Add FBSDKCoreKit and FBSDKLoginKit Frameworks to your project
9/. build your project.
If some error occurs, you may have to delete ParseFacebookUtils.framework from your project and keep only ParseFacebookUtilsV4.
Without CocoaPods
So this is quite the same procedure except that instead of using pods to install GoogleMaps SDK, you will integrate it manually by using the link mentionned in the question, or by going to GoogleMaps podspecs and access the source url to download the last one.
Make sure to add GoogleMaps.framework, as well as the GoogleMaps.bundle which you can find by right-click on GoogleMaps.framework /show in finder under Resources. Drag and drop to the project and make sure it's linked to the project build settings / Copy Bundle Resources
Also, make sure to have all the required framework and libraries listed on the link provided in the question.
Add the -ObjC flag under Build Settings / Other Linker Flags
When it comes to integrate the FacebookSDK, I've noticed that using the latest version isn't working. Apparently, it was prepared to work with xcode 7. Do work around this, just download an older version here
Add FBSDKCoreKit and FBSDKLoginKit to the project and you should be good to go.
Hope that help someone cause it was a pain to make this work...

Xcode debugger doesn't display variable information after installing CocoaPods Podfile

I just installed CocoaPods and added a pod to my project in Xcode so that I could use the Google Maps SDK for iOS, and now I'm not able to get types or values for any variables in the debugger console. The only way I can see a variable's value is through a print statement in the code.
I'm using Swift 2.0 in Xcode 7.0 beta, and I followed these instructions almost exactly to install the pod into my project: https://developers.google.com/maps/documentation/ios-sdk/start. The only thing I did differently was to change the second line in the Podspec from "platform :ios, '8.1'" to "platform :ios, '9.0'".
I looked at the answers to this similar question: Xcode debugger sometimes doesn't display variable values?, but I was already using a debug build, and I'm pretty sure my problem is related to CocoaPods, because everything was working fine before I added that to my project.
This is known issue, you can find more info and starred isuue here.
TL-DR - Quick workaround:
Add Objective-C bridging header file and add #import <GoogleMaps/GoogleMaps.h>"
Remove all "import GoogleMaps" from your swift files
PS: Tricky stuff - you have to remove all imports from your swift files - I have forgotten to remove the one and it causes this debug issue.
I hade the same problem dunno if you solved it but, for me this happened because googlemaps was causing too many errors. So the workaround is remove all your googlemaps import in the projekt and add an import to googlemaps in your bridging header instead.
Updating to version 1.10.21020.0 of Google Maps SDK for iOS fixed the problem.

Resources