'iterator' file not found when compiling bar for iOS - clang

I was using Xcode 11 to compile zbar for my iOS Device.
However it gives me this error:'iterator' file not found
Some code:
#ifndef _ZBAR_IMAGE_H_
#define _ZBAR_IMAGE_H_
/// #file
/// Image C++ wrapper
#ifndef _ZBAR_H_
# error "include zbar.h in your application, **not** zbar/Image.h"
#endif
#include <assert.h>
#include <iterator>
#include "Symbol.h"
#include "Exception.h"
I have tried to clean and rebuild and this didn't seem to work.
Environment:
Mac OS Catalina 10.15 Beta (19A558d)
Xcode 11.0(11A420a)
C11

<iterator> is a c++ reference, please refer to here.
so,
a. Renaming the image.c to image.cpp
or
b. Compile with g++, NOT gcc
would be helpful.

Related

Unable to build the library using cargo lipo --release

Unable to build the library using cargo lipo --release
I am trying to make a cross-platform library using rust for ios target. I am following this article (Building and Deploying a Rust library on iOS).
*Note: I followed the same steps and my project structure also looks the same *
After completing the code and project setup the last step is to build the library. When I try to build the library using cargo lipo --release. It throws this error:
[ERROR cargo_lipo] No library target found for "my-project-name"
Also, note that I am only able to install support for two platforms. (aarch64-apple-ios and x86_64-apple-darwin). I think the reason is that they have dropped the support for 32-bit architectures.
So, when I run
rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i386-apple-ios.
It throws error: error: component 'rust-std' for target 'armv7-apple-ios' is unavailable for download for channel stable
Cargo.toml
[package]
name = "rustylib"
version = "0.1.0"
edition = "2018"
crate-type = ["staticlib", "cdylib"]
rustylib.rs
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
char *hello(const char *to);
void hello_release(char *s);
The rest of the project structure is the usual rust code.
The output of rustup show
Default host: x86_64-apple-darwin
rustup home: /Users/my-username/.rustup
installed toolchains
stable-x86_64-apple-darwin
nightly-x86_64-apple-darwin (default)
installed targets for active toolchain
aarch64-apple-ios
x86_64-apple-darwin
active toolchain
nightly-x86_64-apple-darwin (default)
rustc 1.52.0-nightly (acca81892 2021-03-13)
OS & Rust
Rust: rustc 1.50.0 (cb75ad5db 2021-02-10)
OS: macOS Bug Sur (11.2.3)
Xcode & Command line tools: 12.4
Your Cargo.toml is wrong.
If you look into the guide you linked in your question, you can see, that the crate-type has to be below the [lib] tag like so:
[package]
name = "greetings"
version = "0.1.1"
authors = ["fluffyemily <fluffyemily#mozilla.com>"]
description = "Example static library project built for iOS"
publish = false
[lib]
name = "greetings"
crate-type = ["staticlib", "cdylib"]
Also your code has to be in cargo/src/lib.rs by default as stated in the document (and not in rustylib.rs).
You can run cargo new rustylib --lib from the command line to create all the boilerplate, so that you only have to add the dependencies and the crate-type in the [lib] section of your Cargo.toml.
Edit
I think there is another problem:
You have entered C code in your rustylib.rs file, which can not work. I think what you intended to do, was to create the C bridge, which is called cargo/src/greetings.h in the guide you linked.

Clang OpenMP version, can not get latest

