Skip to content

Commit

Permalink
Use framework iOS platforms
Browse files Browse the repository at this point in the history
MOPPIOS-1237

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Dec 7, 2023
1 parent 8a28362 commit b5a5c11
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 94 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ list(APPEND CPACK_RPM_RELOCATION_PATHS ${CMAKE_INSTALL_SYSCONFDIR})
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
include(CPack)
if( APPLE )
set( FRAMEWORK YES CACHE BOOL "Build library as Mac OS X Framework" )
if(APPLE)
set(FRAMEWORK YES CACHE BOOL "Build library as Mac OS X Framework")
set(FRAMEWORK_DESTINATION /Library/Frameworks CACHE PATH "Mac OS X Framework install destination")
endif()

find_package(Doxygen)
Expand Down
5 changes: 2 additions & 3 deletions build-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,11 @@ case "$@" in
export IPHONEOS_DEPLOYMENT_TARGET
CMAKEARGS="
-DCMAKE_OSX_SYSROOT=${SYSROOT} \
-DFRAMEWORK=off \
-DSWIG_EXECUTABLE=NOTFOUND \
-DBoost_INCLUDE_DIR=NOTFOUND \
-DDOXYGEN_EXECUTABLE=NOTFOUND \
-DBUILD_TOOLS=NO \
-DBUILD_SHARED_LIBS=NO"
-DFRAMEWORK_DESTINATION=${TARGET_PATH}/lib
-DBUILD_TOOLS=NO"
;;
*)
echo "Building for macOS"
Expand Down
2 changes: 1 addition & 1 deletion cmake
3 changes: 1 addition & 2 deletions examples/ios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
Open Xcode project and run on simulator


AppDelegate.mm contains how to override digidoc::XmlConf to point right cache folder for TSL lists and XSD schema folders.
Project also includes schema folder (/Library/libdigidocpp.iphoneos/etc/digidocpp/schema).
AppDelegate.mm contains how to override digidoc::XmlConf to point right cache folder for TSL lists.
96 changes: 42 additions & 54 deletions examples/ios/libdigidocpp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,37 @@

