Alamofire not available after pod install - ios

I am trying to use Alamofire in a swift file that is part of a hybrid (Obj-c/Swift) application. I added a reference to my pod file and ran 'pod install'
When I try to import Alamofire into my Swift file, I get a compile error and Alamofire is not in code completion. Here is my pod file:
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
# Uncomment this line if you're using Swift
use_frameworks!
target 'TheProjectName' do
pod 'Alamofire', '~> 3.4'
end
When I return to my Swift file, I should be able to add the following statement:
import Alamofire
but I cannot because Alamofire is not found. The message is
no such module 'Alamofire'
I have verified that Alamofire is in my pods directory and appears to have been installed correctly. There are no error messages of any kind when running 'pod install'
Any ideas or suggestions of how to solve this? Thanks!

Build your project before you attempt to import after pods install.

Every time I cloned a working project that integrated with Alamofire (from CocoaPods) I encounter this same "unhooked" framework compiler error. I would perform various actions: uninstall / reinstall, open/close; close Xcode - deintegrate - delete files - install - update - open Xcode - clean, build for "generic" - build for simulator, etc. as suggested. Never quite certain if it was going to fix the issue, but eventually it might. Tonight, it was exceptionally stubborn and this is what I truly believe fixed it ...
In Xcode,
locate the file Alamofire.swift in the Project Navigator
delete the file from Alamofire folder under the framework (remove reference, do NOT toss in the trash)
add new file (right click on Alamofire folder) and navigate to find the Alamofire.swift file
Build-to-run on Simulator (my case I used iPhone 12) and voila it compiled successfully.

Related

Install native iOS pod in flutter

I am facing an error while making a flutter plugin on the iOS side while using pods. The pods are installed successfully then also I am able to import them in the file.
The pod in my case which I am trying to use is Freshchat iOS SDK
Steps I have followed to install the pod
Start a new Flutter plugin project.
In .podspec file add s.dependency 'FreshchatSDK'
Run pod install in example/ios folder.
I got an error
The 'Pods-Runner' target has transitive dependencies that include statically linked binaries: (/Users/nimish/FlutterProjects/freshchat_flutter/freshchat_flutter/example/ios/Pods/FreshchatSDK/FreshchatSDK/libFDFreshchatSDK.a)
I removed use_frameworks! from podfile following this comment .
I ran pod install again and the pods were successfully installed and Pods folder was created which had FreshchatSDK folder in it.
Now I need to have use_frameworks! in my project because other plugins are not compiling because of this.
I added s.static_framework = true in .podspec and use_frameworks! in podfile. Now pod install ran successfully,
After I added the import #import "FreshchatSDK.h" in my Plugin.h file I got the error
error: include of non-modular header inside framework module
I tried this answer but was not able to resolve it.
Please help me resolve this. I'll be respectful of your time.
There is another flutter plugin available here but it has many issues and one unhandled case is making my iOS app crash so I want to make it my own.
There may be problems in the PodFile due to unmatched Targets.
When this happens to me, I used these simple steps.
Delete Podfile
Open Terminal at the specific file
Pod init
Open Podfile and adds Dependencies
Pod install

Parse SDK / CocoaPods

