diff --git a/.gitignore b/.gitignore index 5a9e5279..a80bfac2 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,6 @@ android/keystores/debug.keystore # Carthage ios/Carthage/ + +#Cocoapods +ios/Pods/ diff --git a/ios/Cartfile.resolved b/ios/Cartfile.resolved index 5d7d21be..f1662737 100644 --- a/ios/Cartfile.resolved +++ b/ios/Cartfile.resolved @@ -1,2 +1,3 @@ +github "hkellaway/Gloss" "0.7.4" github "stephencelis/SQLite.swift" "0.10.1" github "mozilla-magnet/magnet-scanner-ios" "0.1.2" diff --git a/ios/Magnet.xcodeproj/project.pbxproj b/ios/Magnet.xcodeproj/project.pbxproj index 0364b638..e2ca9f5e 100644 --- a/ios/Magnet.xcodeproj/project.pbxproj +++ b/ios/Magnet.xcodeproj/project.pbxproj @@ -21,14 +21,25 @@ 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; + 1BC0DBF7A10918EAC45ABB77 /* Pods_Magnet.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C765EB2407D1D2653E062264 /* Pods_Magnet.framework */; }; + 3DD18727B4B9A79B54587F01 /* Pods_MagnetWidget.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16BD2429F08D0D5CDB005675 /* Pods_MagnetWidget.framework */; }; 550CECBF1D3536F80076D807 /* NotificationsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 550CECBE1D3536F80076D807 /* NotificationsHelper.swift */; }; 5583EF0E1D3D55AD00852649 /* HistoryRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5583EF0D1D3D55AD00852649 /* HistoryRecord.swift */; }; 5583EF101D3D565200852649 /* HistorySQLite.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5583EF0F1D3D565200852649 /* HistorySQLite.swift */; }; 5583EF121D3E36C300852649 /* History.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5583EF111D3E36C300852649 /* History.swift */; }; 5583EF161D3E4A8400852649 /* SQLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5583EF151D3E4A8400852649 /* SQLite.framework */; }; + 6E52C4C22B62B7FAB1534E72 /* Pods_MagnetTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 98029367574C49A98A910AA0 /* Pods_MagnetTests.framework */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; + 856CA2AD1D76F611002A9CA3 /* MagnetMetadataClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 856CA2AC1D76F611002A9CA3 /* MagnetMetadataClient.swift */; }; + 856CA2E11D77071F002A9CA3 /* MagnetWidgetTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 856CA2E01D77071F002A9CA3 /* MagnetWidgetTableViewCell.swift */; }; 85767A351D6339BD009F400A /* MagnetScannerIOS.framework in Copy Files */ = {isa = PBXBuildFile; fileRef = 85DF9A331D633665004DF3F1 /* MagnetScannerIOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 85DC92CA1D6DF44400CC0BCB /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 85DC92C91D6DF44400CC0BCB /* NotificationCenter.framework */; }; + 85DC92D01D6DF44400CC0BCB /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 85DC92CE1D6DF44400CC0BCB /* MainInterface.storyboard */; }; + 85DC92D41D6DF44400CC0BCB /* MagnetWidget.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 85DC92C71D6DF44400CC0BCB /* MagnetWidget.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 85DC92E71D6DF52100CC0BCB /* MagnetWidgetTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85DC92E61D6DF52100CC0BCB /* MagnetWidgetTableViewController.swift */; }; + 85DC92E91D6DF5B400CC0BCB /* MagnetScannerIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 85DC92E81D6DF5B400CC0BCB /* MagnetScannerIOS.framework */; }; 85DF9A341D633665004DF3F1 /* MagnetScannerIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 85DF9A331D633665004DF3F1 /* MagnetScannerIOS.framework */; }; + 85E11C5B1D6E402E00AC602F /* MagnetScanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85E11C5A1D6E402E00AC602F /* MagnetScanner.swift */; }; 8D5722491CDCB16400480505 /* RNMagnetWebViewManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D5722461CDCB16400480505 /* RNMagnetWebViewManager.swift */; }; 8D57224A1CDCB16400480505 /* RNMagnetWebViewManagerExport.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D5722471CDCB16400480505 /* RNMagnetWebViewManagerExport.m */; }; 8D57224B1CDCB16400480505 /* RNMagnetWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D5722481CDCB16400480505 /* RNMagnetWebView.swift */; }; @@ -125,6 +136,13 @@ remoteGlobalIDString = 58B5119B1A9E6C1200147676; remoteInfo = RCTText; }; + 85DC92D21D6DF44400CC0BCB /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 85DC92C61D6DF44400CC0BCB; + remoteInfo = MagnetWidget; + }; 8D2FD78B1D42607500D8FCE8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 8DF6981FBE0A4B8D8545B9A5 /* BVLinearGradient.xcodeproj */; @@ -142,6 +160,17 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ + 85DC92E41D6DF44400CC0BCB /* Embed App Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 85DC92D41D6DF44400CC0BCB /* MagnetWidget.appex in Embed App Extensions */, + ); + name = "Embed App Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; 85DF9A271D632FED004DF3F1 /* Copy Files */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -176,7 +205,11 @@ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Magnet/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Magnet/main.m; sourceTree = ""; }; 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; + 16BD2429F08D0D5CDB005675 /* Pods_MagnetWidget.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MagnetWidget.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 1E053B6E455FBF4DE602950B /* Pods-MagnetWidget.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MagnetWidget.release.xcconfig"; path = "Pods/Target Support Files/Pods-MagnetWidget/Pods-MagnetWidget.release.xcconfig"; sourceTree = ""; }; + 523E7DFD1D595D2530A1F65F /* Pods-Magnet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Magnet.release.xcconfig"; path = "Pods/Target Support Files/Pods-Magnet/Pods-Magnet.release.xcconfig"; sourceTree = ""; }; 550CECBE1D3536F80076D807 /* NotificationsHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationsHelper.swift; sourceTree = ""; }; + 5544F6A14CACDACE4C5616B8 /* Pods-MagnetWidget.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MagnetWidget.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MagnetWidget/Pods-MagnetWidget.debug.xcconfig"; sourceTree = ""; }; 555800951CBE5F7800A21868 /* Magnet-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Magnet-Bridging-Header.h"; sourceTree = ""; }; 5583EF0D1D3D55AD00852649 /* HistoryRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HistoryRecord.swift; sourceTree = ""; }; 5583EF0F1D3D565200852649 /* HistorySQLite.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HistorySQLite.swift; sourceTree = ""; }; @@ -184,7 +217,17 @@ 5583EF151D3E4A8400852649 /* SQLite.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SQLite.framework; path = Carthage/Build/iOS/SQLite.framework; sourceTree = ""; }; 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; + 856CA2AC1D76F611002A9CA3 /* MagnetMetadataClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MagnetMetadataClient.swift; sourceTree = ""; }; + 856CA2E01D77071F002A9CA3 /* MagnetWidgetTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MagnetWidgetTableViewCell.swift; sourceTree = ""; }; + 85DC92C71D6DF44400CC0BCB /* MagnetWidget.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = MagnetWidget.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + 85DC92C91D6DF44400CC0BCB /* NotificationCenter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NotificationCenter.framework; path = System/Library/Frameworks/NotificationCenter.framework; sourceTree = SDKROOT; }; + 85DC92CF1D6DF44400CC0BCB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; + 85DC92D11D6DF44400CC0BCB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 85DC92E51D6DF52000CC0BCB /* MagnetWidget-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MagnetWidget-Bridging-Header.h"; sourceTree = ""; }; + 85DC92E61D6DF52100CC0BCB /* MagnetWidgetTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MagnetWidgetTableViewController.swift; sourceTree = ""; }; + 85DC92E81D6DF5B400CC0BCB /* MagnetScannerIOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = MagnetScannerIOS.framework; sourceTree = ""; }; 85DF9A331D633665004DF3F1 /* MagnetScannerIOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MagnetScannerIOS.framework; path = Carthage/Build/iOS/MagnetScannerIOS.framework; sourceTree = ""; }; + 85E11C5A1D6E402E00AC602F /* MagnetScanner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MagnetScanner.swift; sourceTree = ""; }; 8D5722461CDCB16400480505 /* RNMagnetWebViewManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RNMagnetWebViewManager.swift; sourceTree = ""; }; 8D5722471CDCB16400480505 /* RNMagnetWebViewManagerExport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNMagnetWebViewManagerExport.m; sourceTree = ""; }; 8D5722481CDCB16400480505 /* RNMagnetWebView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RNMagnetWebView.swift; sourceTree = ""; }; @@ -201,6 +244,11 @@ 8DF8217C1D5388090081F56E /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; 8DF8217E1D5388190081F56E /* libsqlite3.0.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.0.tbd; path = usr/lib/libsqlite3.0.tbd; sourceTree = SDKROOT; }; 8DF821831D53B3830081F56E /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; + 98029367574C49A98A910AA0 /* Pods_MagnetTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MagnetTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 9C6739906B51804D91481171 /* Pods-MagnetTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MagnetTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-MagnetTests/Pods-MagnetTests.release.xcconfig"; sourceTree = ""; }; + C765EB2407D1D2653E062264 /* Pods_Magnet.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Magnet.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + D642C66E8453CE3732A536E8 /* Pods-MagnetTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MagnetTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MagnetTests/Pods-MagnetTests.debug.xcconfig"; sourceTree = ""; }; + FAE150876D857CF32928A9BF /* Pods-Magnet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Magnet.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Magnet/Pods-Magnet.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -208,6 +256,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 6E52C4C22B62B7FAB1534E72 /* Pods_MagnetTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -234,6 +283,17 @@ 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, 8DF821771D5387E20081F56E /* libRCTGoogleAnalyticsBridge.a in Frameworks */, AA85BDA14B4C4D9A8524DCAD /* libBVLinearGradient.a in Frameworks */, + 1BC0DBF7A10918EAC45ABB77 /* Pods_Magnet.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 85DC92C41D6DF44400CC0BCB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 85DC92CA1D6DF44400CC0BCB /* NotificationCenter.framework in Frameworks */, + 85DC92E91D6DF5B400CC0BCB /* MagnetScannerIOS.framework in Frameworks */, + 3DD18727B4B9A79B54587F01 /* Pods_MagnetWidget.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -297,6 +357,19 @@ name = "Supporting Files"; sourceTree = ""; }; + 0220459EC7547A3A54C8A719 /* Pods */ = { + isa = PBXGroup; + children = ( + FAE150876D857CF32928A9BF /* Pods-Magnet.debug.xcconfig */, + 523E7DFD1D595D2530A1F65F /* Pods-Magnet.release.xcconfig */, + D642C66E8453CE3732A536E8 /* Pods-MagnetTests.debug.xcconfig */, + 9C6739906B51804D91481171 /* Pods-MagnetTests.release.xcconfig */, + 5544F6A14CACDACE4C5616B8 /* Pods-MagnetWidget.debug.xcconfig */, + 1E053B6E455FBF4DE602950B /* Pods-MagnetWidget.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; 139105B71AF99BAD00B5F7CC /* Products */ = { isa = PBXGroup; children = ( @@ -399,7 +472,10 @@ 13B07FAE1A68108700A75B9A /* Magnet */, 832341AE1AAA6A7D00B99B32 /* Libraries */, 00E356EF1AD99517003FC87E /* MagnetTests */, + 85DC92CB1D6DF44400CC0BCB /* MagnetWidget */, + 85DC92C81D6DF44400CC0BCB /* Frameworks */, 83CBBA001A601CBA00E9B192 /* Products */, + 0220459EC7547A3A54C8A719 /* Pods */, ); indentWidth = 2; sourceTree = ""; @@ -410,10 +486,37 @@ children = ( 13B07F961A680F5B00A75B9A /* Magnet.app */, 00E356EE1AD99517003FC87E /* MagnetTests.xctest */, + 85DC92C71D6DF44400CC0BCB /* MagnetWidget.appex */, ); name = Products; sourceTree = ""; }; + 85DC92C81D6DF44400CC0BCB /* Frameworks */ = { + isa = PBXGroup; + children = ( + 85DC92C91D6DF44400CC0BCB /* NotificationCenter.framework */, + C765EB2407D1D2653E062264 /* Pods_Magnet.framework */, + 98029367574C49A98A910AA0 /* Pods_MagnetTests.framework */, + 16BD2429F08D0D5CDB005675 /* Pods_MagnetWidget.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 85DC92CB1D6DF44400CC0BCB /* MagnetWidget */ = { + isa = PBXGroup; + children = ( + 85E11C5A1D6E402E00AC602F /* MagnetScanner.swift */, + 85DC92E81D6DF5B400CC0BCB /* MagnetScannerIOS.framework */, + 85DC92CE1D6DF44400CC0BCB /* MainInterface.storyboard */, + 85DC92D11D6DF44400CC0BCB /* Info.plist */, + 85DC92E61D6DF52100CC0BCB /* MagnetWidgetTableViewController.swift */, + 85DC92E51D6DF52000CC0BCB /* MagnetWidget-Bridging-Header.h */, + 856CA2AC1D76F611002A9CA3 /* MagnetMetadataClient.swift */, + 856CA2E01D77071F002A9CA3 /* MagnetWidgetTableViewCell.swift */, + ); + path = MagnetWidget; + sourceTree = ""; + }; 8D2FD7881D42607500D8FCE8 /* Products */ = { isa = PBXGroup; children = ( @@ -467,9 +570,12 @@ isa = PBXNativeTarget; buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "MagnetTests" */; buildPhases = ( + E820BD35F7274DD3C7DA3884 /* [CP] Check Pods Manifest.lock */, 00E356EA1AD99517003FC87E /* Sources */, 00E356EB1AD99517003FC87E /* Frameworks */, 00E356EC1AD99517003FC87E /* Resources */, + 73F6439AE59F2928EC25510D /* [CP] Embed Pods Frameworks */, + 4F19F5E8F1F5885DF9F54E89 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -485,6 +591,7 @@ isa = PBXNativeTarget; buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "Magnet" */; buildPhases = ( + D1513B4E20F29BB85A6074FE /* [CP] Check Pods Manifest.lock */, 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, @@ -492,23 +599,46 @@ 5583EF141D3E46FC00852649 /* ShellScript */, 85DF9A271D632FED004DF3F1 /* Copy Files */, 55AE10ED1D67664900CAD0E0 /* ShellScript */, + 85DC92E41D6DF44400CC0BCB /* Embed App Extensions */, + 28C3DE8E05A7A410B6DB952C /* [CP] Embed Pods Frameworks */, + BA5A3458C6269807A1A88428 /* [CP] Copy Pods Resources */, ); buildRules = ( ); dependencies = ( + 85DC92D31D6DF44400CC0BCB /* PBXTargetDependency */, ); name = Magnet; productName = "Hello World"; productReference = 13B07F961A680F5B00A75B9A /* Magnet.app */; productType = "com.apple.product-type.application"; }; + 85DC92C61D6DF44400CC0BCB /* MagnetWidget */ = { + isa = PBXNativeTarget; + buildConfigurationList = 85DC92E31D6DF44400CC0BCB /* Build configuration list for PBXNativeTarget "MagnetWidget" */; + buildPhases = ( + FAB312CE30E6CC85A08629F2 /* [CP] Check Pods Manifest.lock */, + 85DC92C31D6DF44400CC0BCB /* Sources */, + 85DC92C41D6DF44400CC0BCB /* Frameworks */, + 85DC92C51D6DF44400CC0BCB /* Resources */, + 52634AF623128654D6DB2157 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = MagnetWidget; + productName = MagnetWidget; + productReference = 85DC92C71D6DF44400CC0BCB /* MagnetWidget.appex */; + productType = "com.apple.product-type.app-extension"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 83CBB9F71A601CBA00E9B192 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 730; + LastSwiftUpdateCheck = 0730; LastUpgradeCheck = 730; ORGANIZATIONNAME = Facebook; TargetAttributes = { @@ -519,6 +649,10 @@ 13B07F861A680F5B00A75B9A = { DevelopmentTeam = 43AQ936H96; }; + 85DC92C61D6DF44400CC0BCB = { + CreatedOnToolsVersion = 7.3.1; + DevelopmentTeam = 43AQ936H96; + }; }; }; buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "Magnet" */; @@ -586,6 +720,7 @@ targets = ( 13B07F861A680F5B00A75B9A /* Magnet */, 00E356ED1AD99517003FC87E /* MagnetTests */, + 85DC92C61D6DF44400CC0BCB /* MagnetWidget */, ); }; /* End PBXProject section */ @@ -697,6 +832,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 85DC92C51D6DF44400CC0BCB /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 85DC92D01D6DF44400CC0BCB /* MainInterface.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -714,6 +857,51 @@ shellPath = /bin/sh; shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh"; }; + 28C3DE8E05A7A410B6DB952C /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Magnet/Pods-Magnet-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 4F19F5E8F1F5885DF9F54E89 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-MagnetTests/Pods-MagnetTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 52634AF623128654D6DB2157 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-MagnetWidget/Pods-MagnetWidget-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; 5583EF141D3E46FC00852649 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -741,6 +929,81 @@ shellPath = /bin/sh; shellScript = "APP_PATH=\"${TARGET_BUILD_DIR}/${WRAPPER_NAME}\"\n\n# This script loops through the frameworks embedded in the application and\n# removes unused architectures.\nfind \"$APP_PATH\" -name '*.framework' -type d | while read -r FRAMEWORK\ndo\nFRAMEWORK_EXECUTABLE_NAME=$(defaults read \"$FRAMEWORK/Info.plist\" CFBundleExecutable)\nFRAMEWORK_EXECUTABLE_PATH=\"$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME\"\necho \"Executable is $FRAMEWORK_EXECUTABLE_PATH\"\n\nEXTRACTED_ARCHS=()\n\nfor ARCH in $ARCHS\ndo\necho \"Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME\"\nlipo -extract \"$ARCH\" \"$FRAMEWORK_EXECUTABLE_PATH\" -o \"$FRAMEWORK_EXECUTABLE_PATH-$ARCH\"\nEXTRACTED_ARCHS+=(\"$FRAMEWORK_EXECUTABLE_PATH-$ARCH\")\ndone\n\necho \"Merging extracted architectures: ${ARCHS}\"\nlipo -o \"$FRAMEWORK_EXECUTABLE_PATH-merged\" -create \"${EXTRACTED_ARCHS[@]}\"\nrm \"${EXTRACTED_ARCHS[@]}\"\n\necho \"Replacing original executable with thinned version\"\nrm \"$FRAMEWORK_EXECUTABLE_PATH\"\nmv \"$FRAMEWORK_EXECUTABLE_PATH-merged\" \"$FRAMEWORK_EXECUTABLE_PATH\"\n\ndone"; }; + 73F6439AE59F2928EC25510D /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-MagnetTests/Pods-MagnetTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + BA5A3458C6269807A1A88428 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Magnet/Pods-Magnet-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + D1513B4E20F29BB85A6074FE /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + E820BD35F7274DD3C7DA3884 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + FAB312CE30E6CC85A08629F2 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -771,6 +1034,17 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 85DC92C31D6DF44400CC0BCB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 85E11C5B1D6E402E00AC602F /* MagnetScanner.swift in Sources */, + 856CA2E11D77071F002A9CA3 /* MagnetWidgetTableViewCell.swift in Sources */, + 85DC92E71D6DF52100CC0BCB /* MagnetWidgetTableViewController.swift in Sources */, + 856CA2AD1D76F611002A9CA3 /* MagnetMetadataClient.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -779,6 +1053,11 @@ target = 13B07F861A680F5B00A75B9A /* Magnet */; targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */; }; + 85DC92D31D6DF44400CC0BCB /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 85DC92C61D6DF44400CC0BCB /* MagnetWidget */; + targetProxy = 85DC92D21D6DF44400CC0BCB /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -791,11 +1070,20 @@ path = Magnet; sourceTree = ""; }; + 85DC92CE1D6DF44400CC0BCB /* MainInterface.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 85DC92CF1D6DF44400CC0BCB /* Base */, + ); + name = MainInterface.storyboard; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 00E356F61AD99517003FC87E /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = D642C66E8453CE3732A536E8 /* Pods-MagnetTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; FRAMEWORK_SEARCH_PATHS = ( @@ -821,6 +1109,7 @@ }; 00E356F71AD99517003FC87E /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 9C6739906B51804D91481171 /* Pods-MagnetTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; COPY_PHASE_STRIP = NO; @@ -843,6 +1132,7 @@ }; 13B07F941A680F5B00A75B9A /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = FAE150876D857CF32928A9BF /* Pods-Magnet.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets"; @@ -850,6 +1140,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEAD_CODE_STRIPPING = NO; + EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", @@ -877,12 +1168,14 @@ }; 13B07F951A680F5B00A75B9A /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 523E7DFD1D595D2530A1F65F /* Pods-Magnet.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", @@ -997,6 +1290,58 @@ }; name = Release; }; + 85DC92D51D6DF44400CC0BCB /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5544F6A14CACDACE4C5616B8 /* Pods-MagnetWidget.debug.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + DEBUG_INFORMATION_FORMAT = dwarf; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/MagnetWidget", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = MagnetWidget/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = org.mozilla.ios.Magnet.MagnetWidget; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_OBJC_BRIDGING_HEADER = "MagnetWidget/MagnetWidget-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 85DC92D61D6DF44400CC0BCB /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 1E053B6E455FBF4DE602950B /* Pods-MagnetWidget.release.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/MagnetWidget", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = MagnetWidget/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = org.mozilla.ios.Magnet.MagnetWidget; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_OBJC_BRIDGING_HEADER = "MagnetWidget/MagnetWidget-Bridging-Header.h"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -1027,6 +1372,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 85DC92E31D6DF44400CC0BCB /* Build configuration list for PBXNativeTarget "MagnetWidget" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 85DC92D51D6DF44400CC0BCB /* Debug */, + 85DC92D61D6DF44400CC0BCB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; diff --git a/ios/Magnet.xcworkspace/contents.xcworkspacedata b/ios/Magnet.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..fb152965 --- /dev/null +++ b/ios/Magnet.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/ios/MagnetWidget/Base.lproj/MainInterface.storyboard b/ios/MagnetWidget/Base.lproj/MainInterface.storyboard new file mode 100644 index 00000000..b7d7c46c --- /dev/null +++ b/ios/MagnetWidget/Base.lproj/MainInterface.storyboard @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/MagnetWidget/Info.plist b/ios/MagnetWidget/Info.plist new file mode 100644 index 00000000..468b920d --- /dev/null +++ b/ios/MagnetWidget/Info.plist @@ -0,0 +1,33 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + Magnet + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + NSExtension + + NSExtensionMainStoryboard + MainInterface + NSExtensionPointIdentifier + com.apple.widget-extension + + + diff --git a/ios/MagnetWidget/MagnetMetadataClient.swift b/ios/MagnetWidget/MagnetMetadataClient.swift new file mode 100644 index 00000000..ee81594f --- /dev/null +++ b/ios/MagnetWidget/MagnetMetadataClient.swift @@ -0,0 +1,72 @@ +import Foundation +import SwiftSerializer + +class MagnetObject: Serializable { + var url: String; + + init(url: String) { + self.url = url; + } +} + +class MagnetRequest: Serializable { + var objects: Array; + + init(objects: Array) { + self.objects = objects; + } +} + +class MagnetMetadataClient: NSObject { + let metadataServerUrl: NSURL = NSURL(string: "https://tengam.org/api/v1/metadata")!; + var onMetadata: (([String:AnyObject]) -> Void)!; + + init(onMetadata: ([String:AnyObject]) -> Void) { + super.init(); + self.onMetadata = onMetadata; + } + + func requestMetadata(url: String) { + let request = NSMutableURLRequest(URL: metadataServerUrl); + request.HTTPMethod = "POST"; + request.setValue("application/json", forHTTPHeaderField: "Content-Type"); + + // Serialize request body. + let magnetUrl = MagnetObject(url: url); + var magnetObjects = [MagnetObject](); + magnetObjects.append(magnetUrl); + debugPrint("url", magnetUrl.toJsonString()!); + + let body = MagnetRequest(objects: magnetObjects); + debugPrint("request", body.toJsonString()!); + + request.HTTPBody = body.toJson(); + + let config = NSURLSessionConfiguration.defaultSessionConfiguration(); + let session = NSURLSession(configuration: config); + let task = session.dataTaskWithRequest(request, completionHandler: { + (data, response, error) in + guard error == nil else { + print("Error: metadata server error", error); + return; + } + guard let responseData = data else { + print("Error: did not receive data from metadata server"); + return; + } + do { + guard let metadata = + try NSJSONSerialization.JSONObjectWithData(responseData, options: .AllowFragments) + as? [[String:AnyObject]] else { + print("Error: JSON parse error. Crap"); + return; + } + self.onMetadata(metadata[0]); + + } catch { + print("Error: JSON parse error"); + } + }); + task.resume(); + } +} \ No newline at end of file diff --git a/ios/MagnetWidget/MagnetScanner.swift b/ios/MagnetWidget/MagnetScanner.swift new file mode 100644 index 00000000..5ce8bca2 --- /dev/null +++ b/ios/MagnetWidget/MagnetScanner.swift @@ -0,0 +1,20 @@ +import Foundation +import MagnetScannerIOS + +class MagnetScanner: NSObject { + var scanner: MagnetScannerIOS.MagnetScanner!; + var callback: ((Dictionary) -> Void)! + + init(callback: (Dictionary) -> Void) { + super.init(); + scanner = MagnetScannerIOS.MagnetScanner(callback: callback); + } + + func start() { + scanner.start(); + } + + func stop() { + scanner.stop(); + } +} \ No newline at end of file diff --git a/ios/MagnetWidget/MagnetScannerIOS.framework/Headers/MagnetScannerIOS-Swift.h b/ios/MagnetWidget/MagnetScannerIOS.framework/Headers/MagnetScannerIOS-Swift.h new file mode 100644 index 00000000..f6f83153 --- /dev/null +++ b/ios/MagnetWidget/MagnetScannerIOS.framework/Headers/MagnetScannerIOS-Swift.h @@ -0,0 +1,99 @@ +// Generated by Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31) +#pragma clang diagnostic push + +#if defined(__has_include) && __has_include() +# include +#endif + +#pragma clang diagnostic ignored "-Wauto-import" +#include +#include +#include +#include + +#if !defined(SWIFT_TYPEDEFS) +# define SWIFT_TYPEDEFS 1 +# if defined(__has_include) && __has_include() +# include +# elif !defined(__cplusplus) || __cplusplus < 201103L +typedef uint_least16_t char16_t; +typedef uint_least32_t char32_t; +# endif +typedef float swift_float2 __attribute__((__ext_vector_type__(2))); +typedef float swift_float3 __attribute__((__ext_vector_type__(3))); +typedef float swift_float4 __attribute__((__ext_vector_type__(4))); +typedef double swift_double2 __attribute__((__ext_vector_type__(2))); +typedef double swift_double3 __attribute__((__ext_vector_type__(3))); +typedef double swift_double4 __attribute__((__ext_vector_type__(4))); +typedef int swift_int2 __attribute__((__ext_vector_type__(2))); +typedef int swift_int3 __attribute__((__ext_vector_type__(3))); +typedef int swift_int4 __attribute__((__ext_vector_type__(4))); +#endif + +#if !defined(SWIFT_PASTE) +# define SWIFT_PASTE_HELPER(x, y) x##y +# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y) +#endif +#if !defined(SWIFT_METATYPE) +# define SWIFT_METATYPE(X) Class +#endif + +#if defined(__has_attribute) && __has_attribute(objc_runtime_name) +# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X))) +#else +# define SWIFT_RUNTIME_NAME(X) +#endif +#if defined(__has_attribute) && __has_attribute(swift_name) +# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X))) +#else +# define SWIFT_COMPILE_NAME(X) +#endif +#if !defined(SWIFT_CLASS_EXTRA) +# define SWIFT_CLASS_EXTRA +#endif +#if !defined(SWIFT_PROTOCOL_EXTRA) +# define SWIFT_PROTOCOL_EXTRA +#endif +#if !defined(SWIFT_ENUM_EXTRA) +# define SWIFT_ENUM_EXTRA +#endif +#if !defined(SWIFT_CLASS) +# if defined(__has_attribute) && __has_attribute(objc_subclassing_restricted) +# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA +# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA +# else +# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA +# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA +# endif +#endif + +#if !defined(SWIFT_PROTOCOL) +# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA +# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA +#endif + +#if !defined(SWIFT_EXTENSION) +# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__) +#endif + +#if !defined(OBJC_DESIGNATED_INITIALIZER) +# if defined(__has_attribute) && __has_attribute(objc_designated_initializer) +# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +# else +# define OBJC_DESIGNATED_INITIALIZER +# endif +#endif +#if !defined(SWIFT_ENUM) +# define SWIFT_ENUM(_type, _name) enum _name : _type _name; enum SWIFT_ENUM_EXTRA _name : _type +# if defined(__has_feature) && __has_feature(generalized_swift_name) +# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_EXTRA _name : _type +# else +# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME) SWIFT_ENUM(_type, _name) +# endif +#endif +#if defined(__has_feature) && __has_feature(modules) +#endif + +#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch" +#pragma clang diagnostic ignored "-Wduplicate-method-arg" +#pragma clang diagnostic pop diff --git a/ios/MagnetWidget/MagnetScannerIOS.framework/Headers/MagnetScannerIOS.h b/ios/MagnetWidget/MagnetScannerIOS.framework/Headers/MagnetScannerIOS.h new file mode 100644 index 00000000..24628918 --- /dev/null +++ b/ios/MagnetWidget/MagnetScannerIOS.framework/Headers/MagnetScannerIOS.h @@ -0,0 +1,11 @@ +#import + +//! Project version number for MagnetScannerIOS. +FOUNDATION_EXPORT double MagnetScannerIOSVersionNumber; + +//! Project version string for MagnetScannerIOS. +FOUNDATION_EXPORT const unsigned char MagnetScannerIOSVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/ios/MagnetWidget/MagnetScannerIOS.framework/Info.plist b/ios/MagnetWidget/MagnetScannerIOS.framework/Info.plist new file mode 100644 index 00000000..c0f9a971 Binary files /dev/null and b/ios/MagnetWidget/MagnetScannerIOS.framework/Info.plist differ diff --git a/ios/MagnetWidget/MagnetScannerIOS.framework/MagnetScannerIOS b/ios/MagnetWidget/MagnetScannerIOS.framework/MagnetScannerIOS new file mode 100755 index 00000000..454df6de Binary files /dev/null and b/ios/MagnetWidget/MagnetScannerIOS.framework/MagnetScannerIOS differ diff --git a/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/arm.swiftdoc b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/arm.swiftdoc new file mode 100644 index 00000000..c0cb34b0 Binary files /dev/null and b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/arm.swiftdoc differ diff --git a/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/arm.swiftmodule b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/arm.swiftmodule new file mode 100644 index 00000000..82863331 Binary files /dev/null and b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/arm.swiftmodule differ diff --git a/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/arm64.swiftdoc b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/arm64.swiftdoc new file mode 100644 index 00000000..869f6e7d Binary files /dev/null and b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/arm64.swiftdoc differ diff --git a/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/arm64.swiftmodule b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/arm64.swiftmodule new file mode 100644 index 00000000..89fdf401 Binary files /dev/null and b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/arm64.swiftmodule differ diff --git a/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/i386.swiftdoc b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/i386.swiftdoc new file mode 100644 index 00000000..429eb59b Binary files /dev/null and b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/i386.swiftdoc differ diff --git a/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/i386.swiftmodule b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/i386.swiftmodule new file mode 100644 index 00000000..58edcfd1 Binary files /dev/null and b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/i386.swiftmodule differ diff --git a/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/x86_64.swiftdoc b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/x86_64.swiftdoc new file mode 100644 index 00000000..5a238210 Binary files /dev/null and b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/x86_64.swiftdoc differ diff --git a/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/x86_64.swiftmodule b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/x86_64.swiftmodule new file mode 100644 index 00000000..3dc4c88a Binary files /dev/null and b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/MagnetScannerIOS.swiftmodule/x86_64.swiftmodule differ diff --git a/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/module.modulemap b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/module.modulemap new file mode 100644 index 00000000..a5820f21 --- /dev/null +++ b/ios/MagnetWidget/MagnetScannerIOS.framework/Modules/module.modulemap @@ -0,0 +1,10 @@ +framework module MagnetScannerIOS { + umbrella header "MagnetScannerIOS.h" + + export * + module * { export * } +} + +module MagnetScannerIOS.Swift { + header "MagnetScannerIOS-Swift.h" +} diff --git a/ios/MagnetWidget/MagnetWidget-Bridging-Header.h b/ios/MagnetWidget/MagnetWidget-Bridging-Header.h new file mode 100644 index 00000000..1b2cb5d6 --- /dev/null +++ b/ios/MagnetWidget/MagnetWidget-Bridging-Header.h @@ -0,0 +1,4 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + diff --git a/ios/MagnetWidget/MagnetWidgetTableViewCell.swift b/ios/MagnetWidget/MagnetWidgetTableViewCell.swift new file mode 100644 index 00000000..e21f2322 --- /dev/null +++ b/ios/MagnetWidget/MagnetWidgetTableViewCell.swift @@ -0,0 +1,6 @@ +import UIKit + +class MagnetWidgetTableViewCell: UITableViewCell { + @IBOutlet weak var titleLabel: UILabel! + @IBOutlet weak var urlLabel: UILabel! +} diff --git a/ios/MagnetWidget/MagnetWidgetTableViewController.swift b/ios/MagnetWidget/MagnetWidgetTableViewController.swift new file mode 100644 index 00000000..7896024e --- /dev/null +++ b/ios/MagnetWidget/MagnetWidgetTableViewController.swift @@ -0,0 +1,141 @@ +import UIKit +import NotificationCenter + +class MagnetWidgetTableViewController: UITableViewController, NCWidgetProviding { + var scanner: MagnetScanner!; + var metadataClient: MagnetMetadataClient?; + var nearbyUrls: [String]!; + var metadata: NSMutableDictionary!; + + @IBOutlet var table: UITableView!; + + var rowHeight: CGFloat { + return 50; + } + + override func viewDidLoad() { + debugPrint("viewDidLoad"); + super.viewDidLoad(); + + // Today widgets should have transparent background. + table.backgroundColor = UIColor.clearColor(); + + scanner = MagnetScanner(callback: onItemFound); + nearbyUrls = []; + metadata = NSMutableDictionary(); + + updateSize(); + } + + override func viewWillAppear(animated: Bool) { + debugPrint("viewWillAppear"); + super.viewWillAppear(animated); + // Make the widget full width. + if let superview = view.superview { + var frame = superview.frame + frame = CGRectMake(0, CGRectGetMinY(frame), CGRectGetWidth(frame) + CGRectGetMinX(frame), CGRectGetHeight(frame)) + superview.frame = frame + } + scanner.start(); + table.reloadData(); + updateSize(); + } + + override func viewWillDisappear(animated: Bool) { + debugPrint("viewWillDisappear"); + super.viewWillDisappear(animated); + scanner.stop(); + nearbyUrls = []; + metadata.removeAllObjects(); + } + + func updateSize() { + debugPrint("updateSize") + var preferredSize = self.preferredContentSize; + preferredSize.height = self.rowHeight * CGFloat(self.nearbyUrls.count); + preferredContentSize = preferredSize; + } + + func onItemFound(item: Dictionary) { + debugPrint("MagnetWidget - item found", item); + + let url = item["url"] as! String; + guard nearbyUrls.contains(url) == false else { return } + + nearbyUrls.append(url); + + if (metadataClient == nil) { + metadataClient = MagnetMetadataClient(onMetadata: onMetadata); + } + + metadataClient!.requestMetadata(url); + } + + func onMetadata(metadata: [String:AnyObject]) { + debugPrint("OnMetadata", metadata); + + self.metadata.setValue(metadata, forKey: metadata["originalUrl"] as! String); + + table.reloadData(); + updateSize(); + } + + // MARK: - Widget Delegate + + func widgetPerformUpdateWithCompletionHandler(completionHandler: (NCUpdateResult) -> Void) { + debugPrint("widgetPerformUpdateWithCompletionHandler"); + // It tells the widget to update itself. + table.reloadData(); + completionHandler(NCUpdateResult.NewData); + } + + // MARK: - Table view data source + + override func numberOfSectionsInTableView(tableView: UITableView) -> Int { + return 1; + } + + override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + debugPrint("Number of rows", self.nearbyUrls.count); + return nearbyUrls.count; + } + + override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + debugPrint("Displaying cell"); + let cell = tableView.dequeueReusableCellWithIdentifier( + "MagnetCell", forIndexPath: indexPath) as! MagnetWidgetTableViewCell; + cell.titleLabel!.textColor = UIColor.whiteColor(); + cell.urlLabel!.textColor = UIColor.grayColor(); + + let url = nearbyUrls[indexPath.row]; + guard let metadata = self.metadata[url] else { + return cell; + } + + // Add Magnet URL to the table view. + if let title = metadata["title"] as? String { + cell.titleLabel!.text = title; + } + + if let displayUrl = metadata["displayUrl"] as? String { + cell.urlLabel!.text = displayUrl; + } + + return cell; + } + + override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + let url:NSURL = NSURL(string:nearbyUrls[indexPath.row])!; + extensionContext?.openURL(url, completionHandler: nil); + } + + override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) { + cell.layer.backgroundColor = UIColor.clearColor().CGColor; + } + + override func didReceiveMemoryWarning() { + debugPrint("Memory warning"); + super.didReceiveMemoryWarning(); + // Dispose of any resources that can be recreated. + } +} \ No newline at end of file diff --git a/ios/Podfile b/ios/Podfile new file mode 100644 index 00000000..364fd7bd --- /dev/null +++ b/ios/Podfile @@ -0,0 +1,24 @@ +# Uncomment this line to define a global platform for your project +platform :ios, '8.0' + +target 'Magnet' do + # Comment this line if you're not using Swift and don't want to use dynamic frameworks + use_frameworks! + + # Pods for Magnet + + target 'MagnetTests' do + inherit! :search_paths + # Pods for testing + end + +end + +target 'MagnetWidget' do + # Comment this line if you're not using Swift and don't want to use dynamic frameworks + use_frameworks! + + # Pods for MagnetWidget + pod 'SwiftSerializer', '~> 0.6' + +end diff --git a/ios/Podfile.lock b/ios/Podfile.lock new file mode 100644 index 00000000..ab44c255 --- /dev/null +++ b/ios/Podfile.lock @@ -0,0 +1,12 @@ +PODS: + - SwiftSerializer (0.6) + +DEPENDENCIES: + - SwiftSerializer (~> 0.6) + +SPEC CHECKSUMS: + SwiftSerializer: d8376bfa5ab0eaf0f16b7fc19e684116617f43da + +PODFILE CHECKSUM: 7fd955b5e1f44f5b6881d33e43bfcff5066aa4ad + +COCOAPODS: 1.1.0.beta.1