/* Begin PBXBuildFile section */
4E25CC401B5D1D85005E0B79 /* test.bdoc in Resources */ = {isa = PBXBuildFile; fileRef = 4E25CC3F1B5D1D85005E0B79 /* test.bdoc */; };
4E25CC421B5D1EDA005E0B79 /* schema in Resources */ = {isa = PBXBuildFile; fileRef = 4E25CC411B5D1EDA005E0B79 /* schema */; };
4E26A2292AB4E38600E2B732 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4E26A2282AB4E38600E2B732 /* LaunchScreen.storyboard */; };
4E34C8402AE9292A00DD78B0 /* digidocpp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E34C83F2AE9292A00DD78B0 /* digidocpp.framework */; };
4E34C8412AE9292A00DD78B0 /* digidocpp.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4E34C83F2AE9292A00DD78B0 /* digidocpp.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
4E76639E1B5A37AC00672ACF /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4E76639D1B5A37AC00672ACF /* main.mm */; };
4E7663A11B5A37AC00672ACF /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4E7663A01B5A37AC00672ACF /* AppDelegate.mm */; };
4E7663A41B5A37AC00672ACF /* MasterViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4E7663A31B5A37AC00672ACF /* MasterViewController.mm */; };
4E7663AA1B5A37AC00672ACF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4E7663A81B5A37AC00672ACF /* Main.storyboard */; };
4E7663AC1B5A37AC00672ACF /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4E7663AB1B5A37AC00672ACF /* Images.xcassets */; };
4E85E5F7285364BF00A65763 /* libdigidocpp_util.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E85E5F6285364BF00A65763 /* libdigidocpp_util.a */; };
4ECD5FAA2010A15A00BCC616 /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4ECD5FA92010A15A00BCC616 /* libcrypto.a */; };
4ECD5FB02010A1B700BCC616 /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4ECD5FAB2010A1B700BCC616 /* libssl.a */; };
4ECD5FB12010A1B700BCC616 /* libxalan-c.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4ECD5FAC2010A1B700BCC616 /* libxalan-c.a */; };
4ECD5FB22010A1B700BCC616 /* libxerces-c.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4ECD5FAD2010A1B700BCC616 /* libxerces-c.a */; };
4ECD5FB32010A1B700BCC616 /* libxalanMsg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4ECD5FAE2010A1B700BCC616 /* libxalanMsg.a */; };
4ECD5FB42010A1B700BCC616 /* libxml-security-c.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4ECD5FAF2010A1B700BCC616 /* libxml-security-c.a */; };
4ECD5FB72010A33800BCC616 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 4ECD5FB62010A33800BCC616 /* libz.tbd */; };
4ECD5FBB2010A38900BCC616 /* libminizip.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4ECD5FB82010A38900BCC616 /* libminizip.a */; };
4ECD5FBC2010A38900BCC616 /* libdigidocpp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4ECD5FB92010A38900BCC616 /* libdigidocpp.a */; };
4ECD5FBD2010A38900BCC616 /* libdigidocpp_priv.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4ECD5FBA2010A38900BCC616 /* libdigidocpp_priv.a */; };
4EF2169520496F780013677E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4EF2169420496F780013677E /* UIKit.framework */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
4E34C8422AE9292A00DD78B0 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
4E34C8412AE9292A00DD78B0 /* digidocpp.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
4E25CC3F1B5D1D85005E0B79 /* test.bdoc */ = {isa = PBXFileReference; lastKnownFileType = file; path = test.bdoc; sourceTree = "<group>"; };
4E25CC411B5D1EDA005E0B79 /* schema */ = {isa = PBXFileReference; lastKnownFileType = folder; name = schema; path = "$(SDKPATH)/etc/digidocpp/schema"; sourceTree = "<absolute>"; };
4E26A2282AB4E38600E2B732 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
4E34C83F2AE9292A00DD78B0 /* digidocpp.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = digidocpp.framework; path = "$(SDKPATH)/lib/digidocpp.framework"; sourceTree = "<absolute>"; };
4E7663981B5A37AC00672ACF /* libdigidocpp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = libdigidocpp.app; sourceTree = BUILT_PRODUCTS_DIR; };
4E76639C1B5A37AC00672ACF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4E76639D1B5A37AC00672ACF /* main.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; };
Expand All @@ -41,18 +47,9 @@
4E7663A31B5A37AC00672ACF /* MasterViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MasterViewController.mm; sourceTree = "<group>"; };
4E7663A91B5A37AC00672ACF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
4E7663AB1B5A37AC00672ACF /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
4E85E5F6285364BF00A65763 /* libdigidocpp_util.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libdigidocpp_util.a; path = "$(SDKPATH)/lib/libdigidocpp_util.a"; sourceTree = "<absolute>"; };
4EAC9AA729125D5200A39880 /* libdigidocpp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = libdigidocpp.entitlements; sourceTree = "<group>"; };
4ECD5FA92010A15A00BCC616 /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcrypto.a; path = "$(SDKPATH)/lib/libcrypto.a"; sourceTree = "<absolute>"; };
4ECD5FAB2010A1B700BCC616 /* libssl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libssl.a; path = "$(SDKPATH)/lib/libssl.a"; sourceTree = "<absolute>"; };
4ECD5FAC2010A1B700BCC616 /* libxalan-c.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libxalan-c.a"; path = "$(SDKPATH)/lib/libxalan-c.a"; sourceTree = "<absolute>"; };
4ECD5FAD2010A1B700BCC616 /* libxerces-c.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libxerces-c.a"; path = "$(SDKPATH)/lib/libxerces-c.a"; sourceTree = "<absolute>"; };
4ECD5FAE2010A1B700BCC616 /* libxalanMsg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libxalanMsg.a; path = "$(SDKPATH)/lib/libxalanMsg.a"; sourceTree = "<absolute>"; };
4ECD5FAF2010A1B700BCC616 /* libxml-security-c.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libxml-security-c.a"; path = "$(SDKPATH)/lib/libxml-security-c.a"; sourceTree = "<absolute>"; };
4ECD5FB62010A33800BCC616 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
4ECD5FB82010A38900BCC616 /* libminizip.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libminizip.a; path = "$(SDKPATH)/lib/libminizip.a"; sourceTree = "<absolute>"; };
4ECD5FB92010A38900BCC616 /* libdigidocpp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libdigidocpp.a; path = "$(SDKPATH)/lib/libdigidocpp.a"; sourceTree = "<absolute>"; };
4ECD5FBA2010A38900BCC616 /* libdigidocpp_priv.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libdigidocpp_priv.a; path = "$(SDKPATH)/lib/libdigidocpp_priv.a"; sourceTree = "<absolute>"; };
4ED367C424EA910E0020905B /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
4EF2169420496F780013677E /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
Expand All @@ -63,17 +60,9 @@
buildActionMask = 2147483647;
files = (
4EF2169520496F780013677E /* UIKit.framework in Frameworks */,
4ECD5FBC2010A38900BCC616 /* libdigidocpp.a in Frameworks */,
4ECD5FBD2010A38900BCC616 /* libdigidocpp_priv.a in Frameworks */,
4ECD5FBB2010A38900BCC616 /* libminizip.a in Frameworks */,
4ECD5FB42010A1B700BCC616 /* libxml-security-c.a in Frameworks */,
4ECD5FB02010A1B700BCC616 /* libssl.a in Frameworks */,
4ECD5FAA2010A15A00BCC616 /* libcrypto.a in Frameworks */,
4ECD5FB12010A1B700BCC616 /* libxalan-c.a in Frameworks */,
4ECD5FB32010A1B700BCC616 /* libxalanMsg.a in Frameworks */,
4E85E5F7285364BF00A65763 /* libdigidocpp_util.a in Frameworks */,
4ECD5FB22010A1B700BCC616 /* libxerces-c.a in Frameworks */,
4ECD5FB72010A33800BCC616 /* libz.tbd in Frameworks */,
4E34C8402AE9292A00DD78B0 /* digidocpp.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -111,7 +100,6 @@
4E76639C1B5A37AC00672ACF /* Info.plist */,
4E76639D1B5A37AC00672ACF /* main.mm */,
4E25CC3F1B5D1D85005E0B79 /* test.bdoc */,
4E25CC411B5D1EDA005E0B79 /* schema */,
);
path = libdigidocpp;
sourceTree = "<group>";
Expand All @@ -120,16 +108,8 @@
isa = PBXGroup;
children = (
4EF2169420496F780013677E /* UIKit.framework */,
4ECD5FA92010A15A00BCC616 /* libcrypto.a */,
4ECD5FB92010A38900BCC616 /* libdigidocpp.a */,
4ECD5FBA2010A38900BCC616 /* libdigidocpp_priv.a */,
4E85E5F6285364BF00A65763 /* libdigidocpp_util.a */,
4E34C83F2AE9292A00DD78B0 /* digidocpp.framework */,
4ECD5FB82010A38900BCC616 /* libminizip.a */,
4ECD5FAB2010A1B700BCC616 /* libssl.a */,
4ECD5FAC2010A1B700BCC616 /* libxalan-c.a */,
4ECD5FAE2010A1B700BCC616 /* libxalanMsg.a */,
4ECD5FAD2010A1B700BCC616 /* libxerces-c.a */,
4ECD5FAF2010A1B700BCC616 /* libxml-security-c.a */,
4ECD5FB62010A33800BCC616 /* libz.tbd */,
);
name = Frameworks;
Expand All @@ -145,6 +125,7 @@
4E7663941B5A37AC00672ACF /* Sources */,
4E7663951B5A37AC00672ACF /* Frameworks */,
4E7663961B5A37AC00672ACF /* Resources */,
4E34C8422AE9292A00DD78B0 /* Embed Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -193,7 +174,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4E25CC421B5D1EDA005E0B79 /* schema in Resources */,
4E7663AA1B5A37AC00672ACF /* Main.storyboard in Resources */,
4E7663AC1B5A37AC00672ACF /* Images.xcassets in Resources */,
4E26A2292AB4E38600E2B732 /* LaunchScreen.storyboard in Resources */,
Expand Down Expand Up @@ -343,19 +323,20 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
BUILD_NUMBER = 0;
CODE_SIGN_ENTITLEMENTS = libdigidocpp/libdigidocpp.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(BUILD_NUMBER)";
DEVELOPMENT_TEAM = ET847QJV9F;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
FRAMEWORK_SEARCH_PATHS = "$(SDKPATH)/lib";
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
"TESTING=$(TESTING)",
);
GENERATE_INFOPLIST_FILE = YES;
HEADER_SEARCH_PATHS = (
"$(SDKPATH)/include",
"$(MINIZIP)",
"$(PROJECT_DIR)/../../src/minizip",
);
INFOPLIST_FILE = libdigidocpp/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
Expand All @@ -364,14 +345,17 @@
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = "$(SDKPATH)/lib";
MARKETING_VERSION = 1.0;
MINIZIP = "$(PROJECT_DIR)/../../src/minizip";
PRODUCT_BUNDLE_IDENTIFIER = "ee.ria.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = ee.ria.libdigidocpp.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKPATH = /Library/libdigidocpp.iphoneos;
"SDKPATH[sdk=iphonesimulator*]" = /Library/libdigidocpp.iphonesimulator;
"SDKPATH[sdk=macosx*]" = /Library/libdigidocpp.iphonecatalyst;
SDKPATH = "$(LOCAL_LIBRARY_DIR)/libdigidocpp.iphoneos";
"SDKPATH[sdk=iphonesimulator*]" = "$(LOCAL_LIBRARY_DIR)/libdigidocpp.iphonesimulator";
"SDKPATH[sdk=macosx*]" = "$(LOCAL_LIBRARY_DIR)/libdigidocpp.iphonecatalyst";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
TESTING = 0;
Expand All @@ -384,19 +368,20 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
BUILD_NUMBER = 0;
CODE_SIGN_ENTITLEMENTS = libdigidocpp/libdigidocpp.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(BUILD_NUMBER)";
DEVELOPMENT_TEAM = ET847QJV9F;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
FRAMEWORK_SEARCH_PATHS = "$(SDKPATH)/lib";
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
"TESTING=$(TESTING)",
);
GENERATE_INFOPLIST_FILE = YES;
HEADER_SEARCH_PATHS = (
"$(SDKPATH)/include",
"$(MINIZIP)",
"$(PROJECT_DIR)/../../src/minizip",
);
INFOPLIST_FILE = libdigidocpp/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
Expand All @@ -405,14 +390,17 @@
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = "$(SDKPATH)/lib";
MARKETING_VERSION = 1.0;
MINIZIP = "$(PROJECT_DIR)/../../src/minizip";
PRODUCT_BUNDLE_IDENTIFIER = "ee.ria.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = ee.ria.libdigidocpp.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKPATH = /Library/libdigidocpp.iphoneos;
"SDKPATH[sdk=iphonesimulator*]" = /Library/libdigidocpp.iphonesimulator;
"SDKPATH[sdk=macosx*]" = /Library/libdigidocpp.iphonecatalyst;
SDKPATH = "$(LOCAL_LIBRARY_DIR)/libdigidocpp.iphoneos";
"SDKPATH[sdk=iphonesimulator*]" = "$(LOCAL_LIBRARY_DIR)/libdigidocpp.iphonesimulator";
"SDKPATH[sdk=macosx*]" = "$(LOCAL_LIBRARY_DIR)/libdigidocpp.iphonecatalyst";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
TESTING = 0;
Expand Down
13 changes: 4 additions & 9 deletions examples/ios/libdigidocpp/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,26 @@
#include <digidocpp/Exception.h>
#include <digidocpp/crypto/X509Cert.h>

