Carthage build umbrella framework - ios

We are developing a dynamic umbrella framework which consist of several other frameworks. Our framework structure is in below
Base.framework
SubFramework1
SubFramework2
SubFramework2.1
SubFramework2.2
SubFramework3
And our xcode project file for the umbrella framework(Base.framework) is structured like this.
But when I execute carthage build command , it finds some of the sub frameworks and doesnt able to find some of the sub frameworks.
What should I do in order to compile the framework as its structured in our xcode project
You can see our framework in the below link:
https://github.com/Kandy-IO/test-cp
(All the subframeworks are in SubFrameworks folder of CpaaSSDK.framework)

Make sure that all the sub frameworks are exposed to carthage build system by selecting them as shared schemes.
Shared schemes
As mentioned in carthage doc on github.
Share your Xcode schemes
Carthage will only build Xcode schemes that are shared from your
.xcodeproj. You can see if all of your intended schemes build
successfully by running carthage build --no-skip-current, then
checking the Carthage/Build folder.
If an important scheme is not built when you run that command, open
Xcode and make sure that the scheme is marked as Shared, so Carthage
can discover it.
Doc Link - https://github.com/Carthage/Carthage#share-your-xcode-schemes

Related

CocoaPods not working on framework target

Im building a IOS app that uses a third-party library.
The library project is inherited from another developer that im unable to ask anything.
It is configured to use CocoaPods to manage dependencies, it has a lot of them.
When i run "pod install" it downloads all of them and creates the workspace.
In the workspace i have set the app target as dependent from the framework project product
Then i try to build it and it says it cannot find one of the dependencies of the framework project (it is on the podfile)
Then i found the framework project is missing "[CP] Embed Pods Frameworks" in build phases (the app project has it)
Also the "Pods_[targetName].framework" is shown in red (even when it indeed is in the build products folder, the path is correct)
I found this issue that seems to be exactly my problem but im unable to see if it has been fixed or not and what could i do to workaround this.
Same effect for me, my issue was the s.source_files in the podspec did not reference a location with actual files after a refactor.

iOS : How to generate a .framework file from a GitHub project

There is a Swift project on GitHub that I want to include in my iOS app.
In my iOS app, I use Carthage. But the GitHub project is not compatible with Carthage (only with Cocoapods), so I need to include the .framework file in my project manually.
How can I generate the .framework file without Carthage?
Building the framework is not always the same across projects. That being said, there should be a target available when you open the project to make the framework build. It should look something like this.
After clicking run the framework is usually output to the products directory.
If this doesn't work for you with this project then maybe you could share a link to the github page for the project and I could provide more instruction.
Fork Project
Change scheme to shared in scheme management (more information on Carthage docs)
Add your fork to your Cartfile
You can stop here but I highly recommend do this after:
Update README with information about Carthage support
Make a pull request

What's the equivalent of "development pods" under Carthage?

The teams developing frameworks for our iOS app are migrating from Cocoapods to Carthage.
Under Cocoapods, I could set up dependencies as "development pods". For example, instead of having the main app download a specific version of an xyzzy dependency, I could set up xyzzy as a development pod and point it to my local directory where I had checked out xyzzy from its Git repo. While I was working in the main app's project, any edits I'd do to xyzzy's files would be made in that directory. This let me build and test changes immediately, and when I was ready to check them in, Git would find them in the xyzzy project's directory.
Under Carthage I haven't found a way to do this. I see http://allocinit.io/ios/debugging-carthage-dependencies/ which explains how to create symbolic links so that I can see the dependency source files to make debugging easier, but any edits I make to them are under the main application's Carthage/Builds directory.
How do I set up the equivalent of development pods under Carthage?
I believe Carthage doesn't have something similar to "development pods" yet.
But you could simulate "development pods" just following these steps:
Steps:
Add the .xcodeproj to your workspace
Remove all the dependencies you have in your project of the framework you added in step 1. (probably you may need to remove it from Build Phases -> Run Script -> Input Files too )
Go to General tab of the target you want to run, add the framework under Linked Frameworks and Libraries (it is going to take the one added from the .xcoproj)
(optional) you may need to run carthage bootstrap in the framework's repo you want to add locally.
That's it.
After that you will be able to run your project and update framework's code in the same workspace.
This works just as well as development pods for me, as of Xcode 8.3.3 and Carthage 0.24.0:
In app path, rm -rf Carthage
Point at the appropriate branch or tag in Cartfile
carthage update --use-submodules (generates .gitmodules and clones repo into Carthage/Checkouts)
In Xcode under project -> Build Phases -> Run Script, comment out the line that ends with carthage update --cache-builds if present.
Change to the General tab and remove the lib from Embedded Binaries
Right-click project, Add Files to app..., add lib from Carthage/Checkouts
Under project -> General, re-add the library, choosing the one you added in the previous step.
App should now build with the local lib. Make sure that your .gitignore has Carthage/{Build,Checkouts} and .gitmodules.
This answer is a summary of a successful implementation of the solution introduced here.
A cleaner solution is using local paths for dependencies in Cartfile.
Environment
Xcode 10.1
macOS 10.13.6
Step 1. Symbolic linking
1.1 Change $(SRCROOT_MAIN)/Carthage/Checkouts/$(DEVELOPING_FRAMEWORK_NAME) directory to a symbolic link pointing to source root directory of your developing framework $(SRCROOT_DEVELOPING_FRAMEWORK), where $(SRCROOT_MAIN) is source root directory of your main app. Backup existing directories before this change.
This linking enables version-controlled changes in your developing framework.
Syntax when using ln utility,
$ ln -s "$SRCROOT_DEVELOPING_FRAMEWORK" "$SRCROOT_MAIN/Carthage/Checkouts/$DEVELOPING_FRAMEWORK_NAME"
1.2 Change $(SRCROOT_DEVELOPING_FRAMEWORK)/Carthage/Build directory in your framework to a symbolic link pointing to $(SRCROOT_MAIN)/Carthage/Build directory. Backup existing directories before this change.
This linking enables access to all frameworks built by Carthage from both your developing framework and your main app.
Syntax when using ln utility,
$ ln -s "$SRCROOT_MAIN/Carthage/Build" "$SRCROOT_DEVELOPING_FRAMEWORK/Carthage/Build"
Step 2. Framework Replacement

