Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error when running c++ tests in KIF #733

Closed
snoopying opened this issue Oct 29, 2015 · 8 comments · Fixed by #1006
Closed

Build error when running c++ tests in KIF #733

snoopying opened this issue Oct 29, 2015 · 8 comments · Fixed by #1006

Comments

@snoopying
Copy link

System macro is causing issues when running C++ tests in KIF

In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/locale:192:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:131:9: error: expected unqualified-id

using ::system;

    ^

In file included from /Users/test/Documents/iOS/Tests/test.mm:19:

In file included from /Users/test/Library/Developer/Xcode/DerivedData/frxusjxqwcj/Build/Products/Debug-iphonesimulator/include/KIF/KIF.h:12:

/Users/test/Library/Developer/Xcode/DerivedData/fwcj/Build/Products/Debug-iphonesimulator/include/KIF/KIFSystemTestActor.h:13:16: note: expanded from macro 'system'

define system KIFActorWithClass(KIFSystemTestActor)

           ^

In file included from /Users/test/Documents/iOS/Tests/test.mm:19:

In file included from /Users/test/Library/Developer/Xcode/DerivedData/frxzxqwcj/Build/Products/Debug-iphonesimulator/include/KIF/KIF.h:10:

/Users/test/Library/Developer/Xcode/DerivedData/frxusqwcj/Build/Products/Debug-iphonesimulator/include/KIF/KIFTestActor.h:18:34: note: expanded from macro 'KIFActorWithClass'

define KIFActorWithClass(clazz) [clazz actorInFile:[NSString stringWithUTF8String:FILE] atLine:LINE delegate:self]

                             ^

1 error generated.

Also reported here...

https://groups.google.com/forum/#!topic/kif-framework/qgWxVL644DU

Is there a workaround for this issue or will this be fixed?

Thanks

@mikelupo
Copy link
Contributor

Tony/Brian, I don't know this area of KIF code at all, but I'm curious to know what we can do about the issue.

Thanks,
Mike

-----Original Message-----
From: snoopying notifications@github.com
To: kif-framework/KIF KIF@noreply.github.com
Sent: Thu, Oct 29, 2015 7:56 pm
Subject: [KIF] Build error when running c++ tests in KIF (#733)

System macro is causing issues when running C++ tests in KIF
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/locale:192:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:131:9: error: expected unqualified-id
using ::system;
^

In file included from /Users/test/Documents/iOS/Tests/test.mm:19:
In file included from /Users/test/Library/Developer/Xcode/DerivedData/frxusjxqwcj/Build/Products/Debug-iphonesimulator/include/KIF/KIF.h:12:
/Users/test/Library/Developer/Xcode/DerivedData/fwcj/Build/Products/Debug-iphonesimulator/include/KIF/KIFSystemTestActor.h:13:16: note: expanded from macro 'system'
#define system KIFActorWithClass(KIFSystemTestActor)
^

In file included from /Users/test/Documents/iOS/Tests/test.mm:19:
In file included from /Users/test/Library/Developer/Xcode/DerivedData/frxzxqwcj/Build/Products/Debug-iphonesimulator/include/KIF/KIF.h:10:
/Users/test/Library/Developer/Xcode/DerivedData/frxusqwcj/Build/Products/Debug-iphonesimulator/include/KIF/KIFTestActor.h:18:34: note: expanded from macro 'KIFActorWithClass'
#define KIFActorWithClass(clazz) [clazz actorInFile:[NSString stringWithUTF8String:FILE] atLine:LINE delegate:self]
^

1 error generated.
Also reported here...
https://groups.google.com/forum/#!topic/kif-framework/qgWxVL644DU
Is there a workaround for this issue or will this be fixed?
Thanks

Reply to this email directly or view it on GitHub.

@phatmann
Copy link
Contributor

Clearly using macros with no prefix at global scope is a terrible idea. At the very least we could rename the macros to KIF_system and KIF_tester. But really we should get rid of them entirely. We need to anyway for Swift compatibility.

Tony

On Oct 29, 2015, at 7:06 PM, mikelupo notifications@github.com wrote:

Tony/Brian, I don't know this area of KIF code at all, but I'm curious to know what we can do about the issue.

Thanks,
Mike

-----Original Message-----
From: snoopying notifications@github.com
To: kif-framework/KIF KIF@noreply.github.com
Sent: Thu, Oct 29, 2015 7:56 pm
Subject: [KIF] Build error when running c++ tests in KIF (#733)

System macro is causing issues when running C++ tests in KIF
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/locale:192:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:131:9: error: expected unqualified-id
using ::system;
^

In file included from /Users/test/Documents/iOS/Tests/test.mm:19:
In file included from /Users/test/Library/Developer/Xcode/DerivedData/frxusjxqwcj/Build/Products/Debug-iphonesimulator/include/KIF/KIF.h:12:
/Users/test/Library/Developer/Xcode/DerivedData/fwcj/Build/Products/Debug-iphonesimulator/include/KIF/KIFSystemTestActor.h:13:16: note: expanded from macro 'system'
#define system KIFActorWithClass(KIFSystemTestActor)
^

In file included from /Users/test/Documents/iOS/Tests/test.mm:19:
In file included from /Users/test/Library/Developer/Xcode/DerivedData/frxzxqwcj/Build/Products/Debug-iphonesimulator/include/KIF/KIF.h:10:
/Users/test/Library/Developer/Xcode/DerivedData/frxusqwcj/Build/Products/Debug-iphonesimulator/include/KIF/KIFTestActor.h:18:34: note: expanded from macro 'KIFActorWithClass'
#define KIFActorWithClass(clazz) [clazz actorInFile:[NSString stringWithUTF8String:FILE] atLine:LINE delegate:self]
^

1 error generated.
Also reported here...
https://groups.google.com/forum/#!topic/kif-framework/qgWxVL644DU
Is there a workaround for this issue or will this be fixed?
Thanks

Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub #733 (comment).

@bnickel
Copy link
Contributor

bnickel commented Oct 30, 2015

Renaming to KIF_system and KIF_tester would be a breaking change. (Major version bump.) I'd rather not go down that road until we're ready for v5. We also can't really get rid of them entirely because the only way to get __FILE__ and __LINE__ in Objective-C without brutal boilerplate is macros.

Assuming that KIF doesn't today work for anyone using C++, we could wrap it:

#ifdef __cplusplus
#define systemTester KIFActorWithClass(KIFSystemTestActor)
#else
#define system KIFActorWithClass(KIFSystemTestActor)
#endif

I am interested in why you're using Objective-C++ for tests. Are you using a C++ testing framework? Generally speaking, even if your app is written in Objective-C++, you should be able to do your KIF testing with Objective-C (or Swift).

@snoopying
Copy link
Author

App is in C++ and these were existing C++ tests that I'm trying to automate. I've used KIF before for another app in objective C which worked well.

tried adding the following to KIFSystemTestActor.h but getting a bunch of linker errors

#ifdef __cplusplus
#define systemTester KIFActorWithClass(KIFSystemTestActor)
#else
#define system KIFActorWithClass(KIFSystemTestActor)
#endif

Errors:

Undefined symbols for architecture i386:
"_NSStringFromCGPoint", referenced from:
___35-[KIFUITestActor tapScreenAtPoint:]_block_invoke in libKIF.a(KIFUITestActor.o)
"OBJC_CLASS$UIAccessibilityElement", referenced from:
l_OBJC
$CATEGORY_UIAccessibilityElement$_KIFAdditions in libKIF.a(UIAccessibilityElement-KIFAdditions.o)
objc-class-ref in libKIF.a(UIAccessibilityElement-KIFAdditions.o)
objc-class-ref in libKIF.a(KIFUITestActor.o)
objc-class-ref in libKIF.a(UIView-KIFAdditions.o)
objc-class-ref in libKIF.a(KIFUITestActor-IdentifierTests.o)
objc-class-ref in libKIF.a(KIFUITestActor-ConditionalTests.o)
"OBJC_CLASS$_UIApplication", referenced from:

@snoopying
Copy link
Author

bump

is there another workaround for this issue? getting a build error after renaming system macro in KIF framework

@bnickel
Copy link
Contributor

bnickel commented Nov 3, 2015

That means your test target is failing to link against UIKit. You need to add UIKit to your linked libraries and make sure you're using your app as the test host. Even if you already have a working unit test target, it's usually easiest to create a separate test target for KIF. I would just create a new Unit Testing Bundle and select the app as the test host.

@snoopying
Copy link
Author

Thank you!! that got the tests running.

voznesenskym added a commit to voznesenskym/KIF that referenced this issue Jul 31, 2017
According to kif-framework#733, this collides with stdlib. We have just encountered this ourselves in our code base.
@voznesenskym
Copy link
Contributor

I opened a PR here: #988

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants