Adding Bolts Framework to Custom Swift Framework Error - ios

I'm trying to create a custom Swift Framework. Within that Framework I've added the Bolts Framework. When trying to use my new Swift Framework in another projects, I get the following error:
framework not found Bolts for architecture x86_64
linker command failed with exit code 1 (use -v to see invocation)
Interesting part is that other Frameworks included (Parse) load fine, its just Bolts that is having the issue. I've tried changing the Build Active Architectures settings already.
Thanks

Use CocoaPods for including your other frameworks. Bolts will then be automatically installed through Parse.

Create new Copy Files Phase by going to:
Project Settings -> Build Phases -> + -> New Copy Files Phase. Expand the Copy Files Phase and set destination to Frameworks. Then click on the little + icon and select Bolts framework. Also add it to the linked frameworks and libraries if its not added.
The error you are experiencing is thrown when the framework you use is not in the Frameworks folder that your app uses.

Related

Xcode project giving pod file error for FIRAnalyticsConnector.framework . How to solve it?

I'm working on a book project and the project is connected by API . I'm working on the book app which has different libraries imported from the various places.
Recently, i cloned the project from bitbucket in Xcode and tried to run it. The result i got i error as follows:
enter image description here
It shows :
ld: in /Users/ishinfoservices/Documents/vadltaldhambooks/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector(FIRAnalyticsConnector_a8eeba373b74508311b8b22b8d3202a6.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/ishinfoservices/Documents/vadltaldhambooks/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Help needed to fix the error, as the project has lots of mixes of old libraries along with .h and .m files, the swift files with wireframes
According to the image I saw that you are trying run the app on the iOS simulator, then you could try to add the arm64 to the Excluded Architectures on the Build Settings section of your project or target, it would be like:
Take in mind that if you use Cocoa Pods is possible that also you should add the arm64 to the Exclude Architectures into the Pods project
After the above, clean, build and run the project on the iOS simulator, is possible that on your physical device you must remove the arm64 from the Exclude Architectures, it could depend on what you use in your project.
On the other hand, you can try the following: Select the project -> Select the target -> Go to the Build Phases -> Expand the Link Binary with libraries and add all pod libraries (remove if they exist in embedded binaries or Remove the old FrameWorks), after that, clean and build the project

Missing required module when importing a framework that includes a nested internal framework

I have two Xcode 11.3.1 projects for iOS 13.2:
MyFramework: for generating a framework from Swift and Objective-C source files of mine. This source code uses OpenSSL framework, which is embedded in MyFramework using "Embed & Sign" option, so MyFramework is a framework that has a nested framework (OpenSSL).
TestApp: a swift application that imports MyFramework (and doesn't need OpenSSL functionality).
When I compile MyFramework, the following directory is created in MyFramework Products directory (Xcode correctly includes OpenSSL submodule inside MyFramework):
MyFramework.framework/Frameworks/OpenSSL.framework
Curiously, Modules and Headers directories are missing in "OpenSSL.framework" (have not been copied from the original OpenSSL.framework), but this seems good to me because I don't want to use OpenSSL functionality directly in my TestApp.
However, when I add MyFramework to TestApp and try to compile it, I get the error "Missing required module 'OpenSSL'" in the swift file where the line "import MyFramework" is. This means MyFramework has been correcty found but OpenSSL hasn't.
If I manually add the file MyFramework.framework/Frameworks/OpenSSL.framework/Modules/module.modulemap with the following content (no headers, no exports), then the problem is gone:
framework module OpenSSL {}
Is there a better solution? Why are "Modules" and "Headers" directories not copied? Why is OpenSSL needed in TestApp at compilation time?
Additional note (06-09-2020):
I forgot to mention an important detail. TestApp is able to find OpenSSL framework because I manually added the following path to "Framework Search Paths" in TestApp build setings:
$(PROJECT_DIR)/Frameworks/MyFramework.framework/Frameworks
This puzzles me. If a framework has nested frameworks, why are they not included automatically in searching paths?
I found these questions related to umbrella frameworks in iOS:
Signing embedded framework not working in Xcode 11.2.1
iOS 8+ framework with nested embedded framework
Could MyFramework be considered an umbrella framework and Xcode is not fully prepared for such cases?

Not able to link a Carthage framework to Xcode project

I am trying to link a new framework downloaded via Carthage to one of my project but getting a linker error:
I'm following these steps:
Updated the Cartfile with the framework location.
Run carthage update command to fetch the framework.
Under project target -> Build Phase added a new Run script and renamed it to Framework Copy.
Added the script to copy the framework from the file system : $(SRCROOT)/Carthage/Build/iOS/CleanroomLogger.framework.
Dragged and dropped the framework from the mentioned location under Link Binary With Libraries section of project target -> Build Phase.
Double checked the Framework Search Path under build settings and it seems to be set correctly : $(PROJECT_DIR)/Carthage/Build/iOS.
Am I missing something?
Eventually it turned out to be deployment target issue. The framework I was linking was supported with minimum deployment target as 8 and I was running with 7 :). I wish the build error could be more descriptive.

How to embed framework without copying in project

There was a similar question, but the answer is no
I use appodeal-ios-sdk-mobile-adapter. I want to add them to your projects without copying each.
in the Link Binary with Libraries framework added
But I get:
ld: framework not found GoogleMobileAds
clang: error: linker command failed with exit code 1 (use -v to see invocation)
In order to add the framework to your project without copying proeta folder, drag the folder using the (Create groups), and add the path where you have a set framework -> "Build Setting -> Library Search Paths and Framework Search Paths
/Users/username/Framework/AppodealAdapters/**
Well you can open the system directory where all the frameworks are present
that is in the system folder where all the frameworks are installed
Hit Shift+Command+G
and use the below address
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
Once in the directory copy the framework which you want to use. Take care to not mess around other frameworks in this directory.
Once the frameworks are copied into this directory you can add them to your project just like you include a regular system defined framework.
Try it out it works for me. I am using XCode 7.3.

How to use Realm (installed with Carthage) with a framework in a Swift app?

I'm working on an iOS App and a Watchkit App.
I read a few things regarding best practices and I decided to create a custom framework, as NathashaTheRobot advise here:
https://realm.io/news/architecting-app-apple-watch-natashatherobot/
So I'm trying to use Realm in my framework.
I followed the installation instructions for Carthage:
Add github "realm/realm-cocoa" to your Cartfile.
Run carthage update.
Drag RealmSwift.framework and Realm.framework from the
Carthage/Build/iOS/ directory to the “Linked Frameworks and
Libraries” section of your Xcode project’s “General” settings.
On your application targets’ “Build Phases” settings tab, click the
“+” icon and choose “New Run Script Phase”. Create a Run Script with
the following contents:
/usr/local/bin/carthage copy-frameworks
and add the paths to the frameworks you want to use under “Input
Files”, e.g.:
$(SRCROOT)/Carthage/Build/iOS/Realm.framework
$(SRCROOT)/Carthage/Build/iOS/RealmSwift.framework
Then I added my framework to the Target Membership of both Realm.framework and RealmSwift.framework.
But when I try to build the project, I get this error:
ld: framework not found Realm for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Then I gave a shot to lipo:
$ lipo -info Carthage/Build/iOS/Realm.framework/Realm
Architectures in the fat file: Carthage/Build/iOS/Realm.framework/Realm are: i386 x86_64 armv7 arm64
Do you have any ideas of what I might be doing wrong here? Thank you.
EDIT:
OK so I found the problem and it was totally unrelated to Realm...
It looks like I deleted the Headers and Resources sections of my framework Build Phases somehow (which were and are still empty). I just put them back and everything compiles/works like it should.
Don't be tempted to delete those two
Is it possible that it's your test target that can't find the frameworks? You'll have to add the parent location of the frameworks to the "Frameworks Search Path" section of your unit tests (likely $(SRCROOT)/Carthage/Build/iOS).
Here's a sample project of a Swift framework bundling RealmSwift as a dependency which you might find useful to compare your build settings against: https://static.realm.io/debug/ParentFramework.tgz

Resources