CocoaPods Error (PubNub) with iOS Static Library Project - ios

I'm working on iOS Static Library Project (9.0). I've decided to include PubNub to my Static Library Project. Steps I followed;
I've downloaded PubNub sample project and builded.
I've copied Framework files (CocoaLumberjack and PubNub) into my Supporting Files folder.
I've closed xCode, and created PodFile in project directory.
Content of PodFile is as follows:
platform :ios, "9.0"
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
pod "PubNub", "~> 4.0"
After installation i get warning for both Debug and Release says;
[!] The xxxIOSFramework [Debug] target overrides the OTHER_LDFLAGS build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
I've opened .xcworkspace and saw both my project and Pods project in tree.
At this point build gives error ld: framework not found Pods
After my re-searches, most says that remove Pods.framework which is highlighted in red, and i did.
After removing Pods.framework, build continues to give error such as; ld: -rpath can only be used when creating a dynamic final linked image
I've moved to Target > Build Settings > Other Linker Flags. ObjC was added, and I also added $(inherited) but error still exists.
Anyone have any idea about getting -rpath can only be used when creating a dynamic final linked image error while adding Cocoapods to iOS Static Library Project? I can provide additional information if you need.
Thank you.

Getting started describes few integration ways and from your question it looks like you used bot of them at once.
If you want to build own static library and integrate PubNub and CocoaLumberjack in it, you should stick to pure CocoaPods approach.
You need to:
Remove added dynamic PubNub and CocoaLumberjack frameworks
Remove !use_framewors from Podfile
Clean up a bit (if you have deintegrate plugin installed for CocoaPods you can call it) by removing workspace, Pods folder and Podfile.lock
Run pod install
This way you should be able to build your own static library with PubNub client code inside.

Related

dyld: Library not loaded: #rpath/Alamofire.framework/Alamofire Referenced from:

I got this error when I ran my app on my phone
enter image description here
When I want to add the missing dynamic library, I find that the library is grayish white. Are all the libraries imported through pod like this? It means that the library is missing. I'm looking forward to your help
enter image description here
Normally you don't have to add the frameworks you installed from your podfile via pod install manually. They are all contained in the Pods framework (in your case Pods_ZSS.framework) and added to your project automatically.
Xcode now tries to add Alamofire.framework a second time and does not find the corresponding header search paths, etc. or does not know, which framework should be used.
Try the following:
Remove the additional import of Alamofire, clean build folder and build again.
If the error still occurs, close Xcode and run pod install via terminal in your project folder. This configures your Pods project and adds the dependencies to your main project for you.
Also check, if the target define in your podfile exactly matches the name of your target in Xcode. E.g. your target in Xcode is named 'SSZ', then your podfile should look something like this:
platform :ios, '<your_target_deployment_version>'
# Imports for target 'SSZ'
target 'SSZ' do
# Use dynamic frameworks
use_frameworks!
# Frameworks
pod 'Alamofire', '<specified_framework_version>'
pod '<second_framework>', '<specified_framework_version>'
pod '<third_framework>', '<specified_framework_version>'
# so on and on
end
Also remember to open the project's workspace generated after running pod install (<project_name>.xcworkspace). Otherwise Xcode will not build and integrate your frameworks when building your app. <project_name>.xcodeproj just contains your own project without the frameworks.

Cocoapods causing "library not found" and header "file not found" errors for Xcode Simulator but not device

I'm using Cocoapods with my Xcode project, but it seems to be causing both "library not found" and header "file not found" errors when building with the Simulator but not when I have a device connected nor when using "Generic iOS Device".
My Podfile is simple. I have only one pod in there, for Microsoft's ADAL SDK, needed for single sign-on. When I use use_frameworks! in the Podfile I get:
fatal error: 'ADAL/ADAL.h' file not found
for the line
#import <ADAL/ADAL.h>
but if I use use_modular_headers! instead of use_frameworks! I get:
ld: warning: directory not found for option '-L/Users/memyself/Documents/iOS_Projects/ASSIST-main/ASSIST-main/DerivedData/MyApp/Build/Products/Debug-iphonesimulator/ADAL'
ld: library not found for -lADAL
Even if I disable both of those it builds fine for the device and for "Generic iOS Device", but fails with 'ADAL/ADAL.h' file not found error.
Yes, there are plenty of SO questions and answers for those kinds of errors (such as here) but no success trying them. To be specific, I'm using $(inherited) in the recommended search paths, setting enable bitcode to NO, making sure I'm opening the xcworkspace not the xcodeproj file, and have tried
$ pod deintegrate
$ pod clean
$ rm Podfile
Also, my app uses AWS and Firebase and I was getting the same problem with them, but was able to fix them by manually adding the necessary frameworks. However, I don't have a framework for ADAL, and frankly I need to fix this so I can use Cocoapods to install and manage my AWS and Firebase dependencies. It is very suspicious that it only fails when building for the Simulator, what project settings could cause this?
Update the deployment target and the Podfile 'platform' target. Update both from 9.0 to 11.0. Change this line in your Podfile
platform :ios, '11.0'
and this in both your Target and Project:
Try changing build active architecture only in build settings.

How to manually import third party Swift framework into Swift iOS project?

