diff --git a/.gitignore b/.gitignore index f131b0232..4bcc1c671 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ api-docs-repo/ # Generated by tests on Android /avd /core + +# Artifacts from iOS tests +tests/integration/ios/**/*.dylib \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index c6c37c661..03889ac4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2728,6 +2728,10 @@ dependencies = [ "tempfile", ] +[[package]] +name = "wasmer-integration-tests-ios" +version = "2.0.0" + [[package]] name = "wasmer-middlewares" version = "2.0.0" diff --git a/Cargo.toml b/Cargo.toml index ebc1a3f22..c95ec2cdd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,6 +52,7 @@ members = [ "tests/lib/wast", "tests/lib/compiler-test-derive", "tests/integration/cli", + "tests/integration/ios", "fuzz", ] diff --git a/examples/platform_ios_headless.rs b/examples/platform_ios_headless.rs index a793b700f..3f7603a1a 100644 --- a/examples/platform_ios_headless.rs +++ b/examples/platform_ios_headless.rs @@ -44,11 +44,12 @@ i32.add) // Create a compiler for iOS let compiler_config = Cranelift::default(); - let triple = Triple::from_str("aarch64-apple-ios") + let triple = Triple::from_str("x86_64-apple-ios") .map_err(|error| RuntimeError::new(error.to_string()))?; // Let's build the target. let mut cpu_feature = CpuFeature::set(); + cpu_feature.insert(CpuFeature::from_str("sse2")?); let target = Target::new(triple, cpu_feature); println!("Chosen target: {:?}", target); @@ -67,6 +68,27 @@ i32.add) let mut dylib_file = Path::new("./sum.dylib"); module.serialize_to_file(dylib_file)?; + let module = unsafe { Module::deserialize_from_file(&store, dylib_file) }?; + + // Congrats, the Wasm module has been deserialized! Now let's + // execute it for the sake of having a complete example. + + // Create an import object. Since our Wasm module didn't declare + // any imports, it's an empty object. + let import_object = imports! {}; + + println!("Instantiating module..."); + // Let's instantiate the Wasm module. + let instance = Instance::new(&module, &import_object)?; + + println!("Calling `sum` function..."); + // The Wasm module exports a function called `sum`. + let sum = instance.exports.get_function("sum")?; + let results = sum.call(&[Value::I32(1), Value::I32(2)])?; + + println!("Results: {:?}", results); + assert_eq!(results.to_vec(), vec![Value::I32(3)]); + Ok(()) } diff --git a/lib/c-api/wasmer.h b/lib/c-api/wasmer.h index d700a4fcf..1cf92abc2 100644 --- a/lib/c-api/wasmer.h +++ b/lib/c-api/wasmer.h @@ -62,18 +62,9 @@ # define DEPRECATED(message) __declspec(deprecated(message)) #endif -// The `universal` feature has been enabled for this build. -#define WASMER_UNIVERSAL_ENABLED - -// The `compiler` feature has been enabled for this build. -#define WASMER_COMPILER_ENABLED - // The `wasi` feature has been enabled for this build. #define WASMER_WASI_ENABLED -// The `middlewares` feature has been enabled for this build. -#define WASMER_MIDDLEWARES_ENABLED - // This file corresponds to the following Wasmer version. #define WASMER_VERSION "2.0.0" #define WASMER_VERSION_MAJOR 2 @@ -803,7 +794,9 @@ bool wasmer_features_tail_call(struct wasmer_features_t *features, bool enable); bool wasmer_features_threads(struct wasmer_features_t *features, bool enable); +#if defined(WASMER_COMPILER_ENABLED) bool wasmer_is_compiler_available(enum wasmer_compiler_t compiler); +#endif bool wasmer_is_engine_available(enum wasmer_engine_t engine); diff --git a/tests/integration/ios/Cargo.toml b/tests/integration/ios/Cargo.toml new file mode 100644 index 000000000..f357c8800 --- /dev/null +++ b/tests/integration/ios/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "wasmer-integration-tests-ios" +version = "2.0.0" +authors = ["Wasmer Engineering Team "] +description = "iOS integration tests" +repository = "https://github.com/wasmerio/wasmer" +edition = "2018" +publish = false \ No newline at end of file diff --git a/tests/integration/ios/DylibExample/DylibExample.xcodeproj/project.pbxproj b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/project.pbxproj new file mode 100644 index 000000000..256f6dc98 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/project.pbxproj @@ -0,0 +1,720 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 6315FBEE26CC45F10059CE47 /* calc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6315FBEC26CC45F10059CE47 /* calc.cpp */; }; + 63CD62C426C9492100424C7A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63CD62C326C9492100424C7A /* AppDelegate.swift */; }; + 63CD62C626C9492100424C7A /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63CD62C526C9492100424C7A /* SceneDelegate.swift */; }; + 63CD62C826C9492100424C7A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63CD62C726C9492100424C7A /* ViewController.swift */; }; + 63CD62CB26C9492100424C7A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 63CD62C926C9492100424C7A /* Main.storyboard */; }; + 63CD62CD26C9492400424C7A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 63CD62CC26C9492400424C7A /* Assets.xcassets */; }; + 63CD62D026C9492400424C7A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 63CD62CE26C9492400424C7A /* LaunchScreen.storyboard */; }; + 63CD62DB26C9492400424C7A /* DylibExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63CD62DA26C9492400424C7A /* DylibExampleTests.swift */; }; + 63CD62E626C9492400424C7A /* DylibExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63CD62E526C9492400424C7A /* DylibExampleUITests.swift */; }; + 63CD62FB26C94F4700424C7A /* libwasmer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 63CD62F826C94EB600424C7A /* libwasmer.a */; }; + 63CD62FF26C952CC00424C7A /* sum.wasm in Resources */ = {isa = PBXBuildFile; fileRef = 63CD62FE26C952CC00424C7A /* sum.wasm */; }; + 63CD630126C9541E00424C7A /* sum.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 63CD630026C9541E00424C7A /* sum.dylib */; }; + 63CD630226C9541E00424C7A /* sum.dylib in Embed .dylib in App bundle */ = {isa = PBXBuildFile; fileRef = 63CD630026C9541E00424C7A /* sum.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 63CD62D726C9492400424C7A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 63CD62B826C9492100424C7A /* Project object */; + proxyType = 1; + remoteGlobalIDString = 63CD62BF26C9492100424C7A; + remoteInfo = DylibExample; + }; + 63CD62E226C9492400424C7A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 63CD62B826C9492100424C7A /* Project object */; + proxyType = 1; + remoteGlobalIDString = 63CD62BF26C9492100424C7A; + remoteInfo = DylibExample; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 63CD630326C9541E00424C7A /* Embed .dylib in App bundle */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 12; + dstPath = ""; + dstSubfolderSpec = 6; + files = ( + 63CD630226C9541E00424C7A /* sum.dylib in Embed .dylib in App bundle */, + ); + name = "Embed .dylib in App bundle"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 6311890B26CBAD2C007746B2 /* sum.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = sum.dylib; path = DylibExample/sum.dylib; sourceTree = ""; }; + 6315FBEC26CC45F10059CE47 /* calc.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = calc.cpp; sourceTree = ""; }; + 6315FBED26CC45F10059CE47 /* calc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = calc.h; sourceTree = ""; }; + 63CD62C026C9492100424C7A /* DylibExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DylibExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 63CD62C326C9492100424C7A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 63CD62C526C9492100424C7A /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 63CD62C726C9492100424C7A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 63CD62CA26C9492100424C7A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 63CD62CC26C9492400424C7A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 63CD62CF26C9492400424C7A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 63CD62D126C9492400424C7A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 63CD62D626C9492400424C7A /* DylibExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DylibExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 63CD62DA26C9492400424C7A /* DylibExampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DylibExampleTests.swift; sourceTree = ""; }; + 63CD62DC26C9492400424C7A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 63CD62E126C9492400424C7A /* DylibExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DylibExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 63CD62E526C9492400424C7A /* DylibExampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DylibExampleUITests.swift; sourceTree = ""; }; + 63CD62E726C9492400424C7A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 63CD62F426C94D6000424C7A /* DylibExample-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DylibExample-Bridging-Header.h"; sourceTree = ""; }; + 63CD62F826C94EB600424C7A /* libwasmer.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libwasmer.a; path = ../../../../target/universal/release/libwasmer.a; sourceTree = ""; }; + 63CD62FE26C952CC00424C7A /* sum.wasm */ = {isa = PBXFileReference; lastKnownFileType = text; path = sum.wasm; sourceTree = ""; }; + 63CD630026C9541E00424C7A /* sum.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = sum.dylib; path = DylibExample/sum.dylib; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 63CD62BD26C9492100424C7A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 63CD630126C9541E00424C7A /* sum.dylib in Frameworks */, + 63CD62FB26C94F4700424C7A /* libwasmer.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 63CD62D326C9492400424C7A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 63CD62DE26C9492400424C7A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 63CD62B726C9492100424C7A = { + isa = PBXGroup; + children = ( + 6311890B26CBAD2C007746B2 /* sum.dylib */, + 63CD62F826C94EB600424C7A /* libwasmer.a */, + 63CD62C226C9492100424C7A /* DylibExample */, + 63CD62D926C9492400424C7A /* DylibExampleTests */, + 63CD62E426C9492400424C7A /* DylibExampleUITests */, + 63CD62C126C9492100424C7A /* Products */, + 63CD62FA26C94F4700424C7A /* Frameworks */, + ); + sourceTree = ""; + }; + 63CD62C126C9492100424C7A /* Products */ = { + isa = PBXGroup; + children = ( + 63CD62C026C9492100424C7A /* DylibExample.app */, + 63CD62D626C9492400424C7A /* DylibExampleTests.xctest */, + 63CD62E126C9492400424C7A /* DylibExampleUITests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 63CD62C226C9492100424C7A /* DylibExample */ = { + isa = PBXGroup; + children = ( + 63CD62C326C9492100424C7A /* AppDelegate.swift */, + 63CD62C526C9492100424C7A /* SceneDelegate.swift */, + 63CD62C726C9492100424C7A /* ViewController.swift */, + 63CD62C926C9492100424C7A /* Main.storyboard */, + 63CD62CC26C9492400424C7A /* Assets.xcassets */, + 63CD62CE26C9492400424C7A /* LaunchScreen.storyboard */, + 63CD62D126C9492400424C7A /* Info.plist */, + 63CD62F426C94D6000424C7A /* DylibExample-Bridging-Header.h */, + 63CD62FE26C952CC00424C7A /* sum.wasm */, + 6315FBEC26CC45F10059CE47 /* calc.cpp */, + 6315FBED26CC45F10059CE47 /* calc.h */, + ); + path = DylibExample; + sourceTree = ""; + }; + 63CD62D926C9492400424C7A /* DylibExampleTests */ = { + isa = PBXGroup; + children = ( + 63CD62DA26C9492400424C7A /* DylibExampleTests.swift */, + 63CD62DC26C9492400424C7A /* Info.plist */, + ); + path = DylibExampleTests; + sourceTree = ""; + }; + 63CD62E426C9492400424C7A /* DylibExampleUITests */ = { + isa = PBXGroup; + children = ( + 63CD62E526C9492400424C7A /* DylibExampleUITests.swift */, + 63CD62E726C9492400424C7A /* Info.plist */, + ); + path = DylibExampleUITests; + sourceTree = ""; + }; + 63CD62FA26C94F4700424C7A /* Frameworks */ = { + isa = PBXGroup; + children = ( + 63CD630026C9541E00424C7A /* sum.dylib */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 63CD62BF26C9492100424C7A /* DylibExample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 63CD62EA26C9492400424C7A /* Build configuration list for PBXNativeTarget "DylibExample" */; + buildPhases = ( + 63CD62F326C94B1D00424C7A /* Build Headless Wasmer */, + 63CD62FD26C951EF00424C7A /* Compile .wasm to .dylib */, + 63CD62BC26C9492100424C7A /* Sources */, + 63CD62BD26C9492100424C7A /* Frameworks */, + 63CD62BE26C9492100424C7A /* Resources */, + 63CD630326C9541E00424C7A /* Embed .dylib in App bundle */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = DylibExample; + productName = DylibExample; + productReference = 63CD62C026C9492100424C7A /* DylibExample.app */; + productType = "com.apple.product-type.application"; + }; + 63CD62D526C9492400424C7A /* DylibExampleTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 63CD62ED26C9492400424C7A /* Build configuration list for PBXNativeTarget "DylibExampleTests" */; + buildPhases = ( + 63CD62D226C9492400424C7A /* Sources */, + 63CD62D326C9492400424C7A /* Frameworks */, + 63CD62D426C9492400424C7A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 63CD62D826C9492400424C7A /* PBXTargetDependency */, + ); + name = DylibExampleTests; + productName = DylibExampleTests; + productReference = 63CD62D626C9492400424C7A /* DylibExampleTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 63CD62E026C9492400424C7A /* DylibExampleUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 63CD62F026C9492400424C7A /* Build configuration list for PBXNativeTarget "DylibExampleUITests" */; + buildPhases = ( + 63CD62DD26C9492400424C7A /* Sources */, + 63CD62DE26C9492400424C7A /* Frameworks */, + 63CD62DF26C9492400424C7A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 63CD62E326C9492400424C7A /* PBXTargetDependency */, + ); + name = DylibExampleUITests; + productName = DylibExampleUITests; + productReference = 63CD62E126C9492400424C7A /* DylibExampleUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 63CD62B826C9492100424C7A /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1250; + LastUpgradeCheck = 1250; + TargetAttributes = { + 63CD62BF26C9492100424C7A = { + CreatedOnToolsVersion = 12.5; + LastSwiftMigration = 1250; + }; + 63CD62D526C9492400424C7A = { + CreatedOnToolsVersion = 12.5; + TestTargetID = 63CD62BF26C9492100424C7A; + }; + 63CD62E026C9492400424C7A = { + CreatedOnToolsVersion = 12.5; + TestTargetID = 63CD62BF26C9492100424C7A; + }; + }; + }; + buildConfigurationList = 63CD62BB26C9492100424C7A /* Build configuration list for PBXProject "DylibExample" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 63CD62B726C9492100424C7A; + productRefGroup = 63CD62C126C9492100424C7A /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 63CD62BF26C9492100424C7A /* DylibExample */, + 63CD62D526C9492400424C7A /* DylibExampleTests */, + 63CD62E026C9492400424C7A /* DylibExampleUITests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 63CD62BE26C9492100424C7A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 63CD62D026C9492400424C7A /* LaunchScreen.storyboard in Resources */, + 63CD62CD26C9492400424C7A /* Assets.xcassets in Resources */, + 63CD62CB26C9492100424C7A /* Main.storyboard in Resources */, + 63CD62FF26C952CC00424C7A /* sum.wasm in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 63CD62D426C9492400424C7A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 63CD62DF26C9492400424C7A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 63CD62F326C94B1D00424C7A /* Build Headless Wasmer */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Build Headless Wasmer"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "#!/bin/bash\nexport PATH=$(bash -l -c 'echo $PATH')\ncd ../../../../\nmake build-wasmer\nmake build-capi-headless-ios\n"; + }; + 63CD62FD26C951EF00424C7A /* Compile .wasm to .dylib */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Compile .wasm to .dylib"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/sum.dylib", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "./../../../../target/release/wasmer compile DylibExample/sum.wasm --target x86_64-apple-ios --dylib -o DylibExample/sum.dylib\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 63CD62BC26C9492100424C7A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 63CD62C826C9492100424C7A /* ViewController.swift in Sources */, + 6315FBEE26CC45F10059CE47 /* calc.cpp in Sources */, + 63CD62C426C9492100424C7A /* AppDelegate.swift in Sources */, + 63CD62C626C9492100424C7A /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 63CD62D226C9492400424C7A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 63CD62DB26C9492400424C7A /* DylibExampleTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 63CD62DD26C9492400424C7A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 63CD62E626C9492400424C7A /* DylibExampleUITests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 63CD62D826C9492400424C7A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 63CD62BF26C9492100424C7A /* DylibExample */; + targetProxy = 63CD62D726C9492400424C7A /* PBXContainerItemProxy */; + }; + 63CD62E326C9492400424C7A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 63CD62BF26C9492100424C7A /* DylibExample */; + targetProxy = 63CD62E226C9492400424C7A /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 63CD62C926C9492100424C7A /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 63CD62CA26C9492100424C7A /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 63CD62CE26C9492400424C7A /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 63CD62CF26C9492400424C7A /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 63CD62E826C9492400424C7A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 63CD62E926C9492400424C7A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 63CD62EB26C9492400424C7A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + HEADER_SEARCH_PATHS = "../../../../lib/**"; + INFOPLIST_FILE = DylibExample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + "../../../../target/universal/release/**", + "$(PROJECT_DIR)/DylibExample", + ); + PATH = "/Users/nathanhorrigan/.wasmer/bin:/Users/nathanhorrigan/.cargo/bin:/Users/nathanhorrigan/Android/Sdk/tools:/Users/nathanhorrigan/Android/Sdk/tools/bin:/Users/nathanhorrigan/Android/Sdk/platform-tools:/Users/nathanhorrigan/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/nathanhorrigan/.wasmer/globals/wapm_packages/.bin"; + PRODUCT_BUNDLE_IDENTIFIER = io.wasmer.DylibExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OBJC_BRIDGING_HEADER = "DylibExample/DylibExample-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Debug; + }; + 63CD62EC26C9492400424C7A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + HEADER_SEARCH_PATHS = "../../../../lib/**"; + INFOPLIST_FILE = DylibExample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + "../../../../target/universal/release/**", + "$(PROJECT_DIR)/DylibExample", + ); + PATH = "/Users/nathanhorrigan/.wasmer/bin:/Users/nathanhorrigan/.cargo/bin:/Users/nathanhorrigan/Android/Sdk/tools:/Users/nathanhorrigan/Android/Sdk/tools/bin:/Users/nathanhorrigan/Android/Sdk/platform-tools:/Users/nathanhorrigan/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/nathanhorrigan/.wasmer/globals/wapm_packages/.bin"; + PRODUCT_BUNDLE_IDENTIFIER = io.wasmer.DylibExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OBJC_BRIDGING_HEADER = "DylibExample/DylibExample-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Release; + }; + 63CD62EE26C9492400424C7A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + HEADER_SEARCH_PATHS = "../../../../lib/c-api/**"; + INFOPLIST_FILE = DylibExampleTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = "../../../../target/universal/release/**"; + PRODUCT_BUNDLE_IDENTIFIER = io.wasmer.DylibExampleTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DylibExample.app/DylibExample"; + }; + name = Debug; + }; + 63CD62EF26C9492400424C7A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + HEADER_SEARCH_PATHS = "../../../../lib/c-api/**"; + INFOPLIST_FILE = DylibExampleTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = "../../../../target/universal/release/**"; + PRODUCT_BUNDLE_IDENTIFIER = io.wasmer.DylibExampleTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DylibExample.app/DylibExample"; + }; + name = Release; + }; + 63CD62F126C9492400424C7A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = DylibExampleUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = io.wasmer.DylibExampleUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = DylibExample; + }; + name = Debug; + }; + 63CD62F226C9492400424C7A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = DylibExampleUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = io.wasmer.DylibExampleUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = DylibExample; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 63CD62BB26C9492100424C7A /* Build configuration list for PBXProject "DylibExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 63CD62E826C9492400424C7A /* Debug */, + 63CD62E926C9492400424C7A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 63CD62EA26C9492400424C7A /* Build configuration list for PBXNativeTarget "DylibExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 63CD62EB26C9492400424C7A /* Debug */, + 63CD62EC26C9492400424C7A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 63CD62ED26C9492400424C7A /* Build configuration list for PBXNativeTarget "DylibExampleTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 63CD62EE26C9492400424C7A /* Debug */, + 63CD62EF26C9492400424C7A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 63CD62F026C9492400424C7A /* Build configuration list for PBXNativeTarget "DylibExampleUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 63CD62F126C9492400424C7A /* Debug */, + 63CD62F226C9492400424C7A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 63CD62B826C9492100424C7A /* Project object */; +} diff --git a/tests/integration/ios/DylibExample/DylibExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/tests/integration/ios/DylibExample/DylibExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/tests/integration/ios/DylibExample/DylibExample.xcodeproj/project.xcworkspace/xcuserdata/nathanhorrigan.xcuserdatad/UserInterfaceState.xcuserstate b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/project.xcworkspace/xcuserdata/nathanhorrigan.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 000000000..1b158208c Binary files /dev/null and b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/project.xcworkspace/xcuserdata/nathanhorrigan.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/tests/integration/ios/DylibExample/DylibExample.xcodeproj/xcshareddata/xcschemes/DylibExample.xcscheme b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/xcshareddata/xcschemes/DylibExample.xcscheme new file mode 100644 index 000000000..6cddf2ccd --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/xcshareddata/xcschemes/DylibExample.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/integration/ios/DylibExample/DylibExample.xcodeproj/xcuserdata/nathanhorrigan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/xcuserdata/nathanhorrigan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 000000000..c84cd439b --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/xcuserdata/nathanhorrigan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,6 @@ + + + diff --git a/tests/integration/ios/DylibExample/DylibExample.xcodeproj/xcuserdata/nathanhorrigan.xcuserdatad/xcschemes/xcschememanagement.plist b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/xcuserdata/nathanhorrigan.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 000000000..699867e89 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample.xcodeproj/xcuserdata/nathanhorrigan.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,32 @@ + + + + + SchemeUserState + + DylibExample.xcscheme_^#shared#^_ + + orderHint + 0 + + + SuppressBuildableAutocreation + + 63CD62BF26C9492100424C7A + + primary + + + 63CD62D526C9492400424C7A + + primary + + + 63CD62E026C9492400424C7A + + primary + + + + + diff --git a/tests/integration/ios/DylibExample/DylibExample/AppDelegate.swift b/tests/integration/ios/DylibExample/DylibExample/AppDelegate.swift new file mode 100644 index 000000000..a2a52654b --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// DylibExample +// +// Created by Nathan Horrigan on 15/08/2021. +// + +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/tests/integration/ios/DylibExample/DylibExample/Assets.xcassets/AccentColor.colorset/Contents.json b/tests/integration/ios/DylibExample/DylibExample/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000..eb8789700 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/tests/integration/ios/DylibExample/DylibExample/Assets.xcassets/AppIcon.appiconset/Contents.json b/tests/integration/ios/DylibExample/DylibExample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..9221b9bb1 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/tests/integration/ios/DylibExample/DylibExample/Assets.xcassets/Contents.json b/tests/integration/ios/DylibExample/DylibExample/Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/tests/integration/ios/DylibExample/DylibExample/Base.lproj/LaunchScreen.storyboard b/tests/integration/ios/DylibExample/DylibExample/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..865e9329f --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/integration/ios/DylibExample/DylibExample/Base.lproj/Main.storyboard b/tests/integration/ios/DylibExample/DylibExample/Base.lproj/Main.storyboard new file mode 100644 index 000000000..46b74d95b --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/Base.lproj/Main.storyboard @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/integration/ios/DylibExample/DylibExample/DylibExample-Bridging-Header.h b/tests/integration/ios/DylibExample/DylibExample/DylibExample-Bridging-Header.h new file mode 100644 index 000000000..7ce8fb504 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/DylibExample-Bridging-Header.h @@ -0,0 +1,4 @@ +#include "wasm.h" +#include "wasmer.h" +#include "wasmer_wasm.h" +#include "calc.h" diff --git a/tests/integration/ios/DylibExample/DylibExample/Info.plist b/tests/integration/ios/DylibExample/DylibExample/Info.plist new file mode 100644 index 000000000..5b531f7b2 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/Info.plist @@ -0,0 +1,66 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/tests/integration/ios/DylibExample/DylibExample/SceneDelegate.swift b/tests/integration/ios/DylibExample/DylibExample/SceneDelegate.swift new file mode 100644 index 000000000..2ca113a35 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/SceneDelegate.swift @@ -0,0 +1,52 @@ +// +// SceneDelegate.swift +// DylibExample +// +// Created by Nathan Horrigan on 15/08/2021. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git a/tests/integration/ios/DylibExample/DylibExample/ViewController.swift b/tests/integration/ios/DylibExample/DylibExample/ViewController.swift new file mode 100644 index 000000000..b1da0225b --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/ViewController.swift @@ -0,0 +1,18 @@ +// +// ViewController.swift +// DylibExample +// +// Created by Nathan Horrigan on 15/08/2021. +// + +import UIKit + +class ViewController: UIViewController { + @IBOutlet weak var label: UILabel! + + override func viewDidLoad() { + super.viewDidLoad() + let sum = calculate_sum(1, 3) + label.text = "The sum of 1 + 3 = \(sum)" + } +} diff --git a/tests/integration/ios/DylibExample/DylibExample/calc.cpp b/tests/integration/ios/DylibExample/DylibExample/calc.cpp new file mode 100644 index 000000000..790b71db7 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/calc.cpp @@ -0,0 +1,130 @@ +// +// WASM.cpp +// DylibExample +// +// Created by Nathan Horrigan on 17/08/2021. +// + +#include "calc.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +std::string get_resources_dir() +{ + + CFURLRef resourceURL = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); + char resourcePath[PATH_MAX]; + if (CFURLGetFileSystemRepresentation(resourceURL, true, + (UInt8 *)resourcePath, + PATH_MAX)) + { + if (resourceURL != NULL) + { + CFRelease(resourceURL); + } + + return resourcePath; + } + + return ""; +} + + +inline std::vector read_vector_from_disk(std::string file_path) { + std::ifstream instream(file_path, std::ios::in | std::ios::binary); + std::vector data((std::istreambuf_iterator(instream)), std::istreambuf_iterator()); + return data; +} + +int calculate_sum(int a, int b) { + printf("Creating the store...\n"); + wasm_engine_t* engine = wasm_engine_new(); + wasm_store_t* store = wasm_store_new(engine); + + + printf("Loading .dylib file...\n"); + std::string wasm_path = get_resources_dir() + "/sum.dylib"; + std::vector dylib = read_vector_from_disk(wasm_path.c_str()); + uint8_t* wasm_bytes = dylib.data(); + + wasm_byte_vec_t imported_bytes; + imported_bytes.size = dylib.size(); + imported_bytes.data = (wasm_byte_t *) wasm_bytes; + + printf("Compiling module...\n"); + wasm_module_t* module; + module = wasm_module_deserialize(store, &imported_bytes); + + if (!module) { + printf("> Error compiling module!\n"); + + return 1; + } + + printf("Creating imports...\n"); + wasm_extern_vec_t import_object = WASM_EMPTY_VEC; + + printf("Instantiating module...\n"); + wasm_instance_t* instance = wasm_instance_new(store, module, &import_object, NULL); + + if (!instance) { + printf("> Error instantiating module!\n"); + + return 1; + } + + printf("Retrieving exports...\n"); + wasm_extern_vec_t exports; + wasm_instance_exports(instance, &exports); + + if (exports.size == 0) { + printf("> Error accessing exports!\n"); + + return 1; + } + + printf("Retrieving the `sum` function...\n"); + wasm_func_t* sum_func = wasm_extern_as_func(exports.data[0]); + + if (sum_func == NULL) { + printf("> Failed to get the `sum` function!\n"); + + return 1; + } + + printf("Calling `sum` function...\n"); + wasm_val_t args_val[2] = { WASM_I32_VAL(a), WASM_I32_VAL(b) }; + wasm_val_t results_val[1] = { WASM_INIT_VAL }; + wasm_val_vec_t args = WASM_ARRAY_VEC(args_val); + wasm_val_vec_t results = WASM_ARRAY_VEC(results_val); + + if (wasm_func_call(sum_func, &args, &results)) { + printf("> Error calling the `sum` function!\n"); + + return 1; + } + + printf("Results of `sum`: %d\n", results_val[0].of.i32); + + return results_val[0].of.i32; +} + +// std::vector buffer; +// { +// std::ifstream in(file_path, std::ios::binary); +// in.seekg(0, std::ios::end); +// size_t size = in.tellg(); +// in.seekg(0, std::ios::beg); +// buffer.resize(size); +// in.read(reinterpret_cast(buffer.data()), size); +// } +// +// return buffer; diff --git a/tests/integration/ios/DylibExample/DylibExample/calc.h b/tests/integration/ios/DylibExample/DylibExample/calc.h new file mode 100644 index 000000000..b61f9b47b --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/calc.h @@ -0,0 +1,25 @@ +// +// WASM.hpp +// DylibExample +// +// Created by Nathan Horrigan on 17/08/2021. +// + +#ifndef calc_h +#define WASM_hpp +#include "wasm.h" +#include "wasmer.h" +#include "wasmer_wasm.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int calculate_sum(int a, int b); + +#ifdef __cplusplus +} +#endif + +#endif /* calc_h */ diff --git a/tests/integration/ios/DylibExample/DylibExample/calcr.c b/tests/integration/ios/DylibExample/DylibExample/calcr.c new file mode 100644 index 000000000..57b76ad2f --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/calcr.c @@ -0,0 +1,8 @@ +// +// calcr.c +// DylibExample +// +// Created by Nathan Horrigan on 17/08/2021. +// + +#include "calcr.h" diff --git a/tests/integration/ios/DylibExample/DylibExample/calcr.h b/tests/integration/ios/DylibExample/DylibExample/calcr.h new file mode 100644 index 000000000..f922ccf82 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/calcr.h @@ -0,0 +1,13 @@ +// +// calcr.h +// DylibExample +// +// Created by Nathan Horrigan on 17/08/2021. +// + +#ifndef calcr_h +#define calcr_h + +#include + +#endif /* calcr_h */ diff --git a/tests/integration/ios/DylibExample/DylibExample/sum.wasm b/tests/integration/ios/DylibExample/DylibExample/sum.wasm new file mode 100644 index 000000000..f1b05efb9 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExample/sum.wasm @@ -0,0 +1,7 @@ +(module +(type $sum_t (func (param i32 i32) (result i32))) +(func $sum_f (type $sum_t) (param $x i32) (param $y i32) (result i32) +local.get $x +local.get $y +i32.add) +(export "sum" (func $sum_f))) diff --git a/tests/integration/ios/DylibExample/DylibExampleTests/DylibExampleTests.swift b/tests/integration/ios/DylibExample/DylibExampleTests/DylibExampleTests.swift new file mode 100644 index 000000000..7ee1e2ab5 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExampleTests/DylibExampleTests.swift @@ -0,0 +1,33 @@ +// +// DylibExampleTests.swift +// DylibExampleTests +// +// Created by Nathan Horrigan on 15/08/2021. +// + +import XCTest +@testable import DylibExample + +class DylibExampleTests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + let sum = calculate_sum(5, 2) + assert(sum == 7, "WASM loaded successfully") + } + + func testPerformanceExample() throws { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/tests/integration/ios/DylibExample/DylibExampleTests/Info.plist b/tests/integration/ios/DylibExample/DylibExampleTests/Info.plist new file mode 100644 index 000000000..64d65ca49 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExampleTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/tests/integration/ios/DylibExample/DylibExampleUITests/DylibExampleUITests.swift b/tests/integration/ios/DylibExample/DylibExampleUITests/DylibExampleUITests.swift new file mode 100644 index 000000000..326a92cc8 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExampleUITests/DylibExampleUITests.swift @@ -0,0 +1,42 @@ +// +// DylibExampleUITests.swift +// DylibExampleUITests +// +// Created by Nathan Horrigan on 15/08/2021. +// + +import XCTest + +class DylibExampleUITests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + continueAfterFailure = false + + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // UI tests must launch the application that they test. + let app = XCUIApplication() + app.launch() + + // Use recording to get started writing UI tests. + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + + func testLaunchPerformance() throws { + if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { + // This measures how long it takes to launch your application. + measure(metrics: [XCTApplicationLaunchMetric()]) { + XCUIApplication().launch() + } + } + } +} diff --git a/tests/integration/ios/DylibExample/DylibExampleUITests/Info.plist b/tests/integration/ios/DylibExample/DylibExampleUITests/Info.plist new file mode 100644 index 000000000..64d65ca49 --- /dev/null +++ b/tests/integration/ios/DylibExample/DylibExampleUITests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/tests/integration/ios/tests/dylib.rs b/tests/integration/ios/tests/dylib.rs new file mode 100644 index 000000000..3a91456fe --- /dev/null +++ b/tests/integration/ios/tests/dylib.rs @@ -0,0 +1,42 @@ +#[cfg(test)] +#[cfg(target_os = "macos")] +mod tests { + use std::process::Command; + + #[test] + fn test_runtime() { + let (success, stdout) = run_ios_test("DylibExample/DylibExample.xcodeproj", "DylibExample"); + if !success { + println!("{}", stdout); + panic!("Dylib iOS Tests failed with the above output!"); + } + } + + fn run_ios_test(dir: &str, scheme: &str) -> (bool, String) { + let command = Command::new("xcodebuild") + .arg("test") + .arg("-project") + .arg(dir) + .arg("-scheme") + .arg(scheme) + .arg("-destination") + .arg("platform=iOS Simulator,name=iPhone 12 Pro,OS=14.5") + .output() + .expect("Could not run iOS Test"); + + // Get output from xcodebuild CLI: + let stderr = String::from_utf8(command.stderr).unwrap(); + let stdout = String::from_utf8(command.stdout).unwrap(); + + /* + An iOS Test Result is quite odd, we check stderr for the phrase 'TEST FAILED' + and then return stdout which contains the failure reason; + We also check that the command executed correctly! + */ + let command_success = command.status.success(); + let test_success = stderr.contains("** TEST FAILED **") == false; + let success = command_success && test_success; + + return (success, stdout); + } +}