"Unresolved function call" in MQL with configs all set - mql4

Phenomenon: I've already build a library file, and the EA that uses the library has been exeucted smoothly for months. The code is just like that:
In library file:
void MyFunction(int mode)
....
In EA:
#import "MyLibrary.ex4"
void MyFunction(int mode);
#import
......
MyFunction(1);
Now I opened a new script, calling Test.mq4 and just COPY AND PASTE the related code in my EA. just like:
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#import "MyLibrary.ex4"
void MyFunction(int mode);
#import
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
MyFunction(1);
}
Executing the script. Always get the message: Unresolved function call; Cannot find "Myfunction" in MyLibrary.ex4.
This has been occurred some times. Once I resolved it by opening a new script, copying everything in stdlib.mq4 into it, and replace the body with my own code and it worked. But this time it doesn't. I'm curious what's wrong behind it so that importing failed?
I've already recompiled the library, the EA, and the test script multiple times.

Finally I made the solution: Explicitly delete the ex4 file you compiled before, then click the recompile button, and it is resolved. It seems when the file exists, re-compile the file cannot override some configs that is malfunctioned in my side, so you must find the directory of your ex4 file and manually remove it.

Related

How to set PT_DENY_ATTACH in Xamarin.iOS?

We recently had a pen tester audit our app and one of the findings was that a person with a jailbroken device can attach a local debugger.
The solution they suggested was to enable PT_DENY_ATTACH when starting up the app. This is fairly easy to do in a native app but I haven't been able to figure it out with our Xamarin app (not forms).
I've tried creating an objc framework in Xcode, binding that and pulling it in. I've also tried to create a shared c++ library but that isn't possible in VS Mac.
I know that PT_DENY_ATTACH has been circumvented but I'd still like to know how to implement it.
Thanks!
It turns out that my objc framework was behaving properly just not in the way I expected. For some reason I was still able to attach the Visual Studio debugger but when I move to Xcode and try to attach its debugger it fails when the framework is called.
To answer my question:
In Xcode I created a new static library with one class:
GDBManager.h
#import <Foundation/Foundation.h>
#interface GDBManager : NSObject
+(void)DisableGDB;
#end
GDBManager.m
#import "GDBManager.h"
#import <dlfcn.h>
#import <sys/types.h>
#implementation GDBManager
typedef int (*ptrace_ptr_t)(int _request, pid_t _pid, caddr_t _addr, int _data);
#define PT_DENY_ATTACH 31
+(void)DisableGDB {
void* handle = dlopen(0, RTLD_GLOBAL | RTLD_NOW);
ptrace_ptr_t ptrace_ptr = dlsym(handle, "ptrace");
ptrace_ptr(PT_DENY_ATTACH, 0, 0, 0);
dlclose(handle);
}
#end
I followed these instructions to create a fat file for my library and to use that in a binding project.
https://learn.microsoft.com/en-us/xamarin/ios/platform/binding-objective-c/walkthrough
I then add the generated dll to my Xamarin.iOS project and call it above UIApplication.Main(args, null, "AppDelegate"); in Main.cs

Swift framework - Use Swift class reference in Objective-C class

