diff --git a/.gitignore b/.gitignore index b90654c..028fedc 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,5 @@ xcuserdata/ # End of https://www.toptal.com/developers/gitignore/api/xcode build/ -build.xcresult/ \ No newline at end of file +build.xcresult/ +/archive.xcarchive diff --git a/MacDependency/ArchitectureModel.h b/MacDependency/ArchitectureModel.h index 3a6c995..7e61ffe 100644 --- a/MacDependency/ArchitectureModel.h +++ b/MacDependency/ArchitectureModel.h @@ -8,7 +8,7 @@ #import #import "MachOModel.h" -#include "macho/machoarchitecture.h" +#include "MachO/machoarchitecture.h" #include "MachO/machoheader.h" @class MyDocument; diff --git a/MacDependency/MacDependency.xcodeproj/project.pbxproj b/MacDependency/MacDependency.xcodeproj/project.pbxproj index fb48979..53f187d 100644 --- a/MacDependency/MacDependency.xcodeproj/project.pbxproj +++ b/MacDependency/MacDependency.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 53; objects = { /* Begin PBXBuildFile section */ @@ -263,7 +263,8 @@ 2A37F4A9FDCFA73011CA2CEA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1310; + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = "Konrad Windszus"; }; buildConfigurationList = C05733CB08A9546B00998B17 /* Build configuration list for PBXProject "MacDependency" */; @@ -399,11 +400,12 @@ CLANG_ENABLE_OBJC_ARC = YES; CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; GCC_DYNAMIC_NO_PIC = NO; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; INFOPLIST_FILE = Info.plist; - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.13; PRODUCT_BUNDLE_IDENTIFIER = "com.googlecode.${PRODUCT_NAME:identifier}"; PRODUCT_NAME = MacDependency; SDKROOT = macosx; @@ -416,10 +418,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_OBJC_ARC = YES; CODE_SIGN_IDENTITY = "-"; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_MODEL_TUNING = G5; INFOPLIST_FILE = Info.plist; - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.13; PRODUCT_BUNDLE_IDENTIFIER = "com.googlecode.${PRODUCT_NAME:identifier}"; PRODUCT_NAME = MacDependency; SDKROOT = macosx; @@ -430,6 +433,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; @@ -450,6 +454,7 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + DEAD_CODE_STRIPPING = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = c99; @@ -478,7 +483,7 @@ /opt/local/include, ./../, ); - MACOSX_DEPLOYMENT_TARGET = 10.7; + MACOSX_DEPLOYMENT_TARGET = 10.13; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; }; @@ -509,6 +514,7 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + DEAD_CODE_STRIPPING = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = c99; GCC_NO_COMMON_BLOCKS = YES; @@ -521,7 +527,7 @@ /opt/local/include, ./../, ); - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.13; SDKROOT = macosx; }; name = Release; diff --git a/MacDependency/MacDependency.xcodeproj/xcshareddata/xcschemes/MacDependency.xcscheme b/MacDependency/MacDependency.xcodeproj/xcshareddata/xcschemes/MacDependency.xcscheme index d7d53df..77183b4 100644 --- a/MacDependency/MacDependency.xcodeproj/xcshareddata/xcschemes/MacDependency.xcscheme +++ b/MacDependency/MacDependency.xcodeproj/xcshareddata/xcschemes/MacDependency.xcscheme @@ -1,6 +1,6 @@ + // use reference counting to reuse files for all used architectures InternalFile* InternalFile::create(InternalFile* file) { file->counter++; @@ -24,9 +26,13 @@ filename(filename), counter(1) // open file handle file.open(this->filename, std::ios_base::in | std::ios_base::binary); if (file.fail()) { - std::ostringstream error; - error << "Couldn't open file '" << filename << "'."; - throw MachOException(error.str()); + void* dylib = dlopen(this->filename.c_str(), RTLD_LAZY); + if (dylib) { + dlclose(dylib); + throw MachOException("System cached library '" + filename + "'.", true); + } else { + throw MachOException("Couldn't open file '" + filename + "'."); + } } struct stat buffer; diff --git a/MachO/machoexception.cpp b/MachO/machoexception.cpp index 66ba42c..8496298 100644 --- a/MachO/machoexception.cpp +++ b/MachO/machoexception.cpp @@ -1,6 +1,9 @@ #include "machoexception.h" -MachOException::MachOException(const std::string& cause) : cause(cause) +MachOException::MachOException(const std::string& cause) : cause(cause), warning(false) { } +MachOException::MachOException(const std::string& cause, bool warning) : cause(cause), warning(warning) +{ +} diff --git a/MachO/machoexception.h b/MachO/machoexception.h index a6b3c08..e6580bb 100644 --- a/MachO/machoexception.h +++ b/MachO/machoexception.h @@ -7,9 +7,12 @@ class EXPORT MachOException { public: MachOException(const std::string&); + MachOException(const std::string&, bool warning); const std::string& getCause() { return cause; } + const bool isWarning() { return warning; } private: const std::string cause; + bool warning; }; #endif // MACHOEXCEPTION_H