Core Data code generation causes build failure - xcode

I’m using the new Xcode 8 feature of code generation for my Core Data model using Class Definition as the Codegen option.
When I build I get the following output for each of my entities:
<unknown>:0: error: no such file or directory: ‘/path/to/DerivedSources/CoreDataGenerated/Model/.Entity+CoreDataClass.swift'
<unknown>:0: error: no such file or directory: ‘/path/to/DerivedSources/CoreDataGenerated/Model/.Entity+CoreDataProperties.swift’
...
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
On inspecting the files I can see the following:
Entity+CoreDataClass.swift:
import Foundation
import CoreData
public class Entity: NSManagedObject {
}
Entity+CoreDataProperties.swift
import Foundation
import CoreData
import
extension Entity {
#nonobjc public class func fetchRequest() -> NSFetchRequest<Entity> {
return NSFetchRequest<Entity>(entityName: “Entity");
}
#NSManaged public var title: String?
}
In the second, the obvious thing that shouldn’t be there is the empty import statement, which I’m guessing is causing the crash.
Could I be doing something wrong? Is this a bug?
I’ve tried all the usual, clean, clean build folder, restart Xcode/Mac with no luck.

The Module field of the entity in the Data Model inspector had a value in it, I deleted this so now it’s empty and the placeholder reads “Global namespace”. This seems to have worked!

Core Data is heavily string-based. Using names such as "Entity" for your entities can lead to unexpected results. Also avoid using names in your data model such as "description", or "item" or "attribute" etc. If you do want to use those names, prefix them: names like "My_entity" or "ACEntity" are fine.

Related

Go type cast fails despite the type being the same

I am using the jackc/pgx driver alongside the GORM library to interface with a PostgreSQL database.
I have an instance where I have to check the PostgreSQL error code and handle a certain error type differently. When using the pgx driver, the GORM methods return a *pgconn.PgError type as the error, which contains a field with the specific error code.
In order to access that field, I must cast the error to a *pgconn.PgError, but for some reason this is failing:
res := tx.Take(&f, "id = ?", id)
if res.Error != nil {
if pqErr, ok := res.Error.(*pgconn.PgError); ok {
// does not reach here
} else {
fmt.Printf("Error type: %T\n", res.Error)
// Output: "Error type: *pgconn.PgError"
}
}
Notes:
The pgx and pgconn packages are inside the same project, so it's not the case that they are returning different versions of a type with the same name. In other words, I only have one import in my go.mod.
The returned value is not nil.
A debugger reveals that the type is a *pgconn.PgError.
You've solved your own issue, but here's some perhaps helpful background, and how I found the source.
Packages of the same name can exist in the same program, so long as they have different import paths. For example, the standard library has both math/rand and crypto/rand, each called rand. This is the first hint of how *pgconn.PgError and *pgconn.PgError are not the same: they come from different import paths.
When modules in Go make major revisions, they are supposed to change their import path. This is to preserve backwards compatibility with respect to import paths. Note that this is usually done by updating the module declaration in the go.mod file, rather than actually moving the code into a sub-directory. For example, see this commit where pgx was bumped from v4 to v5. This is the second hint: code from the pgx project is available under multiple import paths (due to the multiple major versions).
With this background in mind, I used the git tags to view the repository at the latest v4.x.x release. I noticed that oddly, the pgconn package did not exist in v4. This seemed to rule out the idea of a github.com/jackc/pgx/v4/pgconn vs github.com/jackc/pgx/v5/pgconn conflict. I then Google searched for "pgconn" and found the github.com/jackc/pgconn repository, where I saw in the README:
This version is used with pgx v4. In pgx v5 it is part of the https://github.com/jackc/pgx repository.
From the other information you've given, your mistake may have been using the import path "github.com/jackc/pgx/pgconn". As shown in the example code for pgx, the current import path you should be using for the base module is "github.com/jackc/pgx/v5", and packages within it would be specified similarly, e.g., "github.com/jackc/pgx/v5/pgconn".
As #HymnsForDisco correctly pointed out in the comments, both github.com/jackc/pgconn and github.com/jackc/pgx/pgconn exist. It turns out that the returned error was from the former, whereas I was importing the latter in my code.
To confirm, I added the following line:
fmt.Println("Error path: ", reflect.TypeOf(res.Error).Elem().PkgPath())
// Output: "Error path: github.com/jackc/pgconn"
Changing my import to "github.com/jackc/pgconn" resolved the issue.