I have installed clang and llvm version 9 using instructions from https://apt.llvm.org/ .
Next I try to get my version of openmp from clang compiler, so I created file openmp_v.cpp:
#include <unordered_map>
#include <cstdio>
#include <omp.h>
int main(int argc, char *argv[])
{
std::unordered_map<unsigned,std::string> map{
{200505,"2.5"},{200805,"3.0"},{201107,"3.1"},{201307,"4.0"},{201511,"4.5"}};
printf("We have OpenMP %s.\n", map.at(_OPENMP).c_str());
printf("Version: %d.\n", _OPENMP);
return 0;
}
and compile it:
clang++-9 -std=c++17 -fopenmp openmp_v.cpp -o openmp_v -fopenmp=libiomp5
The result is:
We have OpenMP 3.1.
Version: 201107.
The problem is that the openmp version should be 4.5 and not 3.1, because clang-9 support openMp 4.5.
I even installed libomp-9-dev and nothing have changed.
Also, I have located llvm-9 include and lib files, which are in: /usr/lib/llvm-9
and try to add them as:
clang++-9 -std=c++17 -fopenmp openmp_v.cpp -o openmp_v -fopenmp=libiomp5 -I /usr/lib/llvm-9/include/openmp -L /usr/lib/llvm-9/lib/
But it still doen't work.
EDIT: replaced placeholder with reply.
After a bit of conversation with one of the clang developers, it's not really clear if this is a bug in clang or more a feature. IMHO, it could be that the version string for _OPENMP was not correctly set, when clang 9.0 was branched from the mainline code version.
The mainline version in the repository correctly reports 201511 for _OPENMP, which corresponds to OpenMP API Version 4.5. I think this is correct, as clang (to my knowledge) does not yet fully support OpenMP 5.0.
So, clang 10.0.0 will correctly report the version number. I'm not sure if there will be a bugfix release of clang 9.0.0 that will also fix this issue.
Hope that helps!

React-native 0.57 ios limits file not found could not build module CoreFoundation

RN 0.57.1
RN-cli 2.0.1
xCode: 9.4.1 (9F2000) or xCode 10
After an update of RN from 0.56 to 0.57.0 (or 0.57.1) I get a lot of could not build module 'CoreFoundation' or could not build module Foundation or limits file not found
I followed exactly the steps from RN doc for this update.
I tried removing ios/build folder, cleaning cache, re-installing everything but nothing worked.
▸ Building BunteMobile/OneSignalNotificationServiceExtension [Debug] ▸
Check Dependencies ▸ Compiling NotificationService.m
/Users/myuser/Desktop/projects/mobileapp/ios/../node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/float.h:8:10:
'limits' file not found
#include <limits>
/Users/myuser/Desktop/projects/mobileapp/ios/../node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/float.h:8:10:
'limits' file not found
#include <limits>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:10:
could not build module 'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h:28:10:
could not build module 'CoreFoundation'
#include <CoreFoundation/CFBase.h>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h:18:10:
could not build module 'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/NSString+UserNotifications.h:8:9:
could not build module 'Foundation'
#import <Foundation/Foundation.h>
If I remove the OneSignalNotificationServiceExtension instead of 7
errors I get another 15 errors in other parts of the project:
/Users/myuser/Desktop/projects/mobileapp/ios/../node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/float.h:8:10:
'limits' file not found
#include <limits>
/Users/myuser/Desktop/projects/mobileapp/ios/../node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/float.h:8:10:
'limits' file not found
#include <limits>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:10:
could not build module 'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h:28:10:
could not build module 'CoreFoundation'
#include <CoreFoundation/CFBase.h>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h:18:10:
could not build module 'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
/Users/myuser/Desktop/projects/mobileapp/ios/build/Build/Products/Debug-iphonesimulator/include/React/RCTBridgeModule.h:8:9:
could not build module 'Foundation'
#import <Foundation/Foundation.h>
The only workaround that I found is to downgrade RN back to 0.56...
According to the RN team answer from here
https://github.com/facebook/react-native/issues/21482
changing all babel deps to 7 should fix the issue but even after an npx babel-ugrade -w and a reinstall of node modules + cache clean I get the same errors.
but still same problems.
Should any with header search paths be updated in extensions/ios build settings after update to 0.57?
I've spent 3 days with this IOS building issue....
Note: I was able to build android after the upgrade of RN and babel.
React-native git associated ticket:
https://github.com/facebook/react-native/issues/21482
To fix all these errors I had to remove React and ReactCommon from Project Header Search paths and from OneSignalNotificationServiceExtension target header search paths.
1) Removing from project header search paths:
The crashes were related to limits, CoreFoundation, Foundation and CoreGraphics.
I went to Project Header Search Paths and removed the React and ReactCommon dependencies from there.
This is how my project header search paths looks now:
2) Removing from one-signal extension: (Optional, if you don't have any extension you don't have to do this)
This is how the paths of that extension used to look when crashing:
This is how the target of that extension looks now:
Note: I haven't changed anything in the project target header search paths.
I am not sure what changed in RN 0.57, why it was crashing now in 0.57, how this header search paths should be in extensions, project and target. Why previously having React and ReactCommon there worked and why now it is not working anymore.
My project was created 3 years ago and had many RN updates. It is possible that at some point React and ReactCommon were needed in the project header search paths.
As I wrote in my question, this problem was signaled in RN github too,
more details can be found here:
https://github.com/facebook/react-native/issues/21482#issuecomment-427815231

