OCUnit will not allow me to use my own data types - iphone

I am using XCode 3.2.2 to unit test some custom data types. The tests run properly without those data types, but when I use said data types, I get this error:
"_OBJC_CLASS_$_classname", referenced from:
(where "classname" is the, well, class name...)
I have seen hints online that it could be linker related. The strange thing is, I originally followed these instructions http://www.mobileorchard.com/ocunit-integrated-unit-testing-in-xcode/ and they worked for me the first time I tried them. Now, after following the same instructions, I'm getting the same error. Any help would be greatly appreciated.
Thanks!
-Matt

Unfortunately your question is pretty ambiguous.
First, is the example working given in the mentioned tutorial?
Second, I'd double check your code:
Right click the class (.m) you're trying to use with OCUnit and click get info. Make sure the target in the class file is pointing to OCUnit! This is key for the linking.
Are you importing your .h for the associated class in the test case?
Check the spelling of the class names?

Related

Xcode 11 doesn't recognize Core data Entity

I just declared an entity called "Users" array:
var UsersArray = [Users]()
I got this error:
use of unresolved identifiers "Users"
hint : I did import CoreData and created the entity
Please try this solutions !!
Solution 1 :-
Product->Build for testing solved this issue for me(it solves most unresolved identifier bugs for some strange reason)
Solution 2 :-
changing import Foundation to import UIKit.
It seems like UIApplication isn't included in Foundation framework.
Solution 3 :- Highlight the Data Model, go to Editor -> Create NSManagedObject Subclass...
Solution 4 :-
Create the NSManagedObject files and then delete them and everything is fixed.
Hope this helps thank you.
If your entity is actually created, just close and re-open XCode. This works for me everytime. The other solutions, such as clean build, build etc, didn't work for me.
Just ran into this issue after renaming an entity and figured I should post here how I resolved it.
Typically after making changes in the data model and getting compilation errors, I just do Product > Clean Build Folder, then Product > Build and that should take care of the errors.
However, the steps above didn't help this time. After scratching my head for while, I found the culprit with following steps:
In the Project navigator, select your .xcdatamodelId file
In the Configurations section, select the appropriate configuration
Look for the entity in question and make sure the class name is correct (in my case, the entity and the class were not the same)
Other possible solutions:
(A) Re-launch Xcode
This is the solution that worked for me. (See this answer)
(B) Check if you did not forget to finalize your entity description
Typically: forgot to assign a type to one of the attributes (still "undefined").
(C) Clear derived data
Reason: The generated core data managed objects subclasses's source code files are in the project’s derived data location.
Note: you might have to re-link your swift packages is using SPM.
I also had to deal with this issue even working with the latest Xcode12.3 on a SwiftUI project where I didn't checked the CoreData option at project creation.
After adding a class to instantiate the NSPersistentContainer, loading the stores, creating model.xcdatamodel file with an entity and a text field plus a button on a view, then it shows an error saying: "cannot find Item in scope".
It's a bit difficult to write code when you expect the entity to help out with autocomplete. First, I thought I forgot to initialize my class or missed a bracket, but it wasn't that either.
I tried cleaning up, rebuilding and running the project several times with build failed as result. I had to close this particular project then all errors got dismissed. No needed to restart Xcode.
I faced the same issue. Doesn't included Coredata on the beginning of the project. Later added necessary files and core data stack. But when trying to fetch the data from the Entity name and the Xcode throwing the same error.
Later, I closed the project and again opened on Xcode and it started to work.
I had this issue with an .xcdatamodel that I had created in another project and moved it into this one.
I solved it by selecting the .xcdatamodel file, turned of the "File Inspector" and then under "Target Membership", I made sure that all the targets were selected.
for me the entity name and class name was different, and I was refering to entity name for Data Type

Cannot load underlying module for XCTest after add language

My app work well, in the last days I update a language and everything it's ok, today i put the 3th with the same process and my app give me this error "Cannot load underlying module for XCTest" I have just try a lot of solutions but without win...
This is a shot in the dark, as it's not entirely clear what the question here is. If I'm understanding right, though, you added another localization (the 3rd language supported by your app), and this now led to you seeing the Cannot load underlying module for XCTest error. If that's the case, I'd check that your new localization file is set to the right target: it should be set to the main target, not your testing target.
This question and it's answers also seem relevant here, if it's not your localization file it sounds like a file has the wrong target membership.

Import third party C library into swift causes error "Include of non-modular header inside framework module"

This question is a continuation of a previous one I'm currently migrating this (https://github.com/emilwojtaszek/leveldb-swift) library from swift 2 to swift 3/4. Here is the link to my fork https://github.com/lu4/leveldb-swift/tree/MigrationFromSwift2ToSwift3 (please note that the target branch is MigrationFromSwift2ToSwift3)
I was able to resolve (with many thanks to #Ruslan Serebriakov) all of the issues with initial code base and check that the code is running.
However after trying to update LevelDB C code to latest master I got new type of error which I don't understand how to resolve:
Include of non-modular header inside framework module 'LevelDB.c': '/Path/to/Project/leveldb-swift-migration/vendor/leveldb/include/leveldb/export.h'
I've did some research on the internet but the issues described there seem non-related with one I've stumbled on. Here is an image of the issue
Any help is appreciated, thank you in advance!
I'm never 100% certain with mixed language frameworks. But an error like this happens in Swift projects when:
since you cannot use a Bridging Header in frameworks,
you #import a C header in the Foo-Framework.h to expose it so the Swift code, and
the header is not itself marked "Public" to the target.
"Non-modular" seems to indicate "not part of the published module interface". At least with Swift--C mixes, you can only combine both through making the C headers public; no way to import private header files there, which is weird.
Give it a shot: Since you are obviously importing the file in non-Swift code, try to locate the export.h header file in your Xcode project, open the File inspector (⌘⌥1), and ensure public visibility in the framework target:
This issue is because the SDK u are importing is not modular or u can say modulemap file is missing. So make sure modulemap file should be available inside the framework folder. Also make sure that all public headers are listed explicitly in the modulemap. This issue will be resolve 100% if module map file will be include in the third party framework.

Only factor methods can have swift_name attribute Mapbox

I'm using cocoa pods and map box was working fine but I installed an update and this message appeared:
Now I can't run my project. I'm using map box iOS sdk 3.3.4. What should I do to fix this issue?
According to apple documentation:
The Swift compiler automatically imports Objective-C code as conventional Swift code. There may be edge cases in your code that are not automatically handled. If you need to change the name imported by Swift of an Objective-C method, enumeration case, or option set value, you can use the NS_SWIFT_NAME macro to customize how a declaration is imported. See more.
So all what I did was delete the implementation of the NS_SWIFT_NAME and with that I was able to build the project. I don't know what made this error appear but this was the best solution I found.
Example:
From this:
- (instancetype)recordWithRPM:(NSUInteger)RPM NS_SWIFT_NAME(init(RPM:));
To this:
- (instancetype)recordWithRPM:(NSUInteger)RPM;

unable to create new static Library out of existing source code

I'v done quite a bit of R&D on creating static libraries in iOS and came across some well written blogs. I followed this link and also this to create a static library. I have follwed the steps specified in those blogs i.e, i added all the implementation files(.m) to the static library and deleted them from the main target etc... But, i am getting around 700 erros (which is quite bizarre) when i try to build the code. i am posting a screenshot of my errors here..
Is there anything that i am missing here or doing wrong?
Please check the imported Header files.
The .m files, which have these errors, may have the same imported files.
Maybe a semi-comma or parentheses is missing or used incorrectly.