I am creating Swift framework in which I have to use Objective-C class. So I went through this link. This is the public header of my framework :
#import <UIKit/UIKit.h>
//! Project version number for Test.
FOUNDATION_EXPORT double TestVersionNumber;
//! Project version string for Test.
FOUNDATION_EXPORT const unsigned char TestVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Test/PublicHeader.h>
#import <arpa/inet.h>
#import <ifaddrs.h>
#import <netdb.h>
#import <sys/socket.h>
#import <MyTest/MPAppDelegateProxy.h>
Now in class MPAppDelegateProxy, I have to use a Swift class which I have created. This is :
#import "MPAppDelegateProxy.h"
#import "MyTest.h"
#implementation MPAppDelegateProxy
+ (void)proxyAppDelegate {
[MPGlobal MPLog:#"App delegate not set, unable to perform automatic setup." file:#"MPAppDelegateProxy.m" function:#"proxyAppDelegate" line:32];
// rest of code
}
MPGlobal is one of my Swift class. But I am getting :
Use of undeclared identifier 'MPGlobal'
Note : I have added #objC before MPGlobal.
You need to import <Target>-Swift.h file.
This is known as Objective-C Generated Interface Header Name.
You can find it in your Target's build settings.
This file is auto generated by compiler and it needs to be imported in Objective-C files.
change the SWIFT_OBJC_INTERFACE_HEADER_NAME build setting and making it the same across different targets. To do so change the instruction that generates this property from $(SWIFT_MODULE_NAME)-Swift.h to $(PROJECT_NAME)-Swift.h as explained here
After doing this Clean Build Folder by pressing Alt and going into Product menu. Since name of header is shared among targets now it can be imported once in the .m ObjectiveC file and all targets can benefit from Swift classes.
If after building it still shows the error, ensure that the header can be reached from XCode by Cmd clicking on its name. It should open a file that contains code similar to this:
SWIFT_CLASS("_TtC27ProjectName_Summary11MyClass")
#interface MyClass : NSObject
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
#end
If need to ensure that those headers are being generated open a terminal and use this command
find ~/Library/Developer/Xcode/DerivedData -name "*Swift.h"
You should see one header for each target
Another issue that happened to me after those changes is that it started giving errors on ObjectiveC code that I didn't touch. The problem was due to the position of the import, as reported here:
Exactly where at the top of a .m file you #import the hidden bridging
header can make a difference. The usual sign of trouble is that you
get an “Unknown type name” compile error, where the unknown type is a
class declared in Objective-C. The solution is to #import the .h file
containing the declaration for the unknown type in your Objective-C
files as well, before you #import the hidden bridging header. Having
to do this can be an annoyance, especially if the Objective-C file in
question has no need to know about this class, but it resolves the
issue and allows compilation to proceed.
At the very end the code compiles and runs on device and simulator!
Original answer
Also you can try this,
You needed to import the -Swift.h for for both the framework and the app target
For Example :
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <Foundation/Foundation.h>
#import "XLPagerTabStrip-Swift.h"
#import "RealmSwift-Swift.h"
...... // Add all frameworks, subclasses, and dependance ios frameworks
#import "MyProject-Swift.h"
You can read this article How to import file header and check paths

React Native Redefinition of 'RCTMethodInfo' in RCTBridgeModule.h

React Native 0.49 in iOS I clone my project install npm and link from git and run but it has error in RCTBridgeModule.h in code
typedef struct RCTMethodInfo {
const char *const jsName;
const char *const objcName;
const BOOL isSync;
} RCTMethodInfo;
it have 2 Error
Redefinition of 'RCTMethodInfo' and Typedef redefinition with different types ('struct (anonymous struct at ../../react-native/React/Base/RCTBridgeModule.h:57:16)' vs 'struct RCTMethodInfo')
I fine solution and included
#if __has_include(<React/RCTBridgeModule.h>)
#import <React/RCTBridgeModule.h>
else
#import "RCTBridgeModule.h"
#endif
but it error same
I happend to encountered this issue just now.It was caused by a third party
penguin called "react-native-weibo".I just changed #import "RCTBridgeModule" to #import <React/RCTBridgeModule.h> inside RCTWeiboAPI
,then everything is ok now.
so if your issue is caused by third party penguin also,just try to change #import "xxxx.h" to #import <React/xxxx.h> inside third party API.
Hope it works.
I encountered this issue and solved it by deleting Derived Data. The issue was appear cause of up-gradation of project via xcode 10. Previous project's derived data from xcode 9 also present which was unable to delete by cleaning the project for some reason.
You can manually delete the project build files in Derived Data or use command below.
rm -rf ~/Library/Developer/Xcode/DerivedData
Hope it helps!

XCode use of undeclared identifier, only appears if the file is opened

When I clean, build and run my XCode project all goes well, but if I open a file that calls the function, an Use of undeclared identifier 'func()' appears. This is the whole implementation:
The function is called:
func();
And 'func()' is decleared in a .h file like so:
#if __cplusplus
extern "C" {
#endif
extern void func();
#if __cplusplus
}
#endif
and func() is implemented is a cplusplus library.
Why would the error ONLY appears if the file is open, but if I don't open it, it runs and works just fine?
Xcode has two ways of generating error messages. Usually both of these generate the same messages, so you do not detect that there are two systems.
The first system is the editor which does syntax coloring and auto-completion. It will also show error messages almost instantly after you write an error.
The second system is errors shown in the build log.
I suspect that your project has a complicated include setting. This prevents the first system from finding the correct file to include and therefore it cannot find the definition of func().

error in ACAccount.h in Simulator-iOS 7.1

I'm trying to build and test an app with the xcode simulator, but during the building I get errors in ACAccount.h, ACAccountType.h, etc.
The "strange thing" (at least for me as i'm completely new in using xcode) is that if I click on the .h files with errors they do not appear under the project code but under
Simulator - iOS 7.1-> Frameworks -> Accounts -> ACAccount.h
which is unmodifiable.
Examples of the errors are:
line:
#class ACAccountType,ACAccount Credential; --> Illegal interface qualifier
ACCOUNTS_CLASS_AVAILABLE(NA, 5_0)
#interface ACAccount : NSObject -->Objective-C declarations may only appear in global scope
If the .h are predefined files.. How can I solve these errors?
Many thanks in advance!
Generally when you encounter items like the 'illegal interface qualifier' in system provided headers it indicates that you've placed the #import statement within an #interface block, like:
#interface foo ()
#import <Accounts/ACAccount.h>
#end
This generates errors about the content in the file being imported (e.g. your illegal interface qualifier error), while the actual issue is that putting #import statements within an #interface block is invalid.
You should put #import statements together at the top of the file, outside of any #interface or #implementation blocks.
If you put it into the #implementation section, the error becomes:
error: Objective-C declarations may only appear in global scope

Resources