Could not build Objective-C module 'CoreGraphics'

I'm getting the following error when trying to run any of my unit or UI tests. Doesn't happen when running the application itself. The error message is shown below:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBase.h:12:10: note: while building module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBase.h:12:
#include <CoreFoundation/CFBase.h>
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/CoreFoundation.h"
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:43:10: note: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:43:
#include <CoreFoundation/CFBase.h>
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:72:10: note: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:72:
#include <Block.h>
^
/Users/eirik/Documents/Utvikling/iOS/ProsjekterSamarbeid/AnchorPoint Fishing as/FerskFiskiOS/Pods/leveldb-library/table/Block.h:10:10: note: in file included from /Users/eirik/Documents/Utvikling/iOS/ProsjekterSamarbeid/AnchorPoint Fishing as/FerskFiskiOS/Pods/leveldb-library/table/Block.h:10:
#include "leveldb/iterator.h"
^
/Users/eirik/Documents/Utvikling/iOS/ProsjekterSamarbeid/AnchorPoint Fishing as/FerskFiskiOS/Pods/leveldb-library/include/leveldb/iterator.h:18:10: note: in file included from /Users/eirik/Documents/Utvikling/iOS/ProsjekterSamarbeid/AnchorPoint Fishing as/FerskFiskiOS/Pods/leveldb-library/include/leveldb/iterator.h:18:
#include "leveldb/slice.h"
/Users/eirik/Documents/Utvikling/iOS/ProsjekterSamarbeid/AnchorPoint Fishing as/FerskFiskiOS/Pods/leveldb-library/include/leveldb/slice.h:21:10: error: 'string' file not found
#include <string>
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/CoreGraphics.h"
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h:8:10: note: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h:8:
#include <CoreGraphics/CGBase.h>
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBase.h:12:10: error: could not build module 'CoreFoundation'
#include <CoreFoundation/CFBase.h>
^
<unknown>:0: error: could not build Objective-C module 'CoreGraphics'
I'm using Xcode 9 in Swift 3.2 mode and CocoaPods. I'm using Firebase and FirebaseUI, which has leveldb as a dependency. You can see that the error is first triggered in leveldb/slice.h, which cannot find the string file.
I have tried the following up to this point:
Clean (Shift + CMD + K)
Remove DerivedData
Clean Build Folder...
Allow Non-Modular Includes In Framework Modules in Build Settings.
pod deintegrate, pod clean pod install.
For what it's worth, here's the error in the Issue Navigator:
Any suggestions?
This looks similar to a CocoaPods issue that was fixed in CocoaPods 1.4.0. Search paths were not properly set for unit test targets.
Try updating to the CocoaPods 1.4.0 beta and rerun pod update
Or use a comparable workaround to the one described here for the leveldb path:
Add "${PODS_ROOT}/leveldb-library/include" to your Tests target only under Build Settings -> Header Search Paths

'pod lib lint' conflict between 'route.h' and <net/route.h>

I'm trying to run pod lib lint on a Cocoa Framework swift project and it returns the following error:
- ERROR | [iOS] xcodebuild: /MyProject/route.h:164:8: error: redefinition of 'rt_msghdr2'
- NOTE | [iOS] xcodebuild: /Applications/Xcode.app/Contents/Developer/Platforms
/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk
/usr/include/net/route.h:164:8:
note: previous definition is here
I have an Objective-C class (NetworkUtil.h - NetworkUtil.m) with the following import structure.
#if TARGET_IPHONE_SIMULATOR
#include <net/route.h>
#else
#include "route.h"
#endif
This, because route.h file only exist in the iOS Simulator SDK, but not in the actual iOS SDK (https://stackoverflow.com/a/23411469/5973853). I check whether it is an iPhone simulator, so the original < net/route.h > will be imported, or it runs on an actual iPhone, in that case it gets my manually copied 'route.h'.
Xcode manages to build and run the whole project correctly, but xcodebuild used by pod lib lint doesn't. For some reason, it imports both < net/route.h > and 'route.h' without considering the #if_TARGET_IPHONE_SIMULATOR validation and that makes the conflict due to "redefinition of several functions".
Is there any solution or workaround to this conflict?

Resources