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

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

Related

Carthage build umbrella framework

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

Is it possible to distribute binary ios framework using carthage

Please bear with me because I spent considerable amount of time on this. I am also relatively a beginner with swift and iOS.
What I did
- built a framework using cocoa touch
- clean, build and it succeeds without a problem.
- made the scheme shared
- did carthage build --no-skip-current
- did carthage archive
- copied only the zip file to a fresh new directory and uploaded with release in git.
- In a different project tried to pull the framework using carthage
and I get the error Dependency "xxx-ios" has no shared framework schemes then I copied the scheme directly and pushed it in the git along the zip. nothing. Tried without the zip together with the scheme. nothing.
Then I created a fresh framework and I did carthage build --no-skip-current and I uploaded the whole thing in the project folder to git. That pulls properly with carthage. Then I removed some part of that folder so that the scheme inside .xcodeproj and the carthage build folder remain, then I get a different error. At this point it got me thinking if carthage does support binary framework distribution.
In my company, they want it so that I don't expose the code - so I am trying to distribute built binary of the framework.
I would really appreciate any help or guides of what different things I could try to single out the problem. Thanks.
Edit
someone had almost exactly the same issue as mine in their issues here but a couple of conversations later it is closed without a solution.
It sounds like you're using a github dependency in your Cartfile and attaching a binary of your framework to the GitHub Release. But you don't have any code in the repository, so Carthage is complaining because it can't actually build it.
That's as designed—Carthage doesn't support distributing binary-only frameworks that way. Binaries attached to GitHub Releases are only meant as a way to speed up builds.
However, Carthage does have a mechanism for binary-only dependencies: binary dependencies.

PubNub - iOS - Carthage only?

Question for someone who's quite fresh with PubNub and iOS-Swift,
as of today can you put PubNub in a project, entirely, absolutely not using cocoapods in any way? So, pure Carthage?
(PubNub's own doco is a little confused on the matter, at a quick glance.)
(Strictly iOS 10, no legacy)
Docs looks pretty clear about how to use Carthage way of integration.
To run this command you don't need CocoaPods (platform can be any: macos, tvos, ios and watchos or w/o platform to build all):
carthage update --platform ios
The only thing is required is Cartfile at the same directory from which you will call command from above. It should contain at leas this line (depending from version which you need):
github "pubnub/objective-c" ~> 4.1
As result you will get .framework bundle under Carthage/Build/{platform-name}/PubNub.framework. As mentioned in docs you can drag&drop it into your project and don't forget to add it to Embedded Binaries.
It looks like the project builds standalone frameworks, so you could add it as a Carthage dependency.
Carthage just downloads the project and builds it according to the project settings. All the consuming project needs to do is add the specific built product to you project.

Carthage: no shared framework schemes for iOS platform (for my own framework)

I create a framework (called ProjectOne) built and tested it. I want to allow this framework to be used in Carthage. I edited my scheme and made the default "ProjectOne" scheme shared in XCODE. I did a carthage build and verified that the framework was build in Carthage/Build/iOS.
I then push to github and and create a release.
In another project, I'm using this framework. But, carthage reports "Dependency ProjectOne has no shared framework schemes for any of the platforms: iOS".
I'm pretty sure I shared the scheme in ProjectOne - does anyone know why this is happening?
The folks at Carthage helped me discover the issue - Xcode was not adding the schemes to git. Make sure that .xcodeproj/xcshareddata/xcschemes is added and pushed to github.
In my case the issue was due the way I've included repo url in my cartfile.
I changed it from:
github "https://...UICore.git" == 1.0.0
to
git "https://... UICore.git" "master"
Click on Manage Schemes, and then un-flag and re-flag the “Shared” voice near "YourFramework". Go to terminal and now :
carthage build --no-skip-current
For me this was missing. I played around with scheme and pushed to GitHub PiAnimation.xcodeproj/xcshareddata/xcschemes/PiAnimation.xcscheme
For me the problem was new version of Xcode. I've build project in newer Xcode version, but command line tool has been set to previous. To change it you should open Xcode -> Preferences -> Locations.

how add manually a cordova plugin to ios existing project

i've a cordova project created via cordova cli command.
i build the project for Android and iOS platform but... i copied the build project into respective workspace (eclipse/xcode) and i updated that single project.
Now i need to add a plugin.
The project into cordova project folder is now so outdate so i would add the plugin via cli and copy the plugin to the respective project.
I copied successfully the generated plugin into the android project, but i'm not able to do the same thing with iOS.
For example i added the console plugin for iOS
cordova plugin add org.apache.cordova.console
if i open and run the build project it work and i see my message in console, but if i try to copy the generated plugin into my existing project it doesn't work.
nobody could help me to understand how add manually a plugin into my existing project?
update
yes i know, i'll try to explain better
i have my cordova project under folder /Document/cordova
when i made an ios build via command line cordova put the built project under /Document/cordova/platforms/ios
well i copied the folder ios under /workspace/my-project-name
after some work under workspace i see that i need to add a cordova plugin.
i added the plugin via command line and it was added to /Document/cordova/platforms/ios
at this poin i have a project under /Document with plugin but asset outdated and one project updated without plugin under /workspace
i'm trying to copy from built project to /workspace project.
i copied
/workspace/my-project-name/my-project-name/Plugins
/workspace/my-project-name/my-project-name/config.xml
/workspace/my-project-name/www/plugins
/workspace/my-project-name/www/cordova.js
/workspace/my-project-name/www/cordova_plugins.js
but it doesn't work... i missed somethings?
After reading it several times I think I get more less the idea...
Well, I am not sure why do you want to copy the ios project outside the current location. I suppose you have a good reason to do it, however you can always tweak that project instead of going back and forward, cordova will not impact non cordova related files each time you run "cordova build".
Are you familiar with control versioning? Git, SVN, mercurial? If so it is simple just we which files were impacted once you add the plugin and copy those... If no, I suggest using control versioning anyways to help keep track of your code changes.
NOTE: Be aware if you build the cordova projet and then you just want to update the files noted above it is highly likely that it won't work, that is why you run "build" is not a simple file sync. I recommend taking the new cordova project with the plugin added and then just add you personal tweaks on the ios in the other folder. Or just tweak the ios folder inside platforms folder...
I hope you are doing for good reason. Anyway you are missing to copy below file to work
/workspace/my-project-name/my-project-name/platforms/ios/my-project-name/config.xml
Copying the cordova iOS platform folder is not a good idea. The reason is, cordova builds an Xcode project in the platform folder, and there is some sort of caching/built in references to absolute location of the original Xcode project. Therefore it would be unclear to you and to Xcode which file is being referenced from within Xcode. This may have caused some other unnoticed errors in the project as well. So therefore, instead of keeping original project path available along with the new path, I would recommend renaming the original project folder in order to remove the ambiguity. This way, you will assure that the right file versions are referenced.

Resources