Can I attach a storyboard to a Static Library - objective-c

I have a very simple single view application that I need to convert into a library.
I believe I am off to the correct start of going to my project settings and then adding a Cocoa Touch Static Library. After doing that I moved my ViewController.h, ViewController.m and Main.storyboard files to the new library directory.
I then went to my applications project settings and added my new library to the "Link Binary With Libraries". Then under the general tab I set the Main interface to nothing since I had moved the storyboard to the new library directory.
Then I went to my libraries project settings and add the Main.storyboard to the Copy Files. Lastly I deleted the two default .h and .m files that were created when I added the library and then added the ViewController.m file to the libraries Compile sources.
The app loads a blank screen and gives warnings because it can't access any of the inputs on the storyboard. How do I get library to load the storyboard or is this just completely wrong?

You need to make sure that the application (not the library) is copying the storyboard.
You should probably build a resource bundle for your resources (a zipped file that ends with .bundle).
There is a hack you could try if you really want to get down to one file, Embedded Frameworks.
Although frameworks are an improvement over libraries, Xcode ignores any resources contained within frameworks. So if you have xibs, images, sounds, or other files in your framework, Xcode won't see them. An embedded framework is a way to trick Xcode into seeing the included resources.
You can see the structure here.
KFData.embeddedframework
├── KFData.framework
│ ├── Headers -> Versions/Current/Headers
│ ├── KFData -> Versions/Current/KFData
│ ├── Resources -> Versions/Current/Resources
│ └── Versions
│ ├── A
│ │ ├── Headers
│ │ │ ├── ..
│ │ ├── KFData
│ │ └── Resources
│ │ ├── ACKNOWLEDGEMENTS
│ │ ├── Info.plist
│ │ ├── LICENSE
│ │ ├── KFData.bundle
│ │ │ ├── ..
│ │ ├── KFData.xcconfig
│ │ └── VERSION
│ └── Current -> A
└── Resources
├── KFData-Acknowledgements -> ../KFData.framework/Resources/ACKNOWLEDGEMENTS
├── KFData-License -> ../KFData.framework/Resources/LICENSE
├── KFData-Version -> ../KFData.framework/Resources/VERSION
├── KFData.bundle -> ../KFData.framework/Resources/KFData.bundle
└── KFData.xcconfig -> ../KFData.framework/Resources/KFData.xcconfig

Related

Summary HTML Report not generated when path is specified in terms of classpath in Karate

I am trying to run some test cases using Karate v1.2.0 (with Junit5). Everything is working well, except for a minor discrepancy that seems to be occurring during report generation. The project folder structure is something like this
my-project/
├── src/
│ └── test/
│ └── java/
│ ├── ronan/
│ │ ├── api/
│ │ │ ├── ApiTest.java
│ │ │ ├── feature-1.feature
│ │ │ └── feature-2.feature
│ │ └── util/
│ │ └── SomeUtil.java
│ ├── karate-config.js
│ └── logback-test.xml
└── build.gradle
When my ApiTest.java specifies the path by individual feature file names, the individual feature HTML reports and the summary HTML report are generated.
#Karate.Test
Karate testAPI() {
// Generates individual HTML reports as well as the summary HTML report
return Karate.run("feature-1", "feature-2")
.outputJunitXml(true)
.relativeTo(getClass());
}
However, when I specify the path using classpath:, only the individual feature HTML reports are generated and not the summary report.
#Karate.Test
Karate testAPI() {
// Generates ONLY individual reports
return Karate.run("classpath:ronan/api")
.outputJunitXml(true)
.relativeTo(getClass());
}
The test task is configured in build.gradle as below
test {
useJUnitPlatform()
systemProperty "karate.options", System.properties.getProperty("karate.options")
systemProperty "karate.env", System.properties.getProperty("karate.env")
outputs.upToDateWhen { false }
}
I wasn't able to find any relevant documentation or SO answers related to the same, so I'm not sure if this is expected and if I'm doing something wrong or if it's an issue with report generation.
Any help on this would be greatly appreciated. Thanks!
For CI, please use the Runner API, and only then can you run tests in parallel. The JUnit helpers are just for IDE dev-loop convenience.
Please read this for details: https://stackoverflow.com/a/65578167/143475
Now if you still see issues with the Runner, then open an issue with a way to replicate. Meanwhile you are welcome to contribute code to fix the problem you describe in your question.

How can I reuse library declarations in Gradle Kotlin DSL?