2.1 Remove your developing framework in Xcode > YOUR_MAIN_APP > General > Linked Frameworks and Libraries (that is, the one located in $(SRCROOT_MAIN)/Carthage/Build/iOS).
2.2 Add $(DEVELOPING_FRAMEWORK_NAME).xcodeproj (found in directory pointed by $(SRCROOT_MAIN)/Carthage/Checkouts/$(DEVELOPING_FRAMEWORK_NAME) symbolic link) into your main app
2.3 Build the developing framework product for device and simulator
2.4 Add the new developing framework auto-detected by Xcode in Xcode > YOUR_MAIN_APP > General > Linked Frameworks and Libraries.
2.5 Add $(DEVELOPING_FRAMEWORK_NAME).framework as a target dependency by adding $(DEVELOPING_FRAMEWORK_NAME).framework in Xcode > YOUR_MAIN_APP > Build Phases > Target Dependencies.
2.6 Copy $(BUILT_PRODUCTS_DIR)/$(DEVELOPING_FRAMEWORK_NAME).framework to $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/$(DEVELOPING_FRAMEWORK_NAME).framework by adding a new input file $(BUILT_PRODUCTS_DIR)/$(DEVELOPING_FRAMEWORK_NAME).framework and a new output file $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/$(DEVELOPING_FRAMEWORK_NAME).framework in Xcode > YOUR_MAIN_APP > Build Phases > Run Script of Carthage Embed Framework.
Reference
Debugging Carthage Dependencies
https://allocinit.io/ios/debugging-carthage-dependencies/
Build Setting Reference
https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html

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.

can't find ios framework headers in react native module library

I've included an iOS framework in the xcode project for the React Native module library I'm creating. Everything compiles fine when I build the ios project in the RN library itself, but once I npm install the library into my main RN project, running react-native link <project-name>, and then build in xcode, the included framework headers are not found.
I checked the normal build settings (Header, Framework, and Library search paths) and they all have $(inherited) listed.
Repo for the react native library that is WIP https://github.com/bsy/react-native-pollfish
Download SDK file from here . May be owner removes the SDK from github.
Please add this line in your package.json file.
"rnpm": {
"ios": {
"sourceDir": "./ios"
}
}
Also, unable to install your plugin with "npm install".
The solution to this issue was to make sure that both your Xcode subproject and your main Xcode project both point to a relative path to the SDK.
Steps to take:
Open your application's Xcode project.
If you don't have a Frameworks group in your project, create one.
Open ~/Documents/PollfishSDK using Finder.
Drag the pollfish.framework file into the Frameworks group of Xcode's Project Navigator. In the displayed dialog, choose Create groups for any added folders and deselect Copy items into destination group's folder. This references the SDK where you installed it rather than copying the SDK into your app.
For 3rd party framework set the framework search path in the library project-
$(SRCROOT)/../../../ios/Pods/3rd_party_framework_folder_name

Resources