iOS Tutorial Compile As Library

Discussion in 'iOS Tutorials' started by Erel, Dec 15, 2016.

  1. Erel

    Erel Administrator Staff Member Licensed User

    B4i v3.50 adds support for library compilation. This is similar to the feature available in B4A and B4J: https://www.b4x.com/android/forum/t...pile-your-project-to-a-library.24750/#content

    This makes it easier to build reusable components and share them in multiple projects or with other developers.
    It also saves compilation time and allows splitting large projects.

    Compiling to a library is simple:

    1. Add #LibraryName and #LibraryVersion attributes to the main module.
    2. Compile with Tools - Build Server - Compile To Library (Alt + 5)

    All modules except of the main module (or any other module explicitly excluded with #ExcludeFromLibrary attribute) will be compiled as a static library.

    As the main module is excluded, other modules cannot directly reference it or compilation will fail.
    Note that you can use CallSub to call subs in excluded modules.

    The output is made of three files:
    - The XML file which will be created in the additional libraries folder.
    - .a and .h files will be created in the Mac Libs folder.

    This means that you can immediately use the libraries.
    You can choose Tools - Build Server - Download Last Build to download a zip file with the three library files.

    Note that if you are using the hosted builder then you need to first receive a permission to compile a specific library. Please contact support@basic4ppc.com and send your hosted builder id and the library name.
     
    stanmiller, Ohanian and JanPRO like this.
  2. narek adonts

    narek adonts Well-Known Member Licensed User

    Will it be possible to return an object as a View ?
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Not sure that I understand the question. With this feature you can take existing B4i code and convert it to a compiled static library.
     
  4. narek adonts

    narek adonts Well-Known Member Licensed User

    I mean if for example I want to create a custom view (ex. BestTextField) and I am compiling it as a library. Is it possible to use it as myPanel.AddView(BestTextField,...) ?
     
  5. icefairy333

    icefairy333 Active Member Licensed User

    after add #ExcludeFromLibrary to a code module ,I cannot use it directly or will throw error when compile yes?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    You cannot do anything that you can't do with B4i code. A B4i class will never extend a UIView.

    You should implement a custom view and add it with the designer.

    Modules excluded from library compilation cannot be referenced. There code is not included in the compilation.
     
  7. Markos

    Markos Active Member Licensed User

    Hi Erel

    I think the member was referring to the callsubs to reference excluded subs by oncluded subs calling same.
     
Loading...