class DigiDocConf: public digidoc::ConfCurrent
class DigiDocConf final: public digidoc::ConfCurrent
{
public:
int logLevel() const override
int logLevel() const final
{
return 4;
}

std::string logFile() const override
std::string logFile() const final
{
return [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/libdigidocpp.log"].UTF8String;
}

std::string TSLCache() const override
std::string TSLCache() const final
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *libraryDirectory = paths[0];
[NSFileManager.defaultManager createFileAtPath:[libraryDirectory stringByAppendingPathComponent:@"EE_T.xml"] contents:nil attributes:nil];
return libraryDirectory.UTF8String;
}

std::string xsdPath() const override
{
return [NSBundle.mainBundle pathForResource:@"schema" ofType:NSString.string].UTF8String;
}
};

@implementation AppDelegate
Expand Down
12 changes: 7 additions & 5 deletions examples/ios/libdigidocpp/MasterViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <digidocpp/Exception.h>
#include "unzip.h"

#include <array>

@interface NSString (Digidoc)
+ (NSString*)stdstring:(const std::string&)str;
@end
Expand Down Expand Up @@ -83,7 +85,7 @@ - (IBAction)runTest:(id)sender {
if(unzResult != UNZ_OK)
break;
std::string fileNameTmp(fileInfo.size_filename, 0);
unzResult = unzGetCurrentFileInfo(open, &fileInfo, fileNameTmp.c_str(), uLong(fileNameTmp.size()), nullptr, 0, nullptr, 0);
unzResult = unzGetCurrentFileInfo(open, &fileInfo, fileNameTmp.data(), uLong(fileNameTmp.size()), nullptr, 0, nullptr, 0);
if(unzResult != UNZ_OK)
break;

Expand All @@ -100,18 +102,18 @@ - (IBAction)runTest:(id)sender {
break;

int size = 0;
char buf[10240];
std::array<char,10240> buf{};
NSMutableData *data = [[NSMutableData alloc] init];
while((size = unzReadCurrentFile(open, buf, 10240)) > 0)
[data appendBytes:buf length:size];
while((size = unzReadCurrentFile(open, buf.data(), buf.size())) > 0)
[data appendBytes:buf.data() length:size];
unzResult = unzCloseCurrentFile(open);

[data writeToFile:file atomically:YES];
NSString *status = @"OK";
NSString *diagnostics = @"";
NSMutableArray *dataFiles = [[NSMutableArray alloc] init];
try {
std::unique_ptr<digidoc::Container> d(digidoc::Container::open(file.UTF8String));
auto d = digidoc::Container::openPtr(file.UTF8String);
for (const digidoc::DataFile *f: d->dataFiles()) {
[dataFiles addObject:@{
@"f": [NSString stdstring:f->fileName()],
Expand Down
2 changes: 2 additions & 0 deletions examples/ios/libdigidocpp/libdigidocpp.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
Expand Down
Loading

0 comments on commit b5a5c11

Please sign in to comment.