Compiler error screen.mainScreen is a static member of type 'Screen'

Help!. Compiler returns error
Property 'mainScreen' is a static member of type 'Screen'
i am trying to get heightDIPs but this.
You might want to check where Screen is being imported from. I've had issues in the past where VS Code would auto import the wrong Screen.
import { Screen } from '#nativescript/core';
// and the following should work
Screen.mainScreen.heightDIPs

How to import a document in UCM using ridc

I am trying to import a archived document that was checked-in earlier, but I want to import it using RIDC program, following is the code I am working on:
IdcClientManager manager = new IdcClientManager();
IdcClient idcClient= manager.createClient("http://localhost/idc/idcplg");
IdcContext idcContext = new IdcContext("sysadmin", "idc");
// get the binder
DataBinder binder = idcClient.createBinder();
//populate the binder with the parameters
binder.putLocal("IdcService", "IMPORT_DOCUMENT");
binder.putLocal("Idc_Name", "idc");
binder.putLocal("aArchiveName", "idc//test1");
binder.putLocal("dDocName", "000022");
binder.putLocal("dCollectionName", "test_checkin");
ServiceResponse response = idcClient.sendRequest(idcContext, binder);
DataBinder binderResult = response.getResponseAsBinder();
But I am getting the following error:
Unable to execute service IMPORT_DOCUMENT and function executeArchiveMethod.
(System Error: The collection name must be specified.)
I specified dCollectionID, dCollectionName,dCollectionLocation, but faced same result.
Can anyone guide me about this error, or where I am getting wrong in implementing this code.
For better understanding I would like to tell that the specified document was earlier checked in using WebDAV.
Any kind of help will be grateful.
Parameters are case-sensitive. You need to use IDC_Name.

Using an External Dependency in a Library

I am using wgo for dependency management in Golang (although I think wgo has little to do with this), wgo has a folder structure like this
project/
.gocfg/
gopaths
vendor.json
vendor/
src/
github.com_or_whatever/
I have a library I coded myself which uses an nsq-go type in one of the exported methods:
func AddNsqSubscription(
topic, channel string,
handler nsq.Handler,
config *nsq.Config) error { }
The library is called messi and I import the nsq-go like so "messi/vendor/src/github.com/bitly/go-nsq"
The problem comes when I try to use this library in another project. For instance, in a project called scribe I have the following code (notice the imports):
import (
"scribe/vendor/src/github.com/bitly/go-nsq"
"scribe/vendor/src/messi"
)
//...
nsqHandler := nsq.HandlerFunc(func(message *nsq.Message) error {
msgHandler(MessiMessage{message})
return nil
})
return messi.AddNsqSubscription(destination, subdestination, nsqHandler, nsq.NewConfig())
When I go build the following error is returned:
cannot use nsqHandler (type "scribe/vendor/src/github.com/bitly/go-nsq".HandlerFunc) as type "messi/vendor/src/github.com/bitly/go-nsq".Handler in argument to messi.AddNsqSubscription:
"scribe/vendor/src/github.com/bitly/go-nsq".HandlerFunc does not implement "messi/vendor/src/github.com/bitly/go-nsq".Handler (wrong type for HandleMessage method)
have HandleMessage("scribe/vendor/src/github.com/bitly/go-nsq".Message) error
want HandleMessage("messi/vendor/src/github.com/bitly/go-nsq".Message) error
Why? I do not really know what is going on. The code go-nsq imported is exactly the same, yet golang wants that this code comes from the same folder?
What am I doing wrong?
Packages in Go are identified by full import path, not by name.
For example in the standard library there are two different packages with the same name template but different import paths: text/template and html/template.
You should make sure that go-nsq package is imported using the same path.

Why can't Processing 2.0b8 find a class or type named "Set"?

I'm trying to walk through a Processing tutorial and hitting a wall. I can't even run the sample starter code --I get an error: Cannot find a class or type named "Set" and this line comes back highlighted:
Set<String> tags = le.getCustomElements().getTags();
Am I missing something already?
Some default imports has gone in 2.0. Try
import java.util.*
at the beginning of the code

Resources