Background:
We are trying to migrate to Gradle's Kotlin DSL, primarily for the additional type safety.
Some of our library definitions are quite large (20+ exclude calls in some extreme cases) so we currently have a giant dependencies.gradle Groovy script which declares a giant map of all libraries, which can then be used like libraries.blah. I'm trying to come up with a working way to do the same in Kotlin.
Investigation:
Dependency constraints (java-platform plugin) allow centralising the version number for the dependency, but that does nothing for the exclusions, and the exclusions are most of the problem in our case. (I'm sure we will eventually use java-platform at some point too.)
The most elegant-looking solution I found was in this one blog post which suggests declaring Kotlin objects, like this:
object Libraries {
val guava = "..."
}
You can then supposedly use the object like Libraries.guava. But this doesn't actually work, at least in Gradle 6.9.1, because of an issue in Kotlin itself. (I'm assuming that it worked on some older version and got broken by a Kotlin compiler upgrade.)
The workaround specified on the ticket comes out like:
class Libraries(dependencies: DependencyHandler) {
val guava = dependencies.create(...)
}
val libraries by project.extra { Libraries(dependencies) }
This gets me closer to a working solution in that my dependencies.gradle.kts file now compiles, but I still can't find a way to use the Libraries class I've defined. If you do this:
val libraries: Libraries by project.extra
Kotlin complains that Libraries is not defined. So it's as if one build script can't even export classes for another build script to use.
More Context
The actual project structure is quite complex, and looks a bit like this:
─ repo root
├─ mainproject1
│ ├─ subproject11
│ │ └─ build.gradle.kts
│ ├─ subproject12
│ │ └─ build.gradle.kts
│ ├─ build.gradle.kts (references dependencies.gradle.kts)
│ └─ settings.gradle.kts
├─ mainproject2
│ ├─ subproject21
│ │ └─ build.gradle.kts
│ ├─ subproject22
│ │ └─ build.gradle.kts
│ ├─ build.gradle.kts (references dependencies.gradle.kts)
│ └─ settings.gradle.kts
└─ shared
└─ gradle
└─ dependencies.gradle.kts
Question:
How are other people with enormous builds with >100 dependencies solving this problem?
Workaround: use buildSrc to instantiate Libraries object.
Create the following directories structure:
.
├── buildSrc
│ ├── build.gradle.kts
│ └── src
│ └── main
│ └── kotlin
│ └── Libraries.kt
├── settings.gradle.kts
└── build.gradle.kts
buildSrc/build.gradle.kts is minimalistic:
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
}
Libraries.kt:
object Libraries {
const val guava = "com.google.guava:guava:31.0.1-jre"
}
Usage (root build.gradle.kts):
plugins {
`java-library`
}
dependencies {
implementation(Libraries.guava)
}
repositories {
mavenCentral()
}

ESP-IDF project with multiple source files

I started my project with a simple "blink" example and used it as a template to write my code.
This example used only one source file blink.c.
Eventually, I want to a use multi source files project and can't figure out how to configure CMakeLists.txt in order to compile the project.
My CMakeLists.txt is:
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(blink)
I want to add for example init.c.
I tried different ways, but with no success.
None of idf_component_register() / register_component() worked for me.
Any idea how to correctly configure the project?
Right, the CMake project hierarchy in ESP IDF is a bit tricky. You are looking at the wrong CMakeLists.txt file. Instead of the one in root directory, open the one in blink/main/CMakeLists.txt. This file lists the source files for the "main" component, which is the one you want to use. It would look like this:
idf_component_register(SRCS "blink.c" "init.c"
INCLUDE_DIRS ".")
Make sure your init.c file is in the same directory as this CMakeLists.txt and blink.c.
I also recommend taking a look at the Espressif Build System documentation, it's quite useful.
You should edit the CMakeLists.txt located in your main folder inside your project folder. In addition, you need to put the directory that contains the header files into INCLUDE_DIRS parameter.
For example, if you have this file structure in your project (you're putting init.h inside include folder) as shown below:
blink/
├── main/
│ ├── include/
│ │ └── init.h
│ ├── blink.c
│ ├── CMakeLists.txt
│ ├── init.c
│ └── ...
├── CMakeLists.txt
└── ...
The content in your main/CMakeLists.txt should be:
idf_component_register(SRCS "blink.c" "init.c"
INCLUDE_DIRS "." "include")

Do you use express.static(‘public’) OR (path.join(__dirname, ‘public’))?

My tree:
├── app.js
├── data
│ └── stuff.json
├── package.json
├── public
│ ├── index.html
│ ├── main.js
├── routes
└── api.js
Below are two lines I’ve used in my app.js file in order to serve the static file public/index.html
This first option works fine. As I understand it, it directs the user to the public directory relative to app.js:
app.use(express.static('public'))
The following second line doesn’t work. As I understand it, this is the absolute path to the public directory.
app.use(express.static(path.join(__dirname, 'public')))
The https://expressjs.com/en/starter/static-files.html seems to suggest the first option, yet most web sites and books encourage the second. Why/When is the second encouraged? And why doesn’t it work for me in this case?

Conditional loading of Dojo modules

Let me first present directory structure of what I have
/
├── dojo/
├── dojox/
├── dijit/
└── app/
├── a/
│ └── moduleA.js
├── b/
│ └── moduleA.js
└── c/
I'm trying to configure Dojo to be able to load moduleA.js in following way:
require(["app/moduleA"]
and in the same time resolve it according to below pseudocode:
if moduleA exists in c
load "app/c/moduleA.js"
else if moduleA exists in b
load "app/b/moduleA.js"
else if moduleA exists in a
load "app/a/moduleA.js"
else
standard fail, same as when no module is defined
It would be great if order a, b and c could be passed as array for instance ["app/c/moduleA", "app/b/moduleA", "app/a/moduleA"].
I was looking into documentation hoping to find something, but no luck. https://dojotoolkit.org/reference-guide/1.7/loader/amd.html#module-identifiers was closest I got. There is packages.location property, but it takes string to load module, so I guess it has no additional logic regards to arrays.
Any idea how to solve this problem?