I have an objective C iOS app using the Parse SDK.
In the process of moving this app from Parse.com to a self hosted Parse-Server, I need to update the Parse SDK to the latest version. For this update I decided to go with CocoaPods.
This is the first time I touch CocoaPods (after reading and hearing so much good about it).
I found my way, following what I could read here and also based on a few CocoaPods tutorial I quickly viewed.
Having my project "ready", when buiding it I get this error:
#import <ParseUI/ParseUI.h> -----> File not found.
Obviously things have changed place. And I tried a couple of unsuccessful solutions.
So here is my question:
How do I need to change the settings of my project, now that I am using CocoaPods?
In order to use Cocoapods with parse and Parse UI you need to do the following steps:
Create a new file and name it Podfile. This file should be located on your IOS project root folder.
The Podfile should contain at least the following structure if you want to use parse IOS SDK and ParseUI
platform :ios, '8.0'
use_frameworks!
pod 'Parse'
pod 'ParseUI'
# Put more pods in here..
Notice to the platform, you may change it to the minimum version that your app can run on and the use_frameworks! will install all your pod as frameworks and this is mandatory if you like to consume Swift libraries.
Open terminal and navigate to your IOS root directory and enter pod install. This command will install all the pods and dependencies into your project.
After installing you will no longer use the IOS project file from now on you will use a new file which called workspace. The workspace will contain both your project files and the pods project/frameworks files.
Build your project, fix some error (if there are) and run it to make sure that it works as expected .
More CocoaPods commands that you need to know are:
pod update - update all your pods to the latest release or to the release that was mentioned in the Podfile
pod update update specific pod to the latest release or to the release that was mentioned in the Podfile
pod outdated - display out to date pods that are being used inside your project.

Swift Framework Added via Cocoapods into Objective-C App - "Module not found"

In Xcode 8 I'm having trouble importing any Swift 2.3 or 3 framework that was added with Cocoapods into my project.
There is a public umbrella.h file, but for some reason Xcode can't find the framework when I try to #import it.
As an example, create any Objective-C project, use the following Podfile, pod install, and then try the #import. It asks me to update the code to swift 2.3 or 3 even if that code is already Swift 2.3 or Swift 3 code. I've cleaned and tried to rebuild as well.
platform :ios, '8.0'
use_frameworks!
target 'testingFrameworks' do
pod 'SwiftyJSON'
end
Did I miss a step?
I used socketIO and was having the same problem. My solution to this is:
Close project.
Delete pod files, delivered files, pod framework, workspace file (clean up project)
pod install
Reopen workspace, upgrade swift syntax if xcode ask for, build a few times.
You might need to fix something for the new swift.

Parse framework keeps unlinking

Every time I open my XCode project in XCode 7.1.1, I get the error: "No such module Parse" wherever I import Parse.
However, I have the Parse framework correctly added in my Build Phases, and the only way to fix this is by deleting the Parse framework listed in my Build Phases and re-adding it like I did the first time.
I have to do this every time I reopen an XCode project, and it's extremely annoying, but able to be worked around. Does anyone have any permanent fixes for this?
Thank you!
I suggest using CocoaPods to install Parse for Swift using the following Podfile:
platform :ios, "8.0"
use_frameworks!
pod 'Parse'
Parse can then be installed with
pod install

Pod CoreData+MagicalRecord.h file not found

I recently had to delete a xcode project from my computer and re-clone it down. After cloning it, I ran a pod install and then went to build the project. However, I kept hitting a error in my .pch file that claimed a file (a pod file) was not found.
I looked into the following SO posts:
iOS - Build fails with CocoaPods cannot find header files
Unit Test build failing when importing MagicalRecord
From there I gathered that I needed to add to Header Search Paths the $(inherited) flag. I've done that, I've cleaned the project, and then re-built it, and still am having the following error..
As of version 2.3.0 (released on 1 June 2015) the file CoreData+MagicalRecord.h seems to have been renamed to MagicalRecord.h only.
If you installed MagicalRecord using CocoaPods and ran pod install or pod update again you might have gotten this new version and will end up with the same error message: CoreData+MagicalRecord.h file not found
So you should change the import of the header in your pch file then. This is what I have now:
Try to add this line on top of your podfile:
link_with ['ProjectName', 'ProjectNameTests']
before this line
platform :ios, '8.0'
Install pod, and at your project Build Setting->Other Linker Flags, add $(inherited).
import "MagicalRecord/MagicalRecord.h"
Try to run command (1) in terminal, then add import in step (2)
In your project directory,run pod update
You should now be able to add
#import <MagicalRecord/CoreData+MagicalRecord.h>
to any of your target's source files and begin using MagicalRecord!
I think with 2 steps you can be solved this problem.

Resources