Podfile usage for iOS apps - ios

I'm very new to using podfiles and have a bit of confusion around how they work and what I need to do to use them. I have followed the 'Getting Started' section on the main website and have successfully created a podfile and run install to pull in the dependencies. The questions I have are as follows:
I see a new section in my project which appears to list the pods i've requested, however they all seem to be in red - is that normal? If not what have I done wrong / what do I need to do?
In terms of some of the Core iOS frameworks (e.g. UIKit, Foundation, etc.) do I still need to manually import them as frameworks into my project? Can I add them to my podfile so I can manage everything in a single place? If so how (does the syntax vary/differ?)?

They appear as red because this frameworks not built yet. After you build project they should look normal.
Yes, CocoaPods only handle third-party dependencies.

Related

How to add or read Google calendar events iOS [Swift] without using Cocoa Pods

I am currently working on integrating Google Calendar into my iOS project which uses GoogleAPIClientForREST And GoogleSignIn libraries. Project Git can be found here. I am able to add or read all my Google calendar events.
However, I have been asked to make it work without using Cocoa Pods. I have added all the necessary frameworks by dragging and dropping into my project, it builds and runs but I'm getting a crash at this line (attached screen shot for ref) GIDSignIn.sharedInstance().scopes = [kGTLRAuthScopeCalendar] .
Here's working screenshot where am getting the kGTLRAuthScopeCalendar element in array. (Using Cocoa Pods)
Here's screenshot where am getting a crash because the kGTLRAuthScopeCalendar element in array has 0 values. (Without Using Cocoa Pods)
Does anyone have any idea what I might have missed, or am I wrong in my implementation without CocoaPods if yes, how?. Please help.
SO links previously referred: 1. How to Create events using Google Calendar API iOS Swift , 2.https://code.tutsplus.com/tutorials/ios-sdk-working-with-google-calendars--mobile-19155
Does anyone have any idea what I might have missed, or am I wrong in my implementation without CocoaPods if yes, how?
Cocoapods is just a dependency manager and distribution mechanism — it doesn't add any actual functionality to your code on its own. You could simply remove the Podfile from your project and you'd be left with a working project that no longer "uses Cocoapods."
One of the lovely things about a dependency manager like Cocoapods is that it manages not only the things that your project needs directly, but also the things that those dependencies need, and so on. There are only two pods listed in your Podfile, but your Podfile.lock shows about 18 pods because the two that you use directly each depend on other pods.
I don't think there's nearly enough information in your post to let us really understand what specific thing(s) you've missed in removing Cocoapods, but from your screenshot it looks like you only have about six frameworks installed in your project while, again, your Podfile.lock shows many more pods than that. It may be that some of the frameworks you need are embedded inside top level ones in your project, but the fact that your project doesn't work correctly even though you're presumably using exactly the same source code is a strong indication that you've left out one or more of the frameworks you need.
Go through the list of pods in Podfile.lock and make sure that the framework each one specifies is included in your new project.

Can't Use "Vendored Framework" CocoaPod Inside Workspace Playground

I've created a sample project illustrating my issue here.
In summary, I'm trying to use a "vendored framework" CocoaPod inside a workspace playground. I think this is possible but requires a bit of fiddling with project settings, and I can't quite figure out what to change.
To observe the issue in the sample project, do the following:
Open CocoaPods-Test/CocoaPods-Test.xcworkspace in Xcode.
Pods should be installed and committed in the repository, but can run pod install if necessary.
Note that the CocoaPods-Test target builds and runs successfully, importing PromiseKit and TwilioChatClient pods.
Navigate to Playground.playground within the workspace.
Note that the playground executes fine while importing PromiseKit but if TwilioChatClient is imported, playground execution fails with "no such module 'TwilioChatClient'".
After reading the following resources:
https://github.com/CocoaPods/CocoaPods/issues/5334
https://github.com/CocoaPods/CocoaPods/issues/5215
https://github.com/CocoaPods/CocoaPods/issues/5563
https://github.com/CocoaPods/swift/issues/3
https://github.com/CocoaPods/CocoaPods/issues/4135
https://github.com/CocoaPods/CocoaPods/issues/2240
https://github.com/CocoaPods/CocoaPods/issues/6669#issuecomment-300188519
https://guides.cocoapods.org/using/troubleshooting.html
https://www.objc.io/issues/6-build-tools/cocoapods-under-the-hood/
I think the issue is probably related to the fact that TwilioChatClient is a "vendored framework" (see its podspec), which means a pod target is not created for it. After reading the above resources, I feel like a solution is within reach, but I can't quite figure it out.
While the sample project here illustrates what I think is the underlying issue, the issue that prompted me to create this example project is just a small bit more complicated.
In my project, I create a framework target containing all my app's code (so it can be imported into my app and also into my playgrounds using app resources). This framework then has pod dependencies, including PromiseKit and TwilioChatClient. The execution error in the playground is different ("Couldn't lookup symbols" instead of "no such module"), as I am not importing the CocoaPods module directly but my framework which uses the pod framework.
I suspect if I can solve the "no such module" issue, it will help me solve my "couldn't lookup symbols" issue.
Finally, this seems like a good opportunity to make an open source contribution others don't seem to have wanted to do (see discussion here). Tangentially, I'd love to contribute but just don't feel like I understand what exactly is going on with CocoaPods, the Xcode build process, etc., after reading about it a bit (e.g. here and here). Any references to help understand the Xcode build process and what CocoaPods is doing under the hood are appreciated. It seems like the resources I've found are either "a very high level overview" (which I get), or "digging through the source code", with not a whole lot in between.
If you must have this work, I came up with a workaround by creating a framework target inside the Pods project which is named the same as the vendor framework, and uses all its headers publicly, using the framework as a sole dependency. I have forked your GH example and linked it here.
It's not the most elegant solution, but it will help you out in a pinch.
UPDATE
Build "fake" framework first, then build app target, then go to playground.

