├── Podfile ├── README.md ├── SwiftObjcCocoapodsExample.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── SwiftObjcCocoapodsExample.xcworkspace └── contents.xcworkspacedata ├── SwiftObjcCocoapodsExample ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── ObjcIPManager.h ├── ObjcIPManager.m ├── SwiftIPManager.swift ├── SwiftObjcCocoapodsExample-Bridging-Header.h └── ViewController.swift └── SwiftObjcCocoapodsExampleTests ├── Info.plist └── SwiftObjcCocoapodsExampleTests.swift /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '6.0' 3 | 4 | target 'SwiftObjcCocoapodsExample' do 5 | pod 'AFNetworking', '~> 2.5.0' 6 | 7 | end 8 | 9 | target 'SwiftObjcCocoapodsExampleTests' do 10 | 11 | end 12 | 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SwiftObjcCocoapodsExample 2 | ========================= 3 | 4 | Swift ,Objective-C and Cocoapods mix and match example 5 | 6 | It demonstrated : 7 | * Swift calling Swift function 8 | * Swift calling Objective-C function 9 | * Objective-C calling Swift function 10 | * Swift calling Objective-C function from Swift function 11 | * and integrated Cocoapods with powerful libs created by Objective-C 12 | 13 | #ViewController.swift 14 | ```swift 15 | // call Swift 16 | SwiftIPManager.getIP() 17 | 18 | // call ObjC 19 | ObjcIPManager.getIP() 20 | 21 | // from Objc call Swift 22 | ObjcIPManager.getIPFromSwift() 23 | ``` 24 | -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0496639C40E9C4EA7719055F /* libPods-SwiftObjcCocoapodsExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C7DB16AE4912B5BFABCE46A /* libPods-SwiftObjcCocoapodsExample.a */; }; 11 | D1FD02C01A584E9400E8FCFE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1FD02BF1A584E9400E8FCFE /* AppDelegate.swift */; }; 12 | D1FD02C21A584E9400E8FCFE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1FD02C11A584E9400E8FCFE /* ViewController.swift */; }; 13 | D1FD02C51A584E9400E8FCFE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D1FD02C31A584E9400E8FCFE /* Main.storyboard */; }; 14 | D1FD02C71A584E9400E8FCFE /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D1FD02C61A584E9400E8FCFE /* Images.xcassets */; }; 15 | D1FD02CA1A584E9400E8FCFE /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = D1FD02C81A584E9400E8FCFE /* LaunchScreen.xib */; }; 16 | D1FD02D61A584E9400E8FCFE /* SwiftObjcCocoapodsExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1FD02D51A584E9400E8FCFE /* SwiftObjcCocoapodsExampleTests.swift */; }; 17 | D1FD02E41A58D8A000E8FCFE /* SwiftIPManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1FD02E31A58D8A000E8FCFE /* SwiftIPManager.swift */; }; 18 | D1FD02E71A58DEF400E8FCFE /* ObjcIPManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D1FD02E61A58DEF400E8FCFE /* ObjcIPManager.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | D1FD02D01A584E9400E8FCFE /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = D1FD02B21A584E9400E8FCFE /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = D1FD02B91A584E9400E8FCFE; 27 | remoteInfo = SwiftObjcCocoapodsExample; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 1C7DB16AE4912B5BFABCE46A /* libPods-SwiftObjcCocoapodsExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SwiftObjcCocoapodsExample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 44619E4F81E4B51ED9F92EE6 /* Pods-SwiftObjcCocoapodsExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftObjcCocoapodsExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftObjcCocoapodsExample/Pods-SwiftObjcCocoapodsExample.release.xcconfig"; sourceTree = ""; }; 34 | AE522E377491A49F6914BC1D /* Pods-SwiftObjcCocoapodsExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftObjcCocoapodsExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftObjcCocoapodsExample/Pods-SwiftObjcCocoapodsExample.debug.xcconfig"; sourceTree = ""; }; 35 | D1FD02BA1A584E9400E8FCFE /* SwiftObjcCocoapodsExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftObjcCocoapodsExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | D1FD02BE1A584E9400E8FCFE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 37 | D1FD02BF1A584E9400E8FCFE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 38 | D1FD02C11A584E9400E8FCFE /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 39 | D1FD02C41A584E9400E8FCFE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 40 | D1FD02C61A584E9400E8FCFE /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 41 | D1FD02C91A584E9400E8FCFE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 42 | D1FD02CF1A584E9400E8FCFE /* SwiftObjcCocoapodsExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftObjcCocoapodsExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | D1FD02D41A584E9400E8FCFE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | D1FD02D51A584E9400E8FCFE /* SwiftObjcCocoapodsExampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftObjcCocoapodsExampleTests.swift; sourceTree = ""; }; 45 | D1FD02DF1A584FA900E8FCFE /* SwiftObjcCocoapodsExample-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SwiftObjcCocoapodsExample-Bridging-Header.h"; sourceTree = ""; }; 46 | D1FD02E31A58D8A000E8FCFE /* SwiftIPManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftIPManager.swift; sourceTree = ""; }; 47 | D1FD02E51A58DEF400E8FCFE /* ObjcIPManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjcIPManager.h; sourceTree = ""; }; 48 | D1FD02E61A58DEF400E8FCFE /* ObjcIPManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjcIPManager.m; sourceTree = ""; }; 49 | /* End PBXFileReference section */ 50 | 51 | /* Begin PBXFrameworksBuildPhase section */ 52 | D1FD02B71A584E9400E8FCFE /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | 0496639C40E9C4EA7719055F /* libPods-SwiftObjcCocoapodsExample.a in Frameworks */, 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | D1FD02CC1A584E9400E8FCFE /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | /* End PBXFrameworksBuildPhase section */ 68 | 69 | /* Begin PBXGroup section */ 70 | 52F2B95E0D47FC6075DEEA98 /* Pods */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | AE522E377491A49F6914BC1D /* Pods-SwiftObjcCocoapodsExample.debug.xcconfig */, 74 | 44619E4F81E4B51ED9F92EE6 /* Pods-SwiftObjcCocoapodsExample.release.xcconfig */, 75 | ); 76 | name = Pods; 77 | sourceTree = ""; 78 | }; 79 | AEA910FCB34C799CDCCDBDDB /* Frameworks */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 1C7DB16AE4912B5BFABCE46A /* libPods-SwiftObjcCocoapodsExample.a */, 83 | ); 84 | name = Frameworks; 85 | sourceTree = ""; 86 | }; 87 | D1FD02B11A584E9400E8FCFE = { 88 | isa = PBXGroup; 89 | children = ( 90 | D1FD02BC1A584E9400E8FCFE /* SwiftObjcCocoapodsExample */, 91 | D1FD02D21A584E9400E8FCFE /* SwiftObjcCocoapodsExampleTests */, 92 | D1FD02BB1A584E9400E8FCFE /* Products */, 93 | 52F2B95E0D47FC6075DEEA98 /* Pods */, 94 | AEA910FCB34C799CDCCDBDDB /* Frameworks */, 95 | ); 96 | sourceTree = ""; 97 | }; 98 | D1FD02BB1A584E9400E8FCFE /* Products */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | D1FD02BA1A584E9400E8FCFE /* SwiftObjcCocoapodsExample.app */, 102 | D1FD02CF1A584E9400E8FCFE /* SwiftObjcCocoapodsExampleTests.xctest */, 103 | ); 104 | name = Products; 105 | sourceTree = ""; 106 | }; 107 | D1FD02BC1A584E9400E8FCFE /* SwiftObjcCocoapodsExample */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | D1FD02BF1A584E9400E8FCFE /* AppDelegate.swift */, 111 | D1FD02C11A584E9400E8FCFE /* ViewController.swift */, 112 | D1FD02E31A58D8A000E8FCFE /* SwiftIPManager.swift */, 113 | D1FD02C31A584E9400E8FCFE /* Main.storyboard */, 114 | D1FD02C61A584E9400E8FCFE /* Images.xcassets */, 115 | D1FD02C81A584E9400E8FCFE /* LaunchScreen.xib */, 116 | D1FD02BD1A584E9400E8FCFE /* Supporting Files */, 117 | D1FD02DF1A584FA900E8FCFE /* SwiftObjcCocoapodsExample-Bridging-Header.h */, 118 | D1FD02E51A58DEF400E8FCFE /* ObjcIPManager.h */, 119 | D1FD02E61A58DEF400E8FCFE /* ObjcIPManager.m */, 120 | ); 121 | path = SwiftObjcCocoapodsExample; 122 | sourceTree = ""; 123 | }; 124 | D1FD02BD1A584E9400E8FCFE /* Supporting Files */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | D1FD02BE1A584E9400E8FCFE /* Info.plist */, 128 | ); 129 | name = "Supporting Files"; 130 | sourceTree = ""; 131 | }; 132 | D1FD02D21A584E9400E8FCFE /* SwiftObjcCocoapodsExampleTests */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | D1FD02D51A584E9400E8FCFE /* SwiftObjcCocoapodsExampleTests.swift */, 136 | D1FD02D31A584E9400E8FCFE /* Supporting Files */, 137 | ); 138 | path = SwiftObjcCocoapodsExampleTests; 139 | sourceTree = ""; 140 | }; 141 | D1FD02D31A584E9400E8FCFE /* Supporting Files */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | D1FD02D41A584E9400E8FCFE /* Info.plist */, 145 | ); 146 | name = "Supporting Files"; 147 | sourceTree = ""; 148 | }; 149 | /* End PBXGroup section */ 150 | 151 | /* Begin PBXNativeTarget section */ 152 | D1FD02B91A584E9400E8FCFE /* SwiftObjcCocoapodsExample */ = { 153 | isa = PBXNativeTarget; 154 | buildConfigurationList = D1FD02D91A584E9400E8FCFE /* Build configuration list for PBXNativeTarget "SwiftObjcCocoapodsExample" */; 155 | buildPhases = ( 156 | 04383FF8E8FCED08D87E070D /* Check Pods Manifest.lock */, 157 | D1FD02B61A584E9400E8FCFE /* Sources */, 158 | D1FD02B71A584E9400E8FCFE /* Frameworks */, 159 | D1FD02B81A584E9400E8FCFE /* Resources */, 160 | ABE4FDD98E38E28857E89D02 /* Copy Pods Resources */, 161 | ); 162 | buildRules = ( 163 | ); 164 | dependencies = ( 165 | ); 166 | name = SwiftObjcCocoapodsExample; 167 | productName = SwiftObjcCocoapodsExample; 168 | productReference = D1FD02BA1A584E9400E8FCFE /* SwiftObjcCocoapodsExample.app */; 169 | productType = "com.apple.product-type.application"; 170 | }; 171 | D1FD02CE1A584E9400E8FCFE /* SwiftObjcCocoapodsExampleTests */ = { 172 | isa = PBXNativeTarget; 173 | buildConfigurationList = D1FD02DC1A584E9400E8FCFE /* Build configuration list for PBXNativeTarget "SwiftObjcCocoapodsExampleTests" */; 174 | buildPhases = ( 175 | D1FD02CB1A584E9400E8FCFE /* Sources */, 176 | D1FD02CC1A584E9400E8FCFE /* Frameworks */, 177 | D1FD02CD1A584E9400E8FCFE /* Resources */, 178 | ); 179 | buildRules = ( 180 | ); 181 | dependencies = ( 182 | D1FD02D11A584E9400E8FCFE /* PBXTargetDependency */, 183 | ); 184 | name = SwiftObjcCocoapodsExampleTests; 185 | productName = SwiftObjcCocoapodsExampleTests; 186 | productReference = D1FD02CF1A584E9400E8FCFE /* SwiftObjcCocoapodsExampleTests.xctest */; 187 | productType = "com.apple.product-type.bundle.unit-test"; 188 | }; 189 | /* End PBXNativeTarget section */ 190 | 191 | /* Begin PBXProject section */ 192 | D1FD02B21A584E9400E8FCFE /* Project object */ = { 193 | isa = PBXProject; 194 | attributes = { 195 | LastUpgradeCheck = 0610; 196 | ORGANIZATIONNAME = "張 景隆"; 197 | TargetAttributes = { 198 | D1FD02B91A584E9400E8FCFE = { 199 | CreatedOnToolsVersion = 6.1.1; 200 | }; 201 | D1FD02CE1A584E9400E8FCFE = { 202 | CreatedOnToolsVersion = 6.1.1; 203 | TestTargetID = D1FD02B91A584E9400E8FCFE; 204 | }; 205 | }; 206 | }; 207 | buildConfigurationList = D1FD02B51A584E9400E8FCFE /* Build configuration list for PBXProject "SwiftObjcCocoapodsExample" */; 208 | compatibilityVersion = "Xcode 3.2"; 209 | developmentRegion = English; 210 | hasScannedForEncodings = 0; 211 | knownRegions = ( 212 | en, 213 | Base, 214 | ); 215 | mainGroup = D1FD02B11A584E9400E8FCFE; 216 | productRefGroup = D1FD02BB1A584E9400E8FCFE /* Products */; 217 | projectDirPath = ""; 218 | projectRoot = ""; 219 | targets = ( 220 | D1FD02B91A584E9400E8FCFE /* SwiftObjcCocoapodsExample */, 221 | D1FD02CE1A584E9400E8FCFE /* SwiftObjcCocoapodsExampleTests */, 222 | ); 223 | }; 224 | /* End PBXProject section */ 225 | 226 | /* Begin PBXResourcesBuildPhase section */ 227 | D1FD02B81A584E9400E8FCFE /* Resources */ = { 228 | isa = PBXResourcesBuildPhase; 229 | buildActionMask = 2147483647; 230 | files = ( 231 | D1FD02C51A584E9400E8FCFE /* Main.storyboard in Resources */, 232 | D1FD02CA1A584E9400E8FCFE /* LaunchScreen.xib in Resources */, 233 | D1FD02C71A584E9400E8FCFE /* Images.xcassets in Resources */, 234 | ); 235 | runOnlyForDeploymentPostprocessing = 0; 236 | }; 237 | D1FD02CD1A584E9400E8FCFE /* Resources */ = { 238 | isa = PBXResourcesBuildPhase; 239 | buildActionMask = 2147483647; 240 | files = ( 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | }; 244 | /* End PBXResourcesBuildPhase section */ 245 | 246 | /* Begin PBXShellScriptBuildPhase section */ 247 | 04383FF8E8FCED08D87E070D /* Check Pods Manifest.lock */ = { 248 | isa = PBXShellScriptBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | ); 252 | inputPaths = ( 253 | ); 254 | name = "Check Pods Manifest.lock"; 255 | outputPaths = ( 256 | ); 257 | runOnlyForDeploymentPostprocessing = 0; 258 | shellPath = /bin/sh; 259 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 260 | showEnvVarsInLog = 0; 261 | }; 262 | ABE4FDD98E38E28857E89D02 /* Copy Pods Resources */ = { 263 | isa = PBXShellScriptBuildPhase; 264 | buildActionMask = 2147483647; 265 | files = ( 266 | ); 267 | inputPaths = ( 268 | ); 269 | name = "Copy Pods Resources"; 270 | outputPaths = ( 271 | ); 272 | runOnlyForDeploymentPostprocessing = 0; 273 | shellPath = /bin/sh; 274 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwiftObjcCocoapodsExample/Pods-SwiftObjcCocoapodsExample-resources.sh\"\n"; 275 | showEnvVarsInLog = 0; 276 | }; 277 | /* End PBXShellScriptBuildPhase section */ 278 | 279 | /* Begin PBXSourcesBuildPhase section */ 280 | D1FD02B61A584E9400E8FCFE /* Sources */ = { 281 | isa = PBXSourcesBuildPhase; 282 | buildActionMask = 2147483647; 283 | files = ( 284 | D1FD02C21A584E9400E8FCFE /* ViewController.swift in Sources */, 285 | D1FD02E41A58D8A000E8FCFE /* SwiftIPManager.swift in Sources */, 286 | D1FD02E71A58DEF400E8FCFE /* ObjcIPManager.m in Sources */, 287 | D1FD02C01A584E9400E8FCFE /* AppDelegate.swift in Sources */, 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | }; 291 | D1FD02CB1A584E9400E8FCFE /* Sources */ = { 292 | isa = PBXSourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | D1FD02D61A584E9400E8FCFE /* SwiftObjcCocoapodsExampleTests.swift in Sources */, 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | /* End PBXSourcesBuildPhase section */ 300 | 301 | /* Begin PBXTargetDependency section */ 302 | D1FD02D11A584E9400E8FCFE /* PBXTargetDependency */ = { 303 | isa = PBXTargetDependency; 304 | target = D1FD02B91A584E9400E8FCFE /* SwiftObjcCocoapodsExample */; 305 | targetProxy = D1FD02D01A584E9400E8FCFE /* PBXContainerItemProxy */; 306 | }; 307 | /* End PBXTargetDependency section */ 308 | 309 | /* Begin PBXVariantGroup section */ 310 | D1FD02C31A584E9400E8FCFE /* Main.storyboard */ = { 311 | isa = PBXVariantGroup; 312 | children = ( 313 | D1FD02C41A584E9400E8FCFE /* Base */, 314 | ); 315 | name = Main.storyboard; 316 | sourceTree = ""; 317 | }; 318 | D1FD02C81A584E9400E8FCFE /* LaunchScreen.xib */ = { 319 | isa = PBXVariantGroup; 320 | children = ( 321 | D1FD02C91A584E9400E8FCFE /* Base */, 322 | ); 323 | name = LaunchScreen.xib; 324 | sourceTree = ""; 325 | }; 326 | /* End PBXVariantGroup section */ 327 | 328 | /* Begin XCBuildConfiguration section */ 329 | D1FD02D71A584E9400E8FCFE /* Debug */ = { 330 | isa = XCBuildConfiguration; 331 | buildSettings = { 332 | ALWAYS_SEARCH_USER_PATHS = NO; 333 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 334 | CLANG_CXX_LIBRARY = "libc++"; 335 | CLANG_ENABLE_MODULES = YES; 336 | CLANG_ENABLE_OBJC_ARC = YES; 337 | CLANG_WARN_BOOL_CONVERSION = YES; 338 | CLANG_WARN_CONSTANT_CONVERSION = YES; 339 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 340 | CLANG_WARN_EMPTY_BODY = YES; 341 | CLANG_WARN_ENUM_CONVERSION = YES; 342 | CLANG_WARN_INT_CONVERSION = YES; 343 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 344 | CLANG_WARN_UNREACHABLE_CODE = YES; 345 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 346 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 347 | COPY_PHASE_STRIP = NO; 348 | ENABLE_STRICT_OBJC_MSGSEND = YES; 349 | GCC_C_LANGUAGE_STANDARD = gnu99; 350 | GCC_DYNAMIC_NO_PIC = NO; 351 | GCC_OPTIMIZATION_LEVEL = 0; 352 | GCC_PREPROCESSOR_DEFINITIONS = ( 353 | "DEBUG=1", 354 | "$(inherited)", 355 | ); 356 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 357 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 358 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 359 | GCC_WARN_UNDECLARED_SELECTOR = YES; 360 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 361 | GCC_WARN_UNUSED_FUNCTION = YES; 362 | GCC_WARN_UNUSED_VARIABLE = YES; 363 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 364 | MTL_ENABLE_DEBUG_INFO = YES; 365 | ONLY_ACTIVE_ARCH = YES; 366 | SDKROOT = iphoneos; 367 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 368 | }; 369 | name = Debug; 370 | }; 371 | D1FD02D81A584E9400E8FCFE /* Release */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ALWAYS_SEARCH_USER_PATHS = NO; 375 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 376 | CLANG_CXX_LIBRARY = "libc++"; 377 | CLANG_ENABLE_MODULES = YES; 378 | CLANG_ENABLE_OBJC_ARC = YES; 379 | CLANG_WARN_BOOL_CONVERSION = YES; 380 | CLANG_WARN_CONSTANT_CONVERSION = YES; 381 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 382 | CLANG_WARN_EMPTY_BODY = YES; 383 | CLANG_WARN_ENUM_CONVERSION = YES; 384 | CLANG_WARN_INT_CONVERSION = YES; 385 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 386 | CLANG_WARN_UNREACHABLE_CODE = YES; 387 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 388 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 389 | COPY_PHASE_STRIP = YES; 390 | ENABLE_NS_ASSERTIONS = NO; 391 | ENABLE_STRICT_OBJC_MSGSEND = YES; 392 | GCC_C_LANGUAGE_STANDARD = gnu99; 393 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 394 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 395 | GCC_WARN_UNDECLARED_SELECTOR = YES; 396 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 397 | GCC_WARN_UNUSED_FUNCTION = YES; 398 | GCC_WARN_UNUSED_VARIABLE = YES; 399 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 400 | MTL_ENABLE_DEBUG_INFO = NO; 401 | SDKROOT = iphoneos; 402 | VALIDATE_PRODUCT = YES; 403 | }; 404 | name = Release; 405 | }; 406 | D1FD02DA1A584E9400E8FCFE /* Debug */ = { 407 | isa = XCBuildConfiguration; 408 | baseConfigurationReference = AE522E377491A49F6914BC1D /* Pods-SwiftObjcCocoapodsExample.debug.xcconfig */; 409 | buildSettings = { 410 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 411 | CLANG_ENABLE_MODULES = YES; 412 | INFOPLIST_FILE = SwiftObjcCocoapodsExample/Info.plist; 413 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 414 | PRODUCT_NAME = "$(TARGET_NAME)"; 415 | SWIFT_OBJC_BRIDGING_HEADER = "SwiftObjcCocoapodsExample/SwiftObjcCocoapodsExample-Bridging-Header.h"; 416 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 417 | }; 418 | name = Debug; 419 | }; 420 | D1FD02DB1A584E9400E8FCFE /* Release */ = { 421 | isa = XCBuildConfiguration; 422 | baseConfigurationReference = 44619E4F81E4B51ED9F92EE6 /* Pods-SwiftObjcCocoapodsExample.release.xcconfig */; 423 | buildSettings = { 424 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 425 | CLANG_ENABLE_MODULES = YES; 426 | INFOPLIST_FILE = SwiftObjcCocoapodsExample/Info.plist; 427 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 428 | PRODUCT_NAME = "$(TARGET_NAME)"; 429 | SWIFT_OBJC_BRIDGING_HEADER = "SwiftObjcCocoapodsExample/SwiftObjcCocoapodsExample-Bridging-Header.h"; 430 | }; 431 | name = Release; 432 | }; 433 | D1FD02DD1A584E9400E8FCFE /* Debug */ = { 434 | isa = XCBuildConfiguration; 435 | buildSettings = { 436 | BUNDLE_LOADER = "$(TEST_HOST)"; 437 | FRAMEWORK_SEARCH_PATHS = ( 438 | "$(SDKROOT)/Developer/Library/Frameworks", 439 | "$(inherited)", 440 | ); 441 | GCC_PREPROCESSOR_DEFINITIONS = ( 442 | "DEBUG=1", 443 | "$(inherited)", 444 | ); 445 | INFOPLIST_FILE = SwiftObjcCocoapodsExampleTests/Info.plist; 446 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 447 | PRODUCT_NAME = "$(TARGET_NAME)"; 448 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftObjcCocoapodsExample.app/SwiftObjcCocoapodsExample"; 449 | }; 450 | name = Debug; 451 | }; 452 | D1FD02DE1A584E9400E8FCFE /* Release */ = { 453 | isa = XCBuildConfiguration; 454 | buildSettings = { 455 | BUNDLE_LOADER = "$(TEST_HOST)"; 456 | FRAMEWORK_SEARCH_PATHS = ( 457 | "$(SDKROOT)/Developer/Library/Frameworks", 458 | "$(inherited)", 459 | ); 460 | INFOPLIST_FILE = SwiftObjcCocoapodsExampleTests/Info.plist; 461 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 462 | PRODUCT_NAME = "$(TARGET_NAME)"; 463 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftObjcCocoapodsExample.app/SwiftObjcCocoapodsExample"; 464 | }; 465 | name = Release; 466 | }; 467 | /* End XCBuildConfiguration section */ 468 | 469 | /* Begin XCConfigurationList section */ 470 | D1FD02B51A584E9400E8FCFE /* Build configuration list for PBXProject "SwiftObjcCocoapodsExample" */ = { 471 | isa = XCConfigurationList; 472 | buildConfigurations = ( 473 | D1FD02D71A584E9400E8FCFE /* Debug */, 474 | D1FD02D81A584E9400E8FCFE /* Release */, 475 | ); 476 | defaultConfigurationIsVisible = 0; 477 | defaultConfigurationName = Release; 478 | }; 479 | D1FD02D91A584E9400E8FCFE /* Build configuration list for PBXNativeTarget "SwiftObjcCocoapodsExample" */ = { 480 | isa = XCConfigurationList; 481 | buildConfigurations = ( 482 | D1FD02DA1A584E9400E8FCFE /* Debug */, 483 | D1FD02DB1A584E9400E8FCFE /* Release */, 484 | ); 485 | defaultConfigurationIsVisible = 0; 486 | defaultConfigurationName = Release; 487 | }; 488 | D1FD02DC1A584E9400E8FCFE /* Build configuration list for PBXNativeTarget "SwiftObjcCocoapodsExampleTests" */ = { 489 | isa = XCConfigurationList; 490 | buildConfigurations = ( 491 | D1FD02DD1A584E9400E8FCFE /* Debug */, 492 | D1FD02DE1A584E9400E8FCFE /* Release */, 493 | ); 494 | defaultConfigurationIsVisible = 0; 495 | defaultConfigurationName = Release; 496 | }; 497 | /* End XCConfigurationList section */ 498 | }; 499 | rootObject = D1FD02B21A584E9400E8FCFE /* Project object */; 500 | } 501 | -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwiftObjcCocoapodsExample 4 | // 5 | // Created by 張 景隆 on 2015/1/4. 6 | // Copyright (c) 2015年 張 景隆. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExample/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.appletone.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExample/ObjcIPManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // ObjcIPManager.h 3 | // SwiftObjcCocoapodsExample 4 | // 5 | // Created by 張 景隆 on 2015/1/4. 6 | // Copyright (c) 2015年 張 景隆. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ObjcIPManager : NSObject 12 | +(void)getIP; 13 | +(void)getIPFromSwift; 14 | @end 15 | -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExample/ObjcIPManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // ObjcIPManager.m 3 | // SwiftObjcCocoapodsExample 4 | // 5 | // Created by 張 景隆 on 2015/1/4. 6 | // Copyright (c) 2015年 張 景隆. All rights reserved. 7 | // 8 | 9 | #import "ObjcIPManager.h" 10 | #import 11 | #import "SwiftObjcCocoapodsExample-Swift.h" 12 | 13 | @implementation ObjcIPManager 14 | 15 | +(void)getIP 16 | { 17 | NSLog(@"[ObjcIPManager ObjcIPManager]"); 18 | 19 | AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; 20 | [manager GET:@"http://ip.jsontest.com" parameters:nil 21 | success:^(AFHTTPRequestOperation *operation, id responseObject) { 22 | // 23 | NSLog(@"from ObjcIPManager = %@", responseObject[@"ip"]); 24 | } 25 | failure:^(AFHTTPRequestOperation *operation, NSError *error) { 26 | // 27 | } 28 | ]; 29 | } 30 | 31 | +(void)getIPFromSwift 32 | { 33 | NSLog(@"[ObjcIPManager getIPFromSwift]"); 34 | 35 | [SwiftIPManager getIP]; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExample/SwiftIPManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftIPManager.swift 3 | // SwiftObjcCocoapodsExample 4 | // 5 | // Created by 張 景隆 on 2015/1/4. 6 | // Copyright (c) 2015年 張 景隆. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | @objc public class SwiftIPManager { 12 | public class func getIP() { 13 | println("SwiftIPManager.getIP()") 14 | 15 | let manager = AFHTTPRequestOperationManager() 16 | 17 | manager.GET("http://ip.jsontest.com", 18 | parameters: nil, 19 | success: { (op:AFHTTPRequestOperation!, obj:AnyObject!) -> Void in 20 | // 21 | let ip = obj["ip"] 22 | println("from SwiftIPManager = \(ip) ") 23 | }, 24 | failure: { (req:AFHTTPRequestOperation!, err:NSError!) -> Void in 25 | // 26 | }) 27 | } 28 | } -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExample/SwiftObjcCocoapodsExample-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import 6 | #import "ObjcIPManager.h" -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SwiftObjcCocoapodsExample 4 | // 5 | // Created by 張 景隆 on 2015/1/4. 6 | // Copyright (c) 2015年 張 景隆. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | 17 | // call Swift 18 | SwiftIPManager.getIP() 19 | 20 | // call ObjC 21 | ObjcIPManager.getIP() 22 | 23 | // from Objc call Swift 24 | ObjcIPManager.getIPFromSwift() 25 | } 26 | 27 | override func didReceiveMemoryWarning() { 28 | super.didReceiveMemoryWarning() 29 | // Dispose of any resources that can be recreated. 30 | } 31 | 32 | 33 | //***************************************** 34 | func afnetworkingTesting() { 35 | let manager = AFHTTPRequestOperationManager() 36 | 37 | manager.GET("http://ip.jsontest.com", 38 | parameters: nil, 39 | success: { (op:AFHTTPRequestOperation!, obj:AnyObject!) -> Void in 40 | // 41 | }, 42 | failure: { (req:AFHTTPRequestOperation!, err:NSError!) -> Void in 43 | // 44 | }) 45 | 46 | 47 | // 省略 -> Void 48 | manager.GET("http://ip.jsontest.com", 49 | parameters: nil, 50 | success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) in 51 | println(responseObject["ip"]) 52 | }, 53 | failure: { (operation: AFHTTPRequestOperation!, error: NSError!) in 54 | } 55 | ) 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.appletone.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SwiftObjcCocoapodsExampleTests/SwiftObjcCocoapodsExampleTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftObjcCocoapodsExampleTests.swift 3 | // SwiftObjcCocoapodsExampleTests 4 | // 5 | // Created by 張 景隆 on 2015/1/4. 6 | // Copyright (c) 2015年 張 景隆. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class SwiftObjcCocoapodsExampleTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------