What is the right way to embed in simple MyApp a custom framework that uses Cocoapods for dependencies?
I read a lot o of tutorials and posts but no one solves the issue!
Please help I cant figure out.
SCENARIO:
I created a little test framework and i embedded it in a little consumer app following this simple tutorial [https://www.raywenderlich.com/5109-creating-a-framework-for-ios][1] just one like many others.
I get my simple example working.
Now i created a biggest framework MyFramework that uses itself some pods like firebase, alamofire and so on. MyFramworks builds correctly
Now i embed it in my consumer application MyApp and added MyFramework in âEmbedded Binariesâ and in âLinked Framework and Librariesâ but IâM getting an error on MyFramwork when xCode is building MyApp:
Apple Mach-O Linker (ld) Error Group
lang: error: linker command failed with exit code 1 (use -v to see invocation)
giving me a lot of âDirectory not foundâ errors in DerivedData for all installed Pods
I read a lot of posts but no one solved the issue
UPDATED SCENARIO:
I tried to replicate the problem in my little working test framework named testfwk.
The testapp is in a separated project, and in a separated folder like ls -la command:
MacBook-Pro:test david$ ls -l
total 0
drwxr-xr-x 12 david staff 384 15 Ott 10:40 testapp
drwxr-xr-x 10 david staff 320 15 Ott 10:14 testfwk
ls -l for testfwk folder:
MacBook-Pro:testfwk david$ ls -l
total 16
-rw-r--r-- 1 david staff 415 15 Ott 10:14 Podfile
-rw-r--r-- 1 david staff 290 15 Ott 10:14 Podfile.lock
drwxr-xr-x 8 david staff 256 15 Ott 10:14 Pods
drwxr-xr-x 5 david staff 160 15 Ott 10:49 testfwk
drwxr-xr-x@ 5 david staff 160 15 Ott 10:14 testfwk.xcodeproj
drwxr-xr-x@ 5 david staff 160 15 Ott 10:16 testfwk.xcworkspace
drwxr-xr-x 4 david staff 128 14 Ott 15:58 testfwkTests
ls -l for testapp folder:
MacBook-Pro:testapp david$ ls -l
total 16
-rw-r--r-- 1 david staff 637 15 Ott 10:53 Podfile
-rw-r--r-- 1 david staff 290 15 Ott 10:40 Podfile.lock
drwxr-xr-x 8 david staff 256 15 Ott 10:53 Pods
drwxr-xr-x 7 david staff 224 15 Ott 10:20 testapp
drwxr-xr-x@ 5 david staff 160 15 Ott 10:40 testapp.xcodeproj
drwxr-xr-x@ 5 david staff 160 15 Ott 10:41 testapp.xcworkspace
drwxr-xr-x 4 david staff 128 14 Ott 16:01 testappTests
drwxr-xr-x 4 david staff 128 14 Ott 16:01 testappUITests
I add KingFisher via Coccoapods to testfwk, opened testfwk.xcworkspace and it builds succesfully, kingfisher import works on a sample swift class.
testfwk Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'
target 'testfwk' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for testfwk
pod 'Kingfisher','~> 4.0'
target 'testfwkTests' do
inherit! :search_paths
# Pods for testing
end
end
First time i opened testapp.xcodeproj, do a clean ad try to build but i get this error:
The testfwk was already added as embedded binary and library in my testapp like shown:
The framwork function testprint.hello() called from Viewcontroller of testapp was working right before adding pod to testfwk
Then i close xCode, cleaned derived data folder, opened testfwk and build it succesfully, opened testapp cleaned and try to build but i get the same error.
What is going wrong??? How can i get it working!!!
I need to embed my framework to set up my consumer app and do some adjusments, after that my idea is to use cocoapods to add my framework in following apps.
Anyoine can help? Thanks
After this i tried to add the KingFisher pod via Cocoapods to testapp application also using a similar podfile used for testfwk but changing target to âtestappâ, the pod was installed succesfully but when i try to build testapp.xcworkspace i get the same error. I think this installation was unnecessary.
I think the testfwk is not able to build inside testapp and for some reason doesnât see KingFisher pod
podfile for testapp
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
target 'testapp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for testapp
pod 'Kingfisher','~> 4.0'
target 'testappTests' do
inherit! :search_paths
# Pods for testing
end
target 'testappUITests' do
inherit! :search_paths
# Pods for testing
end
end
After I also tried to follow the accepted answer [ios - Can I use CocoaPods when creating a Cocoa Touch Framework? - Stack Overflow][4]
i created a similar Podfile for testapp but i get a âTarget not found error for âtestfwkâ targetâ i think for path or folder issues"
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
def facile_core_pods
pod 'Kingfisher','~> 4.0'
end
target 'testapp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for testapp
facile_core_pods
target 'testappTests' do
inherit! :search_paths
# Pods for testing
end
target 'testappUITests' do
inherit! :search_paths
# Pods for testing
end
target 'testfwk' do
use_frameworks!
facile_core_pods
end
end