I followed all kinds of tutorials and tried different things, but no help. I successfully installed cocoaPods via Terminal and initialised a pod file. After figuring out how to solve "import Firebase error", now I have difficulties with simple operations like trying to write data into database. Xcode error when trying to write data
My pod file
The new Firebase SDK 3.2.0 has several breaking changes compared to the old version 2.x, therefore the old Quick Start guide is completely obsolete. All classes have been renamed, and the integration process is different. So use new pod file. It will help you.
You can also do it by adding them directly which is also mentioned on there original web site.
You must follow the new guide on firebase.google.com instead.
Related
This is for Firebase 6.26.0 and 6.27.0 (I've tried both for reasons that will become clear)
I have a Swift application I'm trying to decompose into modules from its current monolith, but so far I have not been able to expose Firebase classes across the modules (i.e frameworks) by installing Firebase pods in each individual module. It will only work when there is only one existing library, and when that library is installed in the application target, where it is instantiated in AppDelegate.
Does anyone know if it's possible to implement Firebase across multiple modules in a single workspace?
Expected results
That Firebase classes will be exposed to all modules in a multi-module Swift application, with one or more copies of the Firebase library present, allowing all modules to call Firebase methods and implement Firebase classes within a single, global instance of FirebaseApp.
Actual results
Either Firebase refuses to instantiate because of the presence of more than one Firebase library in the workspace, or, when only one library is present, Firebase classes cannot be exposed to other modules in the workspace.
What I've done
Installed individual Firebase pods in every module requiring them. On launch I got this error:
.
The default FirebaseApp instance must be configured before the defaultFirebaseApp instance can be initialized
.
According to an answer from a Firebase team member on another StackOverflow post, this is caused by the presence of more than one Firebase library in the workspace.
Installed only one pod to create a "FirebaseProxy" module that both the application target and all other modules could share. By using typealiases and extensions I was able to let classes implement Firebase classes without having to be exposed to the actual Firebase library, for example:
import Firebase
public typealias FirebaseUserProxy = Firebase.User
public extension FirebaseUserProxy {}
So this way an implementing class could use the Firebase.User type by using FirebaseUserProxy instead, and without having to be directly exposed to the Firebase library.
.
However, there were some proxied classes that still seemed to require being exposed to the full library. (My brain is a bit addled from dealing with all this so I've forgotten exactly which ones, I believe it was FirebaseApp.) But even using #_exposed import Firebase in the proxy definition didn't do the trick, and I only got the message Missing required module 'Firebase'.
Same solution as in #2, but using use_frameworks! :linkage => :static in my Podfile. No luck. And yes, I did try using $(SRCROOT)/Stat in my frameworks search paths build settings.
Finally I tried integrating the library directly into my project without using Cocoapods. Here I was using 6.26.0 since the Firebase download link with a 6.27.0 in the URL resulted in a Not Found message, so I manually changed it to 6.26.0 and that downloaded fine
.
I installed the library in the application and in another module, hoping that somehow this method would obscure each library from the other, but ended up with the same error message as in #1... The default FirebaseApp...
.
I also tried using the proxy method from #2, but that resulted in the same error.
.
I had to set :linkage => :static in my Podfile so the installed pods would play nicely with the integrated library. Turning it off resulted in an error.
Alternatives
If I can't get this to work, I may have to refactor my code so that the Firebase-dependent code exists in the application itself instead of a standalone framework module. This would not impact functionality, but it would break the architecture and make the code a good deal more convoluted and brittle.
There is a solution on the Firebase git repo (that I haven't tried), that suggests reverting back to v.6.15.0. I am reluctant to do this though since the most recent release is at 6.27.0 and I don't want to be unable to upgrade and risk using an older version that later releases will undoubtedly break eventually.
Finally
It's disappointing that such a widely used and vital tool can only be used in monolith applications, basically limiting developers to a single, often suboptimal, type of architecture. Have I missed something? Maybe. It wouldn't be the first time. But if anyone can light the way out of my dilemma I would be happy to buy you a beer, and given the current social distancing regulations, consume it on your behalf.
I absolutely can not understand how it works. I started with a simple one: created framework using "Cocoa Touch Framework" template and add some code to source files. Then using cocoapods I installed some pods to this framework-project. All looks good (maybe not so good actually) and build fine. After that there was an attempt to connect my framework to other xcode project. I did this as follows: just took my test.framework file from Product folder and transferred to another project. At first everything was not bad. The import was successful and I can use my framework-code in another project. But when I run it I have error: dyld: Library not loaded: Reason: image not found. I tried all of the answers to this problem, but nothing helped me.
After that, it was decided to try to connect my framework to other project. This time I got a completely different behavior: namely, I was able to connect the framework, but I could not access the code inside it. I'm completely confused, because I did not change anything. I just did the same with another project.
Please help me. What am I doing wrong?
A related questions:
Can I connect the framework just moving test.framework file into
another project?
For some reason, I should use the approach described above, is there a chance in the theory of success or all that I have done before is not correct?
I tried it a lot with the same result you get , until I posted the problem in Apple forums and they respond with Nested frameworks are not supported in IOS
I'm currently working on a iOS (Swift) app for which I installed a few Frameworks via Cocoapods.
I have been facing a few issues with one of the frameworks and decided to tweak its code manually to run some tests and see if I could make things work.
I ended up figuring out a way to achieve what I wanted but I had to add a couple files in that framework as well as modify a few others.
This is the first time I do this and I'm almost certain this is no the best way to do things but I wanted to get some advices on how I can maintain that framework (that is behaving the way I want) in the future?
If I run "pod install" again, I suppose the framework and my changes will be overridden...
Any advice would be really appreciated.
Find the source repo (probably on GitHub) and fork it to your own account. Check out that repo and make your changes.
Optionally I would recommend making your adjustments to the code reusable so others can also use your tweaked version (make it configurable so they can turn the additional functionality on or off) and then submit a pull request back to the original repo.
If you don't want to do that you can point your Podfile directly to your customised repo using the following format:
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git'
Or you could look at creating your own CocoaPod (either by publishing to CocoaPods public specs repo or creating your own specs repo).
I have a project which is almost completed in swift 2.2, Now I want to update the code to swift 2.2 to swift 3.0.I am using the Cocoapods for thrid party library integration and need following suggestions:
Should I go ahead update the libraries used first by running pod update? If any lib has not updated to support swift 3 what should i do?
Should I go ahead to update code to swift 3 manually or follow the XCode8 suggestions?
If I directly go for XCode8 suggestions then XCode8 starts giving suggestions to update library source code also.I am searching for the good way to handle all this. Thanks.
There is not a "best" way — as every project is potentially different in how easily it can be converted to an updated version of the language it's written in.
It would be recommended to:
Save a backup copy of the project before attempting to convert/migrate anything.
Follow the Xcode recommendations for updating the code.
Update the dependencies such as Cocoa Pods.
Fix any unresolved issues that might not have worked during the conversion.
Have patience, as often the conversion is not a one-click process.
If some of your libraries haven't been updated to Swift 3.0 then that's no problem, as you can tell the compiler to compiler only that library with the old compiler.
My suggestion, (and indeed how I updated my own projects), is to run the automatic migration wizard. (Editor>Code Syntax>Upgrade to latest Swift syntax). Then you should run pod update making sure to remove any version specifiers in your podfile.
Once you have done both of these things you can open your project and be greeted with a lot of compiler errors, the bigger your project the more you will have; unfortunately this is somewhat unavoidable because the built in migration tool sucks.
Now it is going to be a case of trudging through and fixing these errors, most of them will probably be something really simple like dropping AnyObject for Any, but a few may trip you up.
Now as I mentioned, if a library hasn't yet been updated for Swift 3.0 you can open your Pods project settings and select the library in question. Under build settings you'll find a key called Use legacy Swift syntax. Set this to true and rebuild. This forces the compiler to use the old compiler for this pod only.
I hope this in depth explanation is of help.
I Found some strategy migrating to Swift 3
I migrated directly to Swift 3.0. I use CocoaPods, so I migrated my dependencies first. This means following the steps above for each open source library (or private pod).
So far, the only dependencies I have for this project are my own libraries, which made this quite easy since I control all of the code. However, if you have third-party dependencies, then I would recommend opening an issue on the project to discuss migration plans with the current maintainers. I expect most popular projects are doing something similar to what I described above. For example, AlamoFire has a swift2.3 and swift3.0 branch. If needed, you can fork and migrate third-party libraries yourself — then submit a pull request or use your fork until the maintainers offer a solution. However, you should definitely reach out to project maintainers before submitting a pull request for migration.
Until Xcode 8 is final, you’ll need to point your pods to these new branches:
pod 'MyLibrary', :git => 'https://github.com/username/MyLibrary.git', :branch => 'swift3.0'
This tells CocoaPods to fetch the latest on the swift3.0 branch, instead of the latest published version.
Once your dependencies and Podfile are updated, you can run pod update to bring in the Swift 3.0 versions of each library. Then you can migrate your main app. I suggest commiting all of this migration in a single commit — update all dependencies, migrate your app, then commit — to keep your history clean.
Bugs
Xcode’s migration tool is not perfect.It would sometimes fail to migrate test targets, or only partially migrate app and framework targets. When this happens, you can attempt to run the tool again, but it’s probably best to make changes manually. Here are some of the specific issues that I saw:
Some expressions inside of XCTAssert*() did not migrate.
Some expressions inside closures did not migrate.
Sometimes waitForExpectations(timeout:) did not migrate.
Migrating NSIndexPath to IndexPath when used in certain contexts often resulted in derpy things like (indexPath as! NSIndexPath).section.
Enums with associated NSDate values migrated to case myCase(Foundation.Date) instead of case myCase(Date).
Sometimes optional protocol methods did not migrate, which can produce hard-to-find bugs.
Ref Links :
http://www.jessesquires.com/migrating-to-swift-3/
https://swift.org/migration-guide/
I have followed this tutorial http://attila.tumblr.com/post/21180235691/ios-tutorial-creating-a-chat-room-using-parse-com to create a basic functioning chatroom, however once I had finished and tried to run it I got the error
"Query has outstanding network connections"
I was adding it to an existing project where I call another Parse query so I assumed it was that, so I tried creating a completely new project, that produced the same error.
So I downloaded the example project from the tutorial and ran it, it worked fine. After a lot of playing around I tried using the Parse.framework from the tutorial in my project and it worked! That would be fine but I use parts of the SDK that weren't available in the older SDK, so now I'm completely stuck.
I've uploaded the new project here https://github.com/cstokes/ChatTest it includes the new framework (1.1.29) with the error, the version it works it is 0.4.40. I asked over at Parse.com and got simply "Update your projects SDK to a recent version", obviously I tried it with the newest and get the error.
Thanks in advance for any help or advice.
You're trying to do both a find and a count at the same time with one PFQuery. PFQuery can't do multiple searches at one time. You should make a separate PFQuery for the count.