Xcode Cocoapods Not Finding Framework Header Files

So I am working on an old Xcode project that was developed by a separate developer and am having build errors when running on my Mac due to Cocoapods. The first error is "The sandbox is not in sync with the Podfile.lock”, which I can fix by removing the various Cocoapods files and the old xcworkspace from the project and running pod install in the terminal to create all of this again. The new issue is that some of the classes cannot find the header files from the podfile's listed frameworks.
My theory is because this is an old project and the old developer didn't put version caps on some of the frameworks in the podfile, is that the project is trying to use old methods / classes that are deprecated in the newest updated frameworks. However I am not sure how to get around this as I tried putting version caps on those frameworks in the podfile without any success.
There are two paths:
You investigate each framework, estimate the approximate pod version that could have been used at the time project was active, and use particular version of each pod (you can find info on configuring pod version here
This solution won't work in 90% of cases, however, as iOS is evolving really fast and old frameworks are most probably outdated and not compatible with latest changes.
You investigate each framework and understand what actually changed. You look at headers that each pod has, understand what actually changed and implement changes in your code.
You start with headers, making sure that you include the right ones, and then start migrating code to the newest versions.
Big projects usually have migration guides.
There are no other options. As soon as any project becomes dependant on external code, it's up to developers to ensure that it's up-to-date.

iOS - update a framework

I built an app that uses a third party SDK. Recently I had to update the SDK with a new version. I removed the framework files from my application folder, copied the new ones, added them to the project, but it seems XCode is caching the old version.
I tried Clean, tried to delete Derived Data, nothing works. At this point it seems the only available option is to recreate the project and import all the source files. Obviously I am not keen on that. There must be an easy, fast solution to this issue.
Any clue?
Cocoa pods are easy to use and install.
CocoaPods is the dependency manager for Objective-C projects. It has
thousands of libraries and can help you scale your projects elegantly.
Ultimately, its goal is to improve discoverability of, and engagement
in, third party open-source libraries, by creating a more centralized
ecosystem.
However the frameworks need to be compatible with cocoa pods which most libraries are. You use terminal to install. This site may give you an idea how to install it.
Fixed it. I deleted all copies of the old SDK, whether or not they were in my project folder. Seems like XCode was linking to one of them... Another mystery.

How to install projects without cocoa pods?

I have seen various libraries on GitHub that look useful, but only list CocoaPods as an install method. I'm not sure I want to be dependent on CocoaPods, because I'm wary of Apple breaking it in some future OS X/Xcode update. Is there a way to get these libraries into my Xcode project without using CocoaPods?
Role of CocoaPods is to automate and simplify the process, but you don't need to use CocoaPods if you don't want to.
In case of "manual installation", usually it would be:
download the project from GitHub
add the files to Xcode
import headers
But there is no universal recipe for every project, it may slightly differ from case to case, but usually it boils down to previously mentioned.
The best way if you don't want to use CocoaPods is to read the project documentation, and study examples if there are any.
Of course there is. Basically you need to download the library project, drag the project into your own project, do some library dependency setup and you're done.
For details, check out https://github.com/Alamofire/Alamofire for manually adding a Swift library. And https://github.com/jverkoey/ObjQREncoder for manually adding a Objective-C library to your project.
The only way to install things without Cocoapods is to just drag the source code of other projects into your class. For example, most Github projects can be installed via Cocoapods, or you can just drag the relevant source code into your projects. You don't need to drag in all of the project resources, all you need is usually class files

Resources