Existing iOS Form Framework

Existing iOS form framework

Take a look at IBAForms - an open source project from from Itty Bitty Apps. I haven't used it yet myself, however I believe it does most of what you want, except for validation. Here is the github page: IBA Forms

It hasn't been maintained in a while, but if you're looking for a forms library - it's mature and works. At the very least, it could be the starting point for something you take further.

  • Update: There is also Chris Miles' EZForm library, which is very nice.

  • Update #2: Have also started checking out QuickDialog, which seems to be very popular.

  • Update #3: Nick Lockwood has created one called FXForms

  • Update #4: Martin Barreto has created one called XLForm

Create a framework from existing iOS project

When you want to make a framework, or module, from a project, the first thing you’ll need to do is, if you don’t have one already, make an Xcode project workspace (File > Save as Workspace) . The next step is to add a new framework “project” to your workspace (that could’ve been why you saw some resources telling you to make a new project) with File > New Project and choosing Cocoa Touch framework. When you add it, make sure you pick your workspace under both Add to and Group. Then you will need to migrate in the files that you wanted to be in this module — make sure to choose copy items if needed.
Here’s an article with more specific details on the process if you need it:
https://medium.com/kinandcartacreated/modular-ios-splitting-a-workspace-into-modules-331293f1090

Why are iOS frameworks I'm linking as Optional being treated as required when my framework is imported elsewhere?

If you create your own framework which uses third party frameworks and you want to make those third party frameworks optional (but at the same time required only for some features of your framework) then I think you need to do few things.

First make sure that those third party frameworks that should be optional use -weak_framework option for linking. It seems that you already did that. If you are adding those third party frameworks with cocoapods then you will probably need to add at the end of your Podfile script such as the one below because cocoapods tends to override those changes and reverts -weak_framework to -framework if you made that change manually.

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
xcconfig_path = config.base_configuration_reference.real_path
xcconfig = File.read(xcconfig_path)
xcconfig_mod = xcconfig.gsub(/-framework "ThirdPartyFrameworkName"/, "-weak_framework \"ThirdPartyFrameworkName\"")
File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
end
end
end

Second thing is that you will need to import this third party framework in your framework as implementation only framework and you can do this like below:

@_implementationOnly import ThirdPartyFrameworkName

Last thing is that in you code you will need to check if this third party framework is actually loaded so that your code will not crash in case when someone will not add this third party framework to his application. So the optional feature in your framework that uses third party framework should first check for example if given class of this external framework exists before using it like below:

if NSClassFromString("ClassNameFromThirdPartyFramework") == nil {
return // third party framework not available
}
// do something with ClassNameFromThirdPartyFramework here

If you perform all those steps it should work.



Related Topics



Leave a reply



Submit