I'm currently integrating a private library from vendor which they mentioned it's required to have use_framework! added in Podfile. Apparently I found out from them, the framework is written in Objective-C, if so.. why is use_framework! needed? I thought this is the reason why we use use_framework!
use_frameworks tells CocoaPods that you want to use Frameworks instead of Static Libraries. Since Swift does not support Static Libraries you have to use frameworks.
Currently I'm facing this build time issue 'React/RCTBridgeDelegate.h' not found in AppDelegate.h
Side info,
My project is running on React Native Firebase v6, hence I have added # $RNFirebaseAsStaticFramework = true to handle the use_framework! case. Read more about this here.
I'll get the following error if I don't append use_framework!
Framework not found helloFramework
Here's the Xcode error . . . .
I confirmed my project's scheme has the React Bulleyes icon from podfile and I'm building on this scheme
My questions, why do I get this issue when I use use_frameworks! ? What's is the correct way to handle this issue?
Update:
Created issue at React Native Github
TLDR
Append $(inherited) at Framework Search Paths .
Explanation
Apparently, when we apply use_frameworks! at Podfile. Our Xcode project will replace libPods-{projectName}.a with Pods_{projectName}.framework.
Since our project is relying on Frameworks to build, we have to append $(inherited) to Framework Search Paths at Target > Build Settings > Search Paths > Framework Search Paths. This will inherit the build settings from project level to target level. Read more here.
Related
I'm working on a rather large iOS project that was originally written in Objective-C and we're now starting to add in Swift code. We are using Cocoapods to install 3rd party libraries and have included use_frameworks! in our Podfile.
In some of our Objective-C classes, we have added module imports at the top such as #import AFNetworking;
Usually, on first build of the project within Xcode, the build fails and we see module 'AFNetworking' not found but on the second build, it works fine. However, now I am trying to get Fastlane to do our builds and when using Fastlane to do the builds, we get the error 100% of the time.
In the build settings of the target:
Enable Modules (C and Objective-C) is set to Yes
Always Search User Paths is set to No
User Header Search Paths is set to $(SRCROOT)/Pods and is recursive
Any suggestions on what else I can check/try?
Have you tried checking "Other Linker Flags" to see if it has the -ObjC value in it?
You can click on your project name on your Navigator, go to Build Settings, scroll down to Linking section and double check on "Other Linker Flags" stated. If it is not there, you can manually add to it.
Today I finally found the solution to the problem. Our project is made up of multiple targets (10+) and we noticed that only the one target was failing to build. After hours of hunting around, comparing files we finally looked at the schemes and noticed that the target that wasn't working was using a scheme that had Find Implicit Dependencies unchecked. We checked this and it started to build again!
Just to note, the target would build if we built it after building one of the other targets but if you then deleted the derived data and tried to build the target then, it would fail.
I create a framework that use AFNetworking (installed with pod).
I can import this framework on my project and I can use all classes/methods that I exposed, so project compile.
When I try to run project on simulator, I obtain this error:
dyld: Library not loaded: #rpath/AFNetworking.framework/AFNetworking
Referenced from:
/Users/.../Library/Developer/CoreSimulator/Devices/F56F98F0-2AE0-4C87-AC9A-6E3B449762D1/data/Containers/Bundle/Application/BFA5359F-8FCE-4402-8487-CD9C002CB673/MyProject.app/Frameworks/MyFramework.framework/MyFramework
Reason: image not found
I already included 'MyFramework' under:
Build phases -> Embed Frameworks
I suppose I missing something on building Frameworks, but I can find out what! I already seen this unanswered question.
Who can I use MyFramework without installing Pod on MyProject again?
It is really delayed, for this issue but I have got my project working. It might not be the best way but it works. I am putting it here for future reference.
I wanted to do it without using Pods in the main project. The reasoning is, we are bundling our SDK into a framework.
So essentially, the first step I took was to get the framework project bundling without using the workspace. I just dragged the Pods project into the framework project.
Then I added the frameworks the the pods project creates and add them to my framework. I set them to optional and code sign. You can see them in the picture of where I added them under the build phases.
Then add them to your main project. not the framework the normal way by adding the project and or the framework. Then add it to the Embedded binaries and Linked Frameworks.
If it helps anyone, the solution mentioned by #ArtyomDevyatov does work. The trick is that you have to add 's.dependency' in podspec file.
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...
I added pod 'CrittercismSDK' to my Podfile and ran pod install, it finished with no error, all good.
Using import Crittercism gives No such module error. I looked into the Pods/ directory, there source code is there; however, the Pods project doesn't have a target called Pods-MyProject-Crittercism (but it does have targets for each dependency).
Build keeps failing because the import isn't found. What am I doing wrong?
PS: I'm using use_frameworks! directive in my Podfile, and I have another obj-c library that works fine, so I don't know why this one isn't working.
While this is not a general answer, I have found that:
Not using #use_frameworks
Using a Bridging-Header.h containing #import "Crittercism.h"
Not importing CrittercismSDK in the Swift class, but merely executing Crittercism.enableWithAppID("appId") does the trick.
See if below steps helps in your case. What version of pod/Xcode in use? It will be great if you can share your pod file, thanks.
Install dependencies using Cocoapods and the use_frameworks! flag.
As you need to use a Objective-C dependency, create a Bridging header. You can create one easily by importing an Objective-C class to your Swift project, than remove it (the wizard should ask you if need a bridging header). Otherwise, create a new header file. Then, navigate to your target configuration and enter the name of your file in Swift Compiler - Code Generation > Objective-C Bridging header.
Still in your target configuration, add a new entry in Search Paths > User Header Search Paths: Pods as value and flag it as recursive.
Remove any import instruction from your code, relative to your Objective-C library.
Build your project. You should have a success.
I have Xcode 6.3, using Swift, importing a Parse 1.7.1 Framework as usual (dragging, copying) and I set it up in a group: Frameworks.
I compile and everything works fine for a while with it, until the compiler does not recognize this sentence anymore:
import Parse
It gives me the error:
No such module 'Parse'
A workaround is to delete the Framework and copy it again, but after a while it starts getting annoying, and I would really like to know the cause.
I only code and build in the meantime (and occasionally creating new swift files), so I can't explain why this happens.
If you're targeting iOS 8 and above, you can tell Cocoapods to use frameworks, by putting
use_frameworks!
in your Podfile, like this example:
use_frameworks!
platform :ios, '8.0'
# Parse
pod 'Parse', '~> 1.7'
I could fix the same problem by doing so.
I just fixed this same issue today with my project. I imported my obj-c framework in a swift project and it worked for a while, then xcode seemed to forget it causing the same error you have.
apple docs
I fixed it by referencing the bridging header in Build Settings.
Under Build Settings, make sure the Objective-C Bridging Header build
setting under Swift Compiler - Code Generation has a path to the
header. The path should be relative to your project, similar to the
way your Info.plist path is specified in Build Settings. In most
cases, you should not need to modify this setting.
I just typed in the name of the bridging header folderName/xxxx-BridgingHeader.h in the field that states bridging header and all was well again.