I am trying to import and use the OAuthSwift library in the Swift iOS project. I followed their directions:
Drag OAuthSwift.xcodeproj to your project in the Project Navigator.
Select your project and then your app target. Open the Build Phases panel.
Expand the Target Dependencies group, and add OAuthSwift framework.
import OAuthSwift whenever you want to use OAuthSwift.
After completing these steps, importing OAuthSwift using import OAuthSwift causes the error No such module 'OAuthSwift' and the project fails to build.
I have tried the following steps, based on a number of other SO questions about similar issues:
Clean and rebuild
Add the OAuthSwift framework to many different combinations of Build Phases > Target Dependencies, Build Phases > Link Binary With Libraries, Build Phases > Embed Frameworks, and General > Embedded Libraries
Set Build Settings > Search Paths > Framework Search Paths and Build Settings > Search Paths > Library Search Paths to $(SRCROOT) and recursive.
Verify that my deployment target matches the deployment target of the OAuthSwift Xcode project.
I have tested this using the latest version of OAuthSwift from their master branch using a git submodule, as well as manually downloading and importing each of the two latest tagged versions (0.6.0 and 0.5.2).
I have also created a brand new Xcode project, imported OAuthSwift as above, and encountered the same error.
Finally, I also tried importing a different Swift Framework (Alamofire), following the steps as stated on the README at https://github.com/Alamofire/Alamofire. This caused the same error as well: No such module 'Alamofire'.
I am using:
OSX 10.11.6
Xcode 7.3.1
Swift 2.2
I'm still fairly new to Xcode and the Swift module system, so any help or suggestions is appreciated.
Your life will be a lot easier if you import the framework using CocoaPods. If you haven't used them before, it's really easy once you get set-up. You use Ruby Gems on the command line to install CocoaPods (sudo gem install cocoapods) and then create a create a pod file using pod init. After this you modify it to include:
platform :ios, '8.0'
use_frameworks!
pod 'OAuthSwift', '~> 0.5.0'
Save the file and run pod install.
Once this is complete you will have to close out the Xcode project and use the newly created .xcworkspace project file (not the .xcodeproj) from here forward.
Here is a link to another post for a secondary reference.
How to install cocoapods?

Cocoapods Completely Broke

To start: I'm using Cocoapods 0.37.2, XCode 6.3.1 compiling for iOS 8.3
My project worked just fine before I ran a basic "pod update" now it's completely refusing to compile. I'm quite positive this has nothing to do with the pods themselves. Specifically the error I'm getting is this:
ld: warning: directory not found for option '-F/Users/user_name/Library/Developer/Xcode/DerivedData/AppName-bjozswzeepmhacfkeimeepxzcxgb/Build/Products/Debug-iphoneos/include'
ld: library not found for -lPods-AppName-AFNetworking
Podfile is this:
# Uncomment this line to define a global platform for your project
platform :ios, "8.0"
def shared_pods
pod 'SocketRocket'
pod 'AFNetworking'
pod 'DateTools'
pod 'Spotify-iOS-SDK'
end
target "AppName" do
shared_pods
end
target "AppNameTests" do
shared_pods
end
I have cleared DerivedData (many many times), cleaned my builds, restarted XCode, restarted my machine, I have ensured my config files and linker config lists are set up correctly. I've been using Cocoapods for years and never had this much trouble.
Completely frustrated and confused... questioning sanity.
Any help?
Information from CocoaPods troubleshooting doc. Hope this helps you.
If Xcode complains when linking, e.g. Library not found for -lPods, it
doesn't detect the implicit dependencies:
Go to Product > Edit Scheme
Click on Build
Add the Pods static
library, and make sure it's at the top of the list
Clean and build again
If that doesn't work, verify that the source for the spec you
are trying to include has been pulled from GitHub. Do this by looking
in /Pods/. If it
is empty (it should not be), verify that the
~/.cocoapods/master//.podspec has the correct git hub url
in it.
If still doesn't work, check your Xcode build locations
settings. Go to Preferences -> Locations -> Derived Data -> Advanced
and set build location to "Relative to Workspace".

Undefined symbols for architecture armv7 for Cocoapods libraries

I stumbled upon a problem on a project that I need to work on. The project use Cocoapods for managing its libraries. I run pod install as usual to get started but xcode give me errors. I got Undefined symbols for architecture armv7 as you can see in the image below:
All this symbols are the libraries that I use with my project. Eg. AFNetworking, RNBlurModalView. I tried to remove all the Cocoapods related file from the project and running pod install again, but it still doesn't solved the problem.
What I have done so far:
Clean the project and build again.
Removing Cocoapods related files and running pod install again.
Tried to add the class in Compile Sources in Project Target, but can't. The class is in Pods workspace.
Set Build Active Architecture Only from YES to NO.
I also try the solutions from the same problem, but none of it is working for me.
If it helps, I'm using xCode6 and Cocoapods 0.34.4. The project valid architectures is armv7 and armv7s.
Update: When running pod install --verbose
Integrating client project
Integrating target `Pods` (`AIYOCore.xcodeproj` project)
[!] The use of implicit sources has been deprecated. To continue using all of the sources currently on your machine, add the following to the top of your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
[!] The `Project [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Project [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
Thanks in advance.
It seems like you don't have $(inherited) in OTHER LINKER FLAGS. Please post output of the pod install
You may just need to clean the build folder (⌥⇧⌘K).

Resources