[Here's the Errors][1]
i'm Getting this Message Everytime with every code i export from unity
#if UNITY_CAN_USE_METAL
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>
#else
typedef NSUInteger MTLPixelFormat;
enum
{
MTLPixelFormatBGRA8Unorm,
MTLPixelFormatBGRA8Unorm_sRGB,
};
......................
#endif
I lack the reputation to comment above, so:
In Unity-iPhone/Classes/Unity/UnityMetalSupport.h, lines 20-25:
typedef NSUInteger MTLPixelFormat;
enum
{
MTLPixelFormatBGRA8Unorm,
MTLPixelFormatBGRA8Unorm_sRGB,
};
Xcode 9.0.1 gives the following errors:
Line 20: Typedef redefinition with different types ('NSUInteger' (aka 'unsigned long') vs 'enum MTLPixelFormat')
Line 23: Redefinition of enumerator 'MTLPixelFormatBGRA8Unorm'
Line 24: Redefinition of enumerator 'MTLPixelFormatBGRA8Unorm_sRGB'
My xcodeproj was generated by Unity 5.5.2f1.
Related
I've just downloaded AudioKit most recent version (4.2.2). When I ran the build_frameworks.sh I get the following error:
[AVAudioUnit?]' has no member 'compactMap'
return _effectsChain.compactMap { $0 }
^~~~~~~~~~~~~ ~~~~~~~~~~
/Users/sky/Desktop/AudioKit-4.2.2/AudioKit/Common/Nodes/Mixing/Mixer/AKMixer.swift:40:19: error: value of type '[AKNode?]' has no member 'compactMap'
self.init(inputs.compactMap { $0 })
^~~~~~ ~~~~~~~~~~
/Users/sky/Desktop/AudioKit-4.2.2/AudioKit/Common/Internals/AudioKitHelpers.swift:22:16: error: cannot invoke 'index' with an argument list of type '(Self.Index, offsetBy: Int)'
return index(startIndex, offsetBy: offset)
^
/Users/sky/Desktop/AudioKit-4.2.2/AudioKit/Common/Internals/AudioKitHelpers.swift:22:16: note: expected an argument list of type '(Self.Index, offsetBy: Self.IndexDistance)'
return index(startIndex, offsetBy: offset)
^
/Users/sky/Desktop/AudioKit-4.2.2/AudioKit/Common/Internals/CoreAudio/AudioUnit+Helpers.swift:101:29: error: missing argument for parameter 'capacity' in call
data.deallocate()
^
capacity: <#Int#>
Swift.UnsafeMutablePointer:273:17: note: 'deallocate(capacity:)' declared here
public func deallocate(capacity: Int)
^
/Users/sky/Desktop/AudioKit-4.2.2/AudioKit/Common/Nodes/Effects/Reverb/Convolution/AKConvolution.swift:144:41: error: missing argument for parameter 'capacity' in call
theData?.deallocate()
^
capacity: <#Int#>
Swift.UnsafeMutablePointer:273:17: note: 'deallocate(capacity:)' declared here
public func deallocate(capacity: Int)
^
/Users/sky/Desktop/AudioKit-4.2.2/AudioKit/Common/Nodes/Playback/Phase-Locked Vocoder/AKPhaseLockedVocoder.swift:226:41: error: missing argument for parameter 'capacity' in call
theData?.deallocate()
^
capacity: <#Int#>
Swift.UnsafeMutablePointer:273:17: note: 'deallocate(capacity:)' declared here
public func deallocate(capacity: Int)
^
/Users/sky/Desktop/AudioKit-4.2.2/AudioKit/Common/Nodes/Effects/AudioKit Operation-Based Effect/AKOperationEffect.swift:28:17: error: value of type '[NSNumber]' has no member 'compactMap'
$0.compactMap { $0.doubleValue }
^~ ~~~~~~~~~~
I tried to copy the AudioKit source code into the project I was testing: AudioKit's HelloWorld project. In this case I have the following error on XCode:
/Users/sky/Desktop/AudioKit-4.2.2/AudioKit/Common/Internals/AudioUnit Host/AKAudioUnitManager.swift:140:16: Value of type '[AVAudioUnit?]' has no member 'compactMap'
The error is thrown on source code file AKAudioUnitManager.swift on the method below:
private var linkedEffects: [AVAudioUnit] {
return _effectsChain.compactMap { $0 }
}
Also, playground is not working even with compiled framework.
I use MacOS Sierra, XCode 9.2, Swift 4, iOS 9.2.
Thanks!
I am integrating with a C library - liblinphone. It has the following typedef and function I need to call from my Swift 3 iOS app.
typedef void (*OrtpLogFunc)(const char *domain,
int lev,
const char *fmt,
va_list args);
void linphone_core_set_log_handler(OrtpLogFunc logfunc);
It appears that Swift is interpreting va_list differently when compiling for the simulator than when compiling for a device.
Here is the Swift code that uses the C function and
This compiles only when the target is the Device:
class MyClass {
func setupLogging() {
linphone_core_set_log_handler(my_callback)
}
}
func my_callback(_ domain: Optional<UnsafePointer<Int8>>,
level: OrtpLogLevel,
format: Optional<UnsafePointer<Int8>>,
args: CVaListPointer?) { // NOTE: Optional CVAListPointer
// do some logging
}
This compiles only when the target is the Simulator:
class MyClass {
func setupLogging() {
linphone_core_set_log_handler(my_callback)
}
}
func my_callback(_ domain: Optional<UnsafePointer<Int8>>,
level: OrtpLogLevel,
format: Optional<UnsafePointer<Int8>>,
args: CVaListPointer) { // NOTE: CVAListPointer is NOT optional
// do some logging
}
When I run on the device, logging works, so it appears that using the optional CVaListPoint? is the safest, so how do I get this to compile for the simulator.
The first version only compiles and runs on a device but issues this compiler error when targeting the simulator:
Swift Compiler Error
C function pointer signature
'(Optional<UnsafePointer<Int8>>, OrtpLogLevel,
Optional<UnsafePointer<Int8>>, CVaListPointer?) -> ()'
is not compatible with expected type 'OrtpLogFunc' (aka
'#convention(c)
(Optional<UnsafePointer<Int8>>, OrtpLogLevel,
Optional<UnsafePointer<Int8>>, CVaListPointer) -> ()')
The second version only compiles when targeting the simulator, but when targeting a device, it issues this error:
Swift Compiler Error
Cannot convert value of type
'(Optional<UnsafePointer<Int8>>, OrtpLogLevel,
Optional<UnsafePointer<Int8>>, CVaListPointer) -> ()'
to expected argument type 'OrtpLogFunc!'
Is there some way I can force the simulator to accept this function without changing the C headers?
Or, is there something I can do in Swift to make this work?
You'd better send a bug report to Apple or swift.org as soon as possible.
And, until this issue will be fixed, this sort of coding would be a workaround:
let my_callback: OrtpLogFunc = {domain, level, format, _args in
let args: CVaListPointer? = _args
// do some logging
}
I know what duplicate symbol linker error means, but in my case I don't know how I'm getting it. I have the following file, which defines some simple globals
// defines.h
#ifndef _DEFINES_H
#define _DEFINES_H
BOOL useTestCode = YES;
#endif
Then I import it in two *.m files, and use the global.
// someFile1.m
#import "defines.h"
- (void)foo
{
if (useTestCode) {
NSLog(#"Using test code");
}
else {
NSLog(#"NOT Using test code");
}
}
// someFile2.m
#import "defines.h"
- (void)foo
{
if (useTestCode) {
NSLog(#"Using test code");
}
else {
NSLog(#"NOT Using test code");
}
}
If I comment out one of the #import "defines.h" statement in either file, I don't get the duplicate symbol linker error, but of course the corresponding *.m file will fail to compile. Why am I getting the duplicate symbol linker error? How do I solve it in iOS 7?
Here is the linker error message. It's literally for the simple code above.
duplicate symbol _useTestCode in:
/Users/cfouts/Library/Developer/Xcode/DerivedData/DupSymbol-bnfownlxdoyqelbhxzpyaaitfshy/Build/Intermediates/DupSymbol.build/Debug-iphonesimulator/DupSymbol.build/Objects-normal/x86_64/DSsomeFile2.o
/Users/cfouts/Library/Developer/Xcode/DerivedData/DupSymbol-bnfownlxdoyqelbhxzpyaaitfshy/Build/Intermediates/DupSymbol.build/Debug-iphonesimulator/DupSymbol.build/Objects-normal/x86_64/DSsomeFile1.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
in your header you have
BOOL useTestCode = YES;
which is copied to every .m file that includes it so you have multiple useTestCode symbols
you need to change the header to contain
extern BOOL useTestCode;
and in one .m file, define the variable
BOOL useTestCode = YES;
Though Bryan C's answer is one solution, and it gave me a clue, I like this better.
// defines.h
#ifndef _DEFINES_H
#define _DEFINES_H
static BOOL useTestCode = YES;
#endif
I have a CFUserNotificationDisplayAlert setup like this:
CFOptionFlags cfRes;
CFUserNotificationDisplayAlert(5, kCFUserNotificationNoteAlertLevel,
NULL, NULL, NULL,
CFSTR("Okay"),
CFSTR("Stop!"),
&cfRes);
switch (cfRes)
{
case kCFUserNotificationDefaultResponse:
strTest = CFSTR("Default response");
break;
case kCFUserNotificationAlternateResponse:
strTest = CFSTR("Alternate response");
break;
}
With this code I get this error:
use of undeclared identifier kCFUserNotifactationDefualtResponce (And the other kCF*'s)
Any ideas? I have the following imported:
#import <CoreFoundation/CoreFoundation.h>
#import <CoreData/CoreData.h>
#import <UIKit/UIKit.h>
The CFUserNotification API is not available on iOS. Looks to me like you copied that bit of code from a Mac App.
Quoted from CodaFi's comment above so question can be marked as answered as per: https://meta.stackexchange.com/questions/54718/how-should-i-handle-questions-which-are-answered-in-the-comments
I'm busy with a library of a collegae. In his code he sets isa a few times. This stills works but is officially deprecated. The alternative should be the object_setClass function. But when I replace it I get a warning: Implicit declaration of function 'object_setClass' is invalid in C99.
Perhaps i am missing an import or something? Anyone an idea? Thanks.
if(nodePtr->type == XML_ELEMENT_NODE)
{
self->isa = [DDXMLElement class];
//object_setClass(self, [DDXMLElement class]);
}
else if(nodePtr->type == XML_DOCUMENT_NODE)
{
self->isa = [DDXMLDocument class];
//object_setClass(self, [DDXMLDocument class]);
}
It's declared in #include <objc/runtime.h